Visible to Intel only — GUID: mwh1416946807722
Ixiasoft
Visible to Intel only — GUID: mwh1416946807722
Ixiasoft
7.15.3. Placement of the Heap and Stack
By default, the heap and stack are placed in the same memory partition as the .rwdata section. The stack grows downwards (toward lower addresses) from the end of the section. The heap grows upwards from the last used memory in the .rwdata section. You can control the placement of the heap and stack by manipulating BSP settings.
By default, the HAL performs no stack or heap checking. This makes function calls and memory allocation faster, but it means that malloc() (in C) and new (in C++) are unable to detect heap exhaustion. You can enable run-time stack checking by manipulating BSP settings. With stack checking on, malloc() and new() can detect heap exhaustion.
To specify the heap size limit, set the preprocessor symbol ALT_MAX_HEAP_BYTES to the maximum heap size in decimal. For example, the preprocessor argument -DALT_MAX_HEAP_BYTES=1048576 sets the heap size limit to 0x100000. You can specify this command-line option through a BSP setting.
For more information about manipulating BSP settings, refer to the “HAL BSP Settings” chapter.
Stack checking has performance costs. If you choose to leave stack checking turned off, you must code your program so as to ensure that it operates within the limits of available heap and stack memory.
For more information about selecting stack and heap placement, and setting up stack checking, refer to the " Nios® II Software Build Tools" chapter.
For more information about how to control BSP settings, refer to the “HAL BSP Settings” chapter.