We are developing an IoT device communicating via LTE to AWS IoT Hub using authentication by client certificate. For that, we are powering on the modem, do a mqtt_connect, exchange some MQTT messages, then we disconnect and send the modem to lte_lc_offline. After a while, we are restarting the modem and repeat the whole process.
On the 23rd cycle, mqtt_connect blocks forever. Stopping and checking the callstack reveals that the task spends most (if not all) of its time in some memory allocation functions.

My best guess is a memory leak of some kind. Since the code is closed source, I cannot debug this on my own. Therefore I have some questions.
- Where does the nrfxlib does its memory allocation. It does not seem to use the standard Zephyr Heap/k_malloc?
- Is there any way to see how much heap memory is left unallocated?
- Are you sure that the nrfxlib socket functions exit correctly in out-of-memory scenarios?
We are using nrfxlib 1.3.0.
Best Regards
Martin