# Cyphal memory management (solved)

**URL:** <https://forum.opencyphal.org/t/cyphal-memory-management-solved/2414>\
**Category:** Libcanard\
**Created:** [September 4, 2025, 11:29am UTC](https://forum.opencyphal.org/t/cyphal-memory-management-solved/2414 "2025-09-04T11:29:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gubo\_hms](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/g/ed655f/32.png) [@gubo\_hms](https://forum.opencyphal.org/u/gubo_hms)\
**Post date:** [September 4, 2025, 11:29am UTC](https://forum.opencyphal.org/t/cyphal-memory-management-solved/2414/1 "2025-09-04T11:29:32Z")

</div>

Hello,  
I’m working on a microcontroller-based diagnostic-tool for a openCyphal Network. I use the sourcecode generated by nunavut. (nnvg.exe) an CANARD\_VERSION\_MAJOR 3  
In the diagnostic tool I can enter a menu for cyphal-diagnostic and leave the menu again, which should uninitialize everything that is allocated by malloc. I call canardRxUnsubscribe() for all subscriptions.  
To find malloc/free errors in my application I track the amount of allocated and freed memory when I enter/leave a menu. Now it seems that when I quit the cyphal diagnostic menu while the CAN-bus is working, 1-2 mallocs are not freed, each time I enter/exit this menu another 1-2 mallocs are not freed.  
When there is no CAN-traffic during enter/exit this diagnostic-menu, the amount of allocated memory is correct

My assumption is that there are unprocessed receive data in the receive buffers. I assume the receive-function allocates the required memory for payload-size, and this payload is freed when the receive-data is processed.

Would canardRxUnsubscribe() clear any remaining data from the recevie-buffers?  
Or is there another function that I can call to free all allocated memory from the receive-buffers?

Regards,  
Gunnar

Problem solved, a typo in my unsubscribe function. One subject was not unsubscribed…
