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:
- Always start at 65523 bytes, when the project cannot possibly have used that much
- Not increase for many PPP connect / disconnect cycles, but then suddenly jump up 9424 bytes in one go.
- Eventually then settle to more steady, slower, smaller increases in RAM use.
So I guess my questions are:
- Has anyone had experience of memory leakage while using MQX 4.1’s (or MQX 4.2) PPP and sockets?
- Has anyone found and fixed the issue in MQX?
- 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.