Problem with adl_memGet and adl_memGetInfo



I’m starting developing an embedded application on the Q2686h dev board (OS v4.22.00).

I use the adl_memGetInfo function to get memory informations. I allocate some memory with the adl_memGet. When I print the memory info before and after the memory allocation, this give me the same result. I thought that the memory heap size will be reduced.

Is it an anormal behaviour or what am I misunderstanding ?



Why do you think that?

Look at the diagram in the ADL User Guide, and the description of adl_memGetInfo.

adl_memGetInfo returns the total heap size - not just the free heap size!


You’re completly right :slight_smile: !

The adl_memGet allocates the memory in the client application RAM memory.

How can I get the current client application ram memory size ?



Hiii dsanchez

Theoretically the maximum amount of memory allocated dynamically for a certain Open AT application can be figured out by deducting the memory size of the call stack and the global variable allocated in Open AT application from the total available RAM size. The adl_memGetInfo () API can be used to find the total available RAM size of the Open AT application which you already know…
The method i would suggest would be a bit complicated but it will not be helpful in case of WIP plug- in… If you are using Open AT, then it can be used… The method is:-

  1. First find out how much heap is available to the application using adl_memGetInfo () API.
  2. Now, redefine the function adl_memGet () and adl_memRelease () by using a macro. For instance, you can do,
    #define adl_memGet myadl_memGet
    #define adl_memRelease myadl_memRelease
    We can put this macro in a header file that is included in all your source files.
  3. Now, create another source file, where the above mentioned header file is not included, and there define the function myadl_memGet and myadl_memRelease as:
    void* myadl_memGet ( u16 size )
    void *ptr;
    ptr = adl_memGet ( size );
    //here we perform the housekeeping and keep track of amount of memory allocated to be allocated to each pointer
    // then call the actual function
    return ptr;
    Bool myadl_memRelease ( void *ptr)
    bool bRet;
    bRet = adl_memRelease ( ptr );
    //Perform the housekeeping using which we can again calculate how much memory is available
  4. Using the above two functions, as soon as the application calls the adl_memGet ( ) or adl_memRelease (), the control will first land into our own function (myadl_memGet or myadl_memRelease()). In this function, we keep track of the amount of memory, that has been allocated or released and then call the actual function that will allocate the memory. Hence, we can know at any point of time, how much heap is present, by simply checking the variables which hold the value of amount of allocated memory.

Hope you find this useful… cheers … :stuck_out_tongue:


Thank you for your answer !

So we can not directly get the information, and I need to ‘overwrite’ the allocation/free memory function to track the memory foot print and deduce it.

Best regards.