I\'m trying to find out how to fix these memory leaks I\'m getting while running this program with Valgrind. The leaks occur with the two allocations in nShell_client_main
libuv is not done with a handle until it's close callback is called. That is the exact moment when you can free the handle.
I see you call uv_loop_close
, but you don't check for the return value. If there are still pending handles, it will return UV_EBUSY, so you should check for that.
If you want to close a loop and close all handles, you need to do the following:
uv_stop
to stop the loopuv_walk
and call uv_close
on all handles which are not closinguv_run
so all close callbacks are called and you can free the memory in the callbacksuv_loop_close
, it should return 0 now