MQX memory allocation

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

MQX memory allocation

937 Views
marcomello95
Contributor I

I'd like to understand how MQX really allocate memory. I couldn't fint it in the Reference Manual or in user guide. Is it using the HEAP? Is it using other regions? I'm searching to understand this mechanism.

0 Kudos
Reply
1 Reply

890 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi @marcomello95 :

 

MQX uses its own memory allocation system, which does not reply on heap.  The default MQX memory pool, where MQX kernel allocates system memory,  is between  __KERNEL_DATA_START and __KERNEL_DATA_END (symbols generated during bsp linkage).

MQX allocates memory using function _mem_alloc_system(). On top of this, in bsp we can define malloc() to call _mem_alloc_system(), to do this you need to follow these steps:
-       First you have to define _mem_alloc_system* in preprocessor to be malloc
#define _mem_alloc_system malloc

-       Then disable bsp "duplicate" definition of malloc (either by link order or be removing the duplicate definition from the sources).

 

Regards

Daniel

0 Kudos
Reply