We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
How is it possible to see if a heap buffer overflow occured?
I just took a look into the .map file and the size of the .bss section is 0x00003c28. I've 16kB internal RAM. The size of the stack is 0x00000488, which is enough for my application.
In the startup code the heap size is
Heap_Size EQU 0x00000000 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit
Does this means, that the heap size is the rest of the internal memory (up to the stack size)? And so everthing is correct (in my settings)?
best regards Bernd
thanks Per - but which things are located in the heap?
e.g. the hardware buffer for the usart? Because in embedded systems I've nearly never dynamic created variables.
Bernd
Nothing in located in the heap, unless you use an RTOS or a library that places data on the heap - or you write own code that places data on the heap.
An RTOS may use the heap to allocate new threads.
A TCP stack may allocate buffers or new connects on the heap.
A communication library that supports runtime-configurable receive/transmit buffers may create these buffers on the heap.
Code that configures their buffer sizes/buffer counts etc as constants (enum or #defined) can statically allocate their buffers in the bss segment, and then the compiler/linker will take care of the memory allocation (hence static memory allocation).
The heap is for data structures that does not have a known size when the program is built. You might get the size information from a serial port, from configuration in an EEPROM memory or similar after the program has started.