Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By paulfer
#52512 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
User avatar
By mrburnette
#52697 @Paul,

From: http://domoticx.com/sdk-esp8266-xtensa-architecture-toolchain/
Xtensa lx106 architecture toolchain (100% OpenSource), based on following projects:
https://github.com/jcmvbkbc/crosstool-NG
https://github.com/jcmvbkbc/gcc-xtensa
https://github.com/jcmvbkbc/newlib-xtensa
https://github.com/tommie/lx106-hal
The source code above originates from work done directly by Tensilica Inc., Cadence Design Systems, Inc, and/or their contractors.


So, essentially the ESP8266 tools are GCC and RedHat's Newlib. The memory map for an embedded device supported by GCC typically looks like:
http://www.geeksforgeeks.org/memory-layout-of-c-program/

Your questions are best answered by studying on the GCC docs, IMO.
This may also help:
http://stackoverflow.com/questions/14290879/disassembling-a-flat-binary-file-using-objdump

Ray