Mail memory not being freed [SOLVED]


I have a device that receives CAN messages using interrupts, passes the messages to a thread using a CircularBuffer and that thread decodes the messages and passes them to the application using a Mail.

The issue is that when there are a lot of messages on the CAN bus (only a few end up on the Mail) the Mail gets full and never empties, even if there are no more messages on the CAN bus.

Once the Mail is full, I cannot get a valid pointer from it, even if I send CAN messages one by one.

The Mail is read in the main loop, a copy is created and the memory is freed. The loop is not stuck.

The device has two CAN interfaces and the Mail was shared between both interfaces so I though that might be the problem and used two Mail, one of each interface with no results.

Any suggestion? I’m using mbed-5.15.3.

EDIT: It was an alloc() without put() that was missed in every code inspection.