Most Efficient Way of Combining Large Strings for HTML Response

chadwixk:
Thank you, some great alternative suggestions that I'll look into.

But fundamentally, I'm still just trying to better understand how to manipulate strings efficiently in C++. How would you do the long concatenations using char instead of String?

The general point was that if you use static HTML (or other Web objects), maybe stored in flash memory using either SPIFFS methods or PROGMEM, you don't have to do long concatenations. You simply stream the data collections you have to the browser.

If you are, however, joining lots of data together, it is usually best to use automatic variables so the stack memory they have occupied is cleaned up when their containing function terminates. On the ESP8266 you have, by default, 4K bytes of stack available. Strings, or more direct types of memory allocation like malloc/free use the heap and may not be so nicely cleaned up, leading to fragmentation and possible allocation failure.