Timeout and overflow of arduino

Find a freeMemory() function. There are many available online.

Make it print the free memory once a minute or something. If you're running out of memory, you will see this easily. Then try cutting out functions until the memory stops disappearing - the last one you cut is the one with the problem.

It's never necessary to use big-S Strings, although they do make certain functions easier.