Disable Heap

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Disable Heap

跳至解决方案
1,318 次查看
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?

标签 (1)
标记 (4)
0 项奖励
回复
1 解答
1,102 次查看
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 项奖励
回复
1 回复
1,103 次查看
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 项奖励
回复