strcat to huge char array leads to reset

Hi,

any clue why this doesn't work?

  char htmlContent[26000] = {"bla"};
  strcat(htmlContent, "bla");

The second line resets my NodeMCU.

Stefan

Apart from anything else strcat() only works with strings not Strings

Why the need for such a huge array of chars ?

Few arduinos have enough RAM to accommodate a 26K array of char. Uno for example has 2K.

If you don't use it, the compiler will ignore it so you can declare a bunch of huge arrays, but the second you do something that means one of them actually has to exist, such as that strcat, bad things will happen.

To explain: first I used a String to build the HTML content for my webserver. I ended up with about 26000 characters and it worked correctly. Then I wanted to change the String to a char array. That's why it's so big

You must be using an ESP unit of some kind.. 26000 characters is still quite a lot.. for just one page. If you create the page within a local function i don't see an issue with just using String.

Deva_Rishi:
You must be using an ESP unit of some kind..

StefanHaupt:
The second line resets my NodeMCU.

in deed free memory was the issue. my huge working String operated at the edge. It contained a bit less then 26 thousand characters. As soon as I tried with the char array at exactly 26 thousand characters, I ran out of memory :wink:

Will now split my website into several parts using a top level menu

I am actually thinking there should be a way (to create ?) to send the page from different memory locations, i think it's time to look into the responsible library (of course, which one are you using ESPwebserver ?) Still 26000 ? your webpage must contain images or what ?