[Libwebsockets] Releasing Memory in wsi user_space

Joerg Pommnitz pommnitz at yahoo.com
Tue Oct 4 18:16:29 CEST 2016

Hello all,
I try to keep a pointer to dynamically allocated memory in the per-session user memory. I had hoped to free this memory in LWS_CALLBACK_WSI_DESTROY. This seems to be OK for WS but not for HTTP:

/* outermost destroy notification for wsi (user_space still intact) */
wsi->vhost->protocols[0].callback(wsi, LWS_CALLBACK_WSI_DESTROY,
wsi->user_space, NULL, 0);

vhost->protocols[0].callback(wsi, LWS_CALLBACK_WSI_DESTROY,

Any reason for the different behaviour? And what is the suggested way to handle dynamically allocated per session memory?
 -- Regards       Joerg

More information about the Libwebsockets mailing list