Memory leaks while using PPP and UDP

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

Memory leaks while using PPP and UDP

1,052 Views
Gra
Contributor II

Hi

We have a project using MQX 4.1 that sends and receives UDP data via a GPRS modem. To do this it uses PPP_init() to get the PPP link and then sockets to communicate. It all works perfectly! When the modem drops the PPP link due to bad coverage etc, the socket is closed and the PPP shutdown with PPP_release(), the equipment then attempts to establish the connection again and this is where the problem is. Every time PPP_init() is called the peak RAM usage (using _mem_get_highwater) goes up 944 bytes and eventually the unit runs out of RAM and stops. I tried PPP_pause() and PPP_resume() which didn’t increase the peak memory usage, but it failed to resume after 19 successful attempts with an error message.

Thinking we must be doing something wrong I had a play with the GPRS project example included in MQX4.2. I’ve got it running on the K60 Tower connected to a Sierra Wireless modem. It successfully pings a server on our APN. To make it more like our project I then modified it to continually re open the PPP connection, ping and close the PPP connection. On running this I also found that peak RAM usage goes up, just in a slightly different way.

To monitor the RAM usage I use _mem_get_highwater(). This works really well on our project, but using it with the GPRS example it seems to:

  1. Always start at 65523 bytes, when the project cannot possibly have used that much
  2. Not increase for many PPP connect / disconnect cycles, but then suddenly jump up 9424 bytes in one go.
  3. Eventually then settle to more steady, slower, smaller increases in RAM use.

So I guess my questions are:

  1. Has anyone had experience of memory leakage while using MQX 4.1’s (or MQX 4.2) PPP and sockets?
  2. Has anyone found and fixed the issue in MQX?
  3. Does anyone know of a better way to dynamically monitor RAM used? The documentation states it reports the highest memory location, from which MQX has allocated a memory block, so that’s not ideal as the block may sit on smaller unused areas. There was a _mem_get_free() function in MQX 4 but this has disappeared in later versions.

Many thanks

Graeme

Labels (1)
4 Replies

627 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Graeme,

have you tried MQX4.2 with MQX4.2.0.1 patch? Please note that RTCS is deeply modified by MQX patches. Please also not that it is coming soon (Q1 2016) MQX4.2.0.2 patch. I have reported some PPP issues that will be adressed in this version.


Best regards,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

627 Views
Gra67
Contributor III

Hi Carlos,

Thanks for the suggestion to try MQX 4.2.0.1. Unfortunately it is still leaking memory.

Any update on when the MQX 4.2.0.2 patch will be released? I did a bit of searching on MQX and was a bit alarmed to find:

"MQX RTOS v4.2 is the last major release planned in the classic MQX product line."

I know it states that "Technical support, maintenance releases, and professional services will continue to be available" but how much effort will be put into MQX now there is the Kinetis SDK?

Regards

Graeme

0 Kudos

627 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Graeme,

Besides Task Aware Debugger tool you can use Performace Tool provided by MQX to verify the stack usage. You can find related documentation in MQX_PerfTool_Getting_Started.pdf located in MQX installation path C:\Freescale\Freescale_MQX_4_2\doc\tools\cw

Please note that _mem_get_highwater() returns the highest pointer used in the memory pool. But memory pool is taken from the heap. This does not mean that all the RAM in lower locations outside the heap is used. Moreover, the memory handler can free some space in lower locations of the pool when there is some other memory space allocated in a highest address.

Regarding MQX, we will continue providing support for MQX4.2 for a long timeand as long as costumers keep using it.

Best regards,

Carlos

0 Kudos

627 Views
Gra67
Contributor III

Carlos, I've fixed the leaks:

Solution for memory leaks in MQX 4.1’s PPP_init() and PPP_release()

Could you verify what I've done please?

Cheers

Graeme

0 Kudos