Used/Free RAM


#1

I know there used to be a thread about this, but it was on the old forum and is now missing.

How do I calculate the amount of RAM in use by running code and the amount still free given adl_memInfo_t structure:

typedef struct _adl_memInfo_t
{
    u32 TotalSize;
    u32 StackSize;
    u32 HeapSize;
    u32 GlobalSize;
} adl_memInfo_t;

Thanks,
Cory


#2

Hi,

I guess you can use adl_memGetInfo API to get information about the amount
of RAM in use.

Regards,
Paruthiv


#3

Yes, calling adl_memGetInfo will populate the above structure. That much I know. What I can’t seem to determine is the math necessary to calculate the amount of free RAM based on the adl_memInfo_t data. The documentation is a bit unclear about the relationships between the fields in the structure.


#4

Really?

This diagram seems quite clear to me:


#5

So, using that diagram, is is correct to calculate free RAM using the following:

adl_memInfo_t.TotalSize - adl_memInfo_t.Heapsize - adl_memInfo_t.StackSize - adl_memInfo_t.GlobalSize


#6

I tried the previous calculation, and it yields 0.

So, given the values at hand, is there any way to actually calculate how much RAM is in use/free? I am trying to determine if the application is leaking memory over long periods of time.

Cory


#7

Which is what the diagram seems to suggest!

It appears that the Heap expands to fill all the available space.


#8

I am using a code which allocates memory with (adl_megGet) until it runs over memory. During the allocation the memory allocation exception is caught with the error managment. Actually i didn’t give any thought if there is any other nicer way available now.


#9

You can monitor the heap usage of your application using RTK traces in TMT. I think its level 3 (can’t remember exactly). Check with your distributor or FAE for details.