How to find Free RAM in MQX 3.8?

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

How to find Free RAM in MQX 3.8?

Jump to solution
1,802 Views
mariappanramasa
Contributor I

Hi all,

I am new to MQX RTOS infact RTOS itself.

Can anyone please tell me if there is any way to find free RAM space in MQX?

Something similar to "free" in linux.

Thanks in advance

Tags (2)
0 Kudos
Reply
1 Solution
760 Views
BryGuyH
Contributor IV

_mem_get_free

_mem_get_free_from

If you get an error add these files to the lwmem section of the PSP project

(Use this recommendation at your own risk since I don't know why Freescale hasn't included these in the PSP projects. I have not see any adverse affects myself.)

lwm_gfre.c

lwm_gfri.c

lwm_gfrf.c

These files are located in the \mqx\source\lwmem folder. For example the default install on my machine is:

C:\Program Files\Freescale\Freescale MQX 3.8\mqx\source\lwmem

In my application I have a shell command that dumps a bunch of system information. In it I've used the functions like this:

        printf("Static RAM Usage:   %d Bytes\r\n", (uint32_t)_mqx_get_initialization()->START_OF_KERNEL_MEMORY - 0x1FFF0000);

        printf("  Peak RAM Usage:   %d Bytes(%d%%)\r\n", (uint32_t)_mem_get_highwater() - 0x1FFF0000, ((uint32_t)_mem_get_highwater() - 0x1FFF0000)/0x51E);

        printf("Current RAM Free:   %d Bytes(%d%%)\r\n", _mem_get_free(), _mem_get_free()/0x51E);

The magic numbers used above (0x1FFF0000 and 0x51E) are the base memory address (0x1FFF0000) and ram size (0x51E) for the Kinetis K20/K60 chips. Change them to match your system. Mine looks like this when running:

Static RAM Usage:   23712 Bytes

  Peak RAM Usage:   98500 Bytes(75%)

Current RAM Free:   35468 Bytes(27%)

View solution in original post

0 Kudos
Reply
3 Replies
761 Views
BryGuyH
Contributor IV

_mem_get_free

_mem_get_free_from

If you get an error add these files to the lwmem section of the PSP project

(Use this recommendation at your own risk since I don't know why Freescale hasn't included these in the PSP projects. I have not see any adverse affects myself.)

lwm_gfre.c

lwm_gfri.c

lwm_gfrf.c

These files are located in the \mqx\source\lwmem folder. For example the default install on my machine is:

C:\Program Files\Freescale\Freescale MQX 3.8\mqx\source\lwmem

In my application I have a shell command that dumps a bunch of system information. In it I've used the functions like this:

        printf("Static RAM Usage:   %d Bytes\r\n", (uint32_t)_mqx_get_initialization()->START_OF_KERNEL_MEMORY - 0x1FFF0000);

        printf("  Peak RAM Usage:   %d Bytes(%d%%)\r\n", (uint32_t)_mem_get_highwater() - 0x1FFF0000, ((uint32_t)_mem_get_highwater() - 0x1FFF0000)/0x51E);

        printf("Current RAM Free:   %d Bytes(%d%%)\r\n", _mem_get_free(), _mem_get_free()/0x51E);

The magic numbers used above (0x1FFF0000 and 0x51E) are the base memory address (0x1FFF0000) and ram size (0x51E) for the Kinetis K20/K60 chips. Change them to match your system. Mine looks like this when running:

Static RAM Usage:   23712 Bytes

  Peak RAM Usage:   98500 Bytes(75%)

Current RAM Free:   35468 Bytes(27%)

0 Kudos
Reply
760 Views
c0170
Senior Contributor III

Thanks bryan,

I totally missed _mem_get_free functions.:smileysilly:

Regards,

MartinK

760 Views
c0170
Senior Contributor III

Hello mariappanramasamy,

There's _tad_stack_usage() function in tad file which you can find in MQX/source/tad. Or another option is TAD (Task Aware Debugging) which shows stack usage in IDE.

For more information about TAD (5th chapter) : http://cache.freescale.com/files/32bit/doc/app_note/AN3905.pdf

There are more documents where TAD is described for different IDE's. These are located in MQX/doc folder.

Regards,

MartinK