Memory management. Should HTML be on the heap or stack?
Posted: Mon Aug 08, 2016 8:31 pm
Hi All,
OK, so coming from the privileged, albeit spoilt world of c# and GC I have a memory question for you.
I am developing a AP to serve up approx. 2.6 KB of HTML. I store the HTML in a txt file using SPIFFS.
My question is Three-fold:
1. Does the heap/stack allocation work the same as standard c?
2. With regards to memory utilisation, would I be better off to malloc a char[] aray and read the bytes from the .txt file into it and store this 2.6 KB on the heap (and then free() it), or should I just declare the char[] in a function and store it on the stack?
3. Does a char[x] array also get popped off the stack in the same way as int's and long's?
I thank you all in advance,
Paul
OK, so coming from the privileged, albeit spoilt world of c# and GC I have a memory question for you.
I am developing a AP to serve up approx. 2.6 KB of HTML. I store the HTML in a txt file using SPIFFS.
My question is Three-fold:
1. Does the heap/stack allocation work the same as standard c?
2. With regards to memory utilisation, would I be better off to malloc a char[] aray and read the bytes from the .txt file into it and store this 2.6 KB on the heap (and then free() it), or should I just declare the char[] in a function and store it on the stack?
3. Does a char[x] array also get popped off the stack in the same way as int's and long's?
I thank you all in advance,
Paul