Disable Heap

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Disable Heap

Jump to solution
727 Views
twp
Contributor III

We are using the standard linker file for the MPC5643L flash build "MPC5643L_FLASH.lcf" on a product that is required not to use dynamic memory allocation.  What is the best way to disable the heap?  Removing it from the .lcf file still leaves symbols in the map file. Alternatively, changing the size in the project settings C/C++ Build -> Settings -> PowerPC Linker -> Output, to 0K doesn't seem to have any effect.  Is there a safe way to go about this and disable dynamic allocation library functions?

Labels (1)
0 Kudos
1 Solution
511 Views
stanish
NXP Employee
NXP Employee

Hello twp,

It should be enough to remove/comment out the heap memory section from .lcf:

//heap: org = 0x40014000, len = 0x00008000 /* 32K heap core_lsm */

and also linker expressions:

//_heap_addr  = ADDR(heap);

//_heap_end   = ADDR(heap)+SIZEOF(heap);

The linker generates some heap symbols anyway (see the .map file):

_heap_addr 003d7ff0

_heap_end 003d7ff0

but these symbols are equal so the size of heap memory pool is 0. Any attemp to allocate memory using malloc() will not allocate any memory and return 0. You are save and you don't overwrite anything in your SRAM.

Hope it helps.

Stan

View solution in original post

0 Kudos
1 Reply
512 Views
stanish
NXP Employee
NXP Employee

Hello twp,

It should be enough to remove/comment out the heap memory section from .lcf:

//heap: org = 0x40014000, len = 0x00008000 /* 32K heap core_lsm */

and also linker expressions:

//_heap_addr  = ADDR(heap);

//_heap_end   = ADDR(heap)+SIZEOF(heap);

The linker generates some heap symbols anyway (see the .map file):

_heap_addr 003d7ff0

_heap_end 003d7ff0

but these symbols are equal so the size of heap memory pool is 0. Any attemp to allocate memory using malloc() will not allocate any memory and return 0. You are save and you don't overwrite anything in your SRAM.

Hope it helps.

Stan

0 Kudos