On Tuesday 24 of November 2009 01:50:02 Dantzler, DeWayne C wrote: > I'm using libcurl with C++ classes in a single threaded application by > setting up the curl env in the constructor and invoking cleanup > operation in the destructor, but I'm having trouble freeing the > allocated memory. I read the curl documentation and tutorial. What is > the correct method of freeing resources?
Kamil wrote: It doesn't matter what programming paradigma are you actually using. Just call curl_global_init()/curl_easy_cleanup() once per whole program. A singleton might be a good candidate if you like clean object-oriented design? Then for each curl_easy_init() you should call one curl_easy_cleanup(). You can wrap it to class and call the functions in its ctor/dtor. Or perhaps use cURLpp binding which does the job for you? Looking at your example again, one thing is clear. You can't call curl_global_cleanup() before curl_easy_cleanup(). ============================================================= Thanks I took your suggestions to try a Singleton and it worked!! Placing the calls to curl_global_init() and curl_easy_init() in the ctor of the Singleton and curl_easy_cleanup()/curl_global_cleanup() in the dtor did not result in a crash or memory leaks. ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
