On 05/06/2015 11:17 AM, MELWIN JOSE wrote:
> http://stackoverflow.com/questions/30046114/memory-leak-in-hiredis-using-valgrind
> 
> I ran valgrind on my code which uses hiredis, it points out the
> following individual lines in my code :
> 
>   * redisAsyncConnect()
>   * redisAsyncConnectUnix()
>   * redisLibuvAttach()
>   * uv_loop_new()
> 
> I have used 'redisAsyncDisconnect' to free up the memory for the first
> two cases, couldn't find the right method for third one. For the fourth
> one i used uv_stop(). But still valgrind says there is definitely a loss
> in memory in all the four, what is the right way to release the memory ?
> 

The only libuv related function there is uv_loop_new, which you need to
pair with uv_loop_delete in order for the loop resources to be cleaned up.

Also, uv_loop_new is the "old" API, after 1.0 it's preferred to use
uv_loop_init / uv_loop_close:

uv_loop_t* loop = malloc(sizeof *loop);
uv_loop_init(loop);
/* do your stuff */

uv_loop_close(loop);  /* if it returns 0 the loop has disposed of all
resources */
free(loop);


Cheers,

-- 
Saúl Ibarra Corretgé
bettercallsaghul.com


-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to