I am clueless with software, so take this with a grain of salt.
Does String not have a bad reputation in the Arduino world, isn't it an object, e.g. one of those OOP things.
On a Raspberry Pi Linux will stop the program and tell the user they have run out of memory (e.g. the heap and stack have collided) but Arduino provides no such service (I don't think AVR even has an interrupt that could be used to do such a service but I have not looked for it either).
On AVR I learned to distrust C++ because I am not good enough to know when I have done something that will use the heap memory, but I have learned that I can use plain old C and it does not use the heap memory (unless I tell it to with memory allocation functions).
Anyway, try to figure out a way to not use String. Also if you want to learn C++ then I suggest the Raspberry Pi will be a better environment.