Hi, I’ve been facing random out of memory restarts in this [device].(https://impcentral.electricimp.com/ide/devices/40000c2a6914b374). I’ve tried with multiple testing to find if the restarts occur at regular intervals or after some event, but they don’t. They occur completely randomly.
Any suggestions as to why this can occur will be really helpful. Thanks.
If by “check that the character count passed to readstring() is always reasonable”, you mean the parameter we pass to the uart.readstring(<parameter>), then I can tell that there are only two places in my code I’ve used this uart.readstring() method and they both don’t contain any arguments passed to them.
According to this documentation, it seems that the parameter in my case will be 10000, because I’ve calleduart.setrxfifosize(10000) during the initialization procedure.
Do you think due to any other reason it could have failed ? BTW, I will also do the imp.getmemoryfree() check to see if the memory is getting leaked.
Ok so every time you call readstring(), impOS requests an additional 10000 byte contiguous allocation from the shared memory heap.
Over time the heap can become fragmented, so you might still see an OOM restart when getmemoryfree() reports a larger value. A downward trend over time would be the concern.
Otherwise can you pass a smaller value parameter to readstring() and process the received data incrementally?
Certainly ! I will try passing in a smaller value than 10000 to uart.readstring() and see if it reduces the OOM restarts. As per your suggestion, I also started printing the freememory periodically and it’s always around 44 KB. No downward trend over time.
But any permanent solution to avoid this OOM restart would be most helpful considering the fact that I’ve large number of devices suffering from this exact problem.