adl_atCmdCreate leaks Memory!

Hello all,

As mentioned in this topic: OpenAT 4.11 leaks memory?
I have found that this also happens with OpenAt OS 4.21 (FW 6.63)!!!
In my case adl_atCmdCreate consumes 160Bytes every call !!!

You can test this behaviour by a little function:

void Debug_PrintFreeMem(void)
{
  void * pMem;

  /* get 32 byte buffer */
  pMem = adl_memGet(32);
  if( pMem != NULL )
  {
    /* get sucess */
    DebugPrint("Mem Pointer: %X\r\n", pMem);
    adl_memRelease(pMem);
  }
  else
  {
    DebugPrint("Error no free Heap available!\r\n");
  }
}

The Pointer should be nearly the same every call. If it increases, you have the problem that
you call adl_atCmdCreate cyclic.

Wavecom should fix this as soon as possbile!

regards,
Gregor Bader

Hello,

I have not noticed this kind of memory leakage in that OS. I don’t think that adl_atCmdCreate function has that problem now. Which AT commands did you call? Please include your full code, with the atCmdCreate functions.

I don’t exactly understand your reasoning, especially when i did not see any adl_atCmdCreate in your code. If you mean that you don’t get the same address from adl_memGet after the releasing the same block than my question is: Did you try this on the same session or using for example a timer ? I don’t know the exact behaviour of the OAT memory manager, but i presume the garbage collector takes effect, after you give back the full control to the OS.

Cheers,
tom

Hi,

Actually my sample code only shows how you can display the memory leak.

I cant’t post my original code of course, so I tried to write an app which produces
this effect (with a timer called every 500ms calling AT+CSQ). But unfortunately
this small app doesn’t have that same memory leak effect.
So I think there are some other influcenes from my original application.

In my application a timer is setup with 500ms calling AT+CSQ see:

void SiqnalQualityTimerHandler_ ( u8 ID )
{
  adl_atCmdCreate("AT+CSQ",FALSE, (adl_atRspHandler_t) ReadSignalQualityResponseHdl__,"+CSQ:",NULL);

  Debug_PrintFreeMem();
}

The Pointer I get from adl_memGet increases steadily until the whole heap is used and an exception raised.
When I comment the line with adl_atCmdCreate… the pointer stays nearly the same.

Here the debug output where you see the memory leak:

Mem Pointer: 180C6824
Mem Pointer: 180C7824
Mem Pointer: 180C78C4
Mem Pointer: 180C7924
Mem Pointer: 180C79C4
Mem Pointer: 180C7A64
Mem Pointer: 180C7B04
Mem Pointer: 180C7BA4
Mem Pointer: 180C7C44
Mem Pointer: 180C7CE4
Mem Pointer: 180C7D84
Mem Pointer: 180C7E24
Mem Pointer: 180C7EC4
Mem Pointer: 180C7F64
Mem Pointer: 180C8004
Mem Pointer: 180C80A4
Mem Pointer: 180C8144
Mem Pointer: 180C81E4
Mem Pointer: 180C8284
Mem Pointer: 180C8324
Mem Pointer: 180C83C4

and here with the commented adl_atCmdCreate:

Mem Pointer: 180C6124
Mem Pointer: 180C6164
Mem Pointer: 180C6024
Mem Pointer: 180C6064
Mem Pointer: 180C6124
Mem Pointer: 180C6164
Mem Pointer: 180C6024
Mem Pointer: 180C6064
Mem Pointer: 180C6124
Mem Pointer: 180C6164
Mem Pointer: 180C6024
Mem Pointer: 180C6064
Mem Pointer: 180C6124
Mem Pointer: 180C6164

That sounds like a really bad idea! :open_mouth:

Remember: an AT Command hasn’t completed until you’ve had its Terminal response; therefore you should at least wait until you’ve had the Terminal response before issuing another command.

Probably better to start the timer on receving the Terminal response?

In this particular case, to get signal strength updates, why not just use AT+CCED to request RSSI updates? 8)

Hi,

Indeed thats the better solution.

I finally found that the problem lies with AT+CSQ only not with adl_atCmdCreate.
And only when the GPRS stack is switched off which was burried in my orig. application when using
USB.

Here is the sample code:

#include "adl_global.h"

const u16 wm_apmCustomStackSize = 1024;

char Debug_szDbgOut[200];

#define DebugPrint(szText, ...) \
do {\
  wm_sprintf(Debug_szDbgOut, (szText) , ## __VA_ARGS__ ); \
  adl_atSendResponse ( ADL_AT_PORT_TYPE(ADL_AT_UART1,ADL_AT_UNS), Debug_szDbgOut); \
} while(0)
/* end of define */

void Debug_PrintFreeMem(void)
{
  void * pMem;

  /* get 32 byte buffer */
  pMem = adl_memGet(32);
  if( pMem != NULL )
  {
    /* get sucess */
    DebugPrint("Mem Pointer: %X\r\n", pMem);
    adl_memRelease(pMem);
  }
  else
  {
    DebugPrint("Error no free Heap available!\r\n");
  }
}


void SiqnalQualityTimerHandler ( u8 ID )
{
  adl_atCmdCreate("AT+CSQ",ADL_AT_PORT_TYPE(ADL_AT_UART1,TRUE), (adl_atRspHandler_t) NULL,NULL);

  Debug_PrintFreeMem();
}

void adl_main ( adl_InitType_e InitType )
{
  TRACE (( 1, "Embedded Application : Main" ));

  // start signal quality measurement
  adl_tmrSubscribe ( TRUE, 50, ADL_TMR_TYPE_100MS, SiqnalQualityTimerHandler );

  // deactivate GPRS stack
  adl_atCmdCreate("AT+CFUN=0",FALSE, (adl_atRspHandler_t) NULL,NULL,NULL);
}

Although there is no point asking for the csq value when the gsm stack is off, it should not cause that kind of problem. The situation may be the same with other gsm related commands.

Cheers,
tom