Discussion:
I created a C++ wrapper to libcurl (!= curlpp) and worried about memory leaks
Patrick Louis
2013-02-12 11:15:27 UTC
Permalink
Dear libcurl mailing list readers,
I'm working on a little c++ wrapper for libcurl which resembles a lot
the python2 module mechanize.Browser()
Here is the link to the library: https://github.com/venam/Browser
It really makes some tasks look relatively easy compared to the
libcurl or curlpp way of doing.
However, I'm not sure about how I managed to not leak memory.
I tried to put in all the destructors the "free" functions but
running valgrind with --leak-check=yes
shows me that there's some bytes that are leaked during the process.
I'm not an expert in debugging but I see that some leaks are from
libcrypto.

If someone could clear my mind about that or just lead me to a better
way to do things.
(This email is linked with the valgrind logs.)

Thank you for your prompt support,
Patrick Louis
--
_Patrick Louis_
Daniel Stenberg
2013-02-12 11:52:44 UTC
Permalink
If someone could clear my mind about that or just lead me to a better way to
do things.
Without your exact code it is hard to tell, but it seems to be an curl_slist
list that you created with curl_slist_append() that's left allocated.

If you build with debug symbols left, valgrind will tell you the exact source
code line that did it.
--
/ daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Patrick Louis
2013-02-12 12:33:56 UTC
Permalink
Post by Daniel Stenberg
Post by Patrick Louis
If someone could clear my mind about that or just lead me to a
better way to do things.
Without your exact code it is hard to tell, but it seems to be an
curl_slist list that you created with curl_slist_append() that's left
allocated.
If you build with debug symbols left, valgrind will tell you the
exact source code line that did it.
Thanks a lot.
Your answer resolved my whole problem.
I reviewed the whole places where I used the curl_slist_append() and
directly freed the headers after use.
Now I have 0bytes leaked, fabulous.
I'm really glad that "the" Daniel Stenberg replied directly to me, I'm
a big fan of your works and included in my library a form grabber that
outputs exactly like the one you did in perl.

I'll push the updates to my git repo tonight (in 4-5 hours)

Again, thanks, you are an inspiration for the youth!
--
_Patrick Louis_
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Loading...