Used/Free RAM

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

Hi,

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

Regards,
Paruthiv

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.

Really?

This diagram seems quite clear to me:

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

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

Which is what the diagram seems to suggest!

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

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.

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.