Hi -
I’m working on an app communicating with a Notecard, using FreeRTOS (on an STM Nucleo-U083RC). When I submit requests to the Notecard from a FreeRTOS thread, and then send the response to the terminal, everything seems to work OK. But I’m concerned about memory leaks, so I have tried to use NoteDeleteResponse
after I’ve printed out the response. If I do that, the thread is permanently blocked. I can, however, use JFree
on the response and the thread is not blocked, but I don’t think JFree
is sufficient (or else why is there NoteDeleteResponse
?).
Here’s a sample:
J *req = NoteNewRequest("hub.get");
J* rsp = NoteRequestResponseWithRetry(req, 5);
char* pp = JPrintUnformatted(rsp);
printf("\n\r** RSP %s **\n\r", pp);
JFree(pp);
NoteDeleteResponse(rsp);
As I say, if I comment out the NoteDeleteResponse
(or replace with JFree
) the thread runs just fine (but memory leaks?), but with the NoteDeleteResponse
in place the thread is blocked at that method call.
Since I’m using FreeRTOS, I’ve added wrappers around the thread-safe malloc
and free
equivalents:
void *tsmalloc(size_t size)
{
void *ptr = NULL;
if (size > 0)
{
ptr = pvPortMalloc(size);
}
return ptr;
}
void tsfree(void *ptr)
{
if (ptr)
{
vPortFree(ptr);
}
}
… and passed references to NoteSetFn
:
NoteSetFn(tsmalloc, tsfree, delay, millis);
Any ideas what I’m doing wrong here, or what I can try to prevent the thread from being blocked while avoiding memory leaks?