# Potential memory leak in libserard

**URL:** <https://forum.opencyphal.org/t/potential-memory-leak-in-libserard/2461>\
**Category:** Applications & Usage\
**Created:** [April 27, 2026, 9:46pm UTC](https://forum.opencyphal.org/t/potential-memory-leak-in-libserard/2461 "2026-04-27T21:46:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgimhof](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@mgimhof](https://forum.opencyphal.org/u/mgimhof)\
**Post date:** [April 27, 2026, 9:46pm UTC](https://forum.opencyphal.org/t/potential-memory-leak-in-libserard/2461/1 "2026-04-27T21:46:01Z")

</div>

I am using the development branch v0\_impl in [GitHub - coderkalyan/libserard: A compact implementation of the Cyphal/serial protocol in C for high-integrity real-time embedded systems · GitHub](https://github.com/coderkalyan/libserard) and find that I am losing memory with every received message.

I think I the issue relates to

```auto
    struct SerardInternalRxSession* rxs =
        (struct SerardInternalRxSession*) cavlSearch((struct SerardTreeNode**) &subscription->sessions,
                                                     (void*) &metadata->remote_node_id,
                                                     &rxSubscriptionPredicateOnSession,
                                                     NULL);

    if (rxs == NULL)
    {
        rxs = (struct SerardInternalRxSession*) ins->memory_rx_session
                  .allocate(ins->memory_rx_session.user_reference, sizeof(struct SerardInternalRxSession));

```

Putting my debugger on allocations, I find that this allocation happens in every call. It is as if rxs was not registered in the cavl tree and thus every search fails, return 0 and a new rxs is allocated.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [April 28, 2026, 4:22pm UTC](https://forum.opencyphal.org/t/potential-memory-leak-in-libserard/2461/2 "2026-04-28T16:22:42Z")

</div>

That implementation remains experimental/incomplete, so issues of this kind are expected. The Cyphal/serial transport remains experimental and there is a possibility that there will be changes to it in [Cyphal v1.1](https://github.com/OpenCyphal/specification/pull/151).
