cURL / Mailing Lists / curl-library / Single Mail

curl-library

Memory Leak in Libcurl ( with OpenSSL )

From: 林聖雄 <brother21913_at_yahoo.com.tw>
Date: Tue, 19 Jan 2010 20:31:44 +0800

I noticed that when use libcurl compiled with OpenSSL, IDE would
detect my program have 36(16 + 20) bytes memory leak. Following is my
development enviroment :

IDE: Visual Studio 2005
Libcurl: 7.19.7( with openssl & zlib)

Previously, I use libcurl in dynamic link library, and the IDE
wouldn't detect the memory leak but some tools like AQtime does. So, I
make libcurl ( openssl, zlib ) all to be static library, and import
them into a simple MFC Dialog-based Project. No matter where I put
curl_global_init & curl_global_cleanup, after close the program the
output window will show the memory leak with 36 bytes. Likes:

Detected memory leaks!
Dumping objects ->
{2197} normal block at 0x01030B70, 16 bytes long.
 Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
{2196} normal block at 0x01030A88, 20 bytes long.
 Data: < p > 00 00 00 00 70 0B 03 01 00 00 00 00 04 00 00 00
Object dump complete.

I Have uploaded the demo project to rapidshare:

http://rapidshare.com/files/337349925/TestLibcurlDemo.rar

All You need to do is run the program and close it, the output window
in VS2005 will show you memory leak. I also test the same library in
Win32 console project, and there are no leaks. We use some tools to
find the leak, found there is something with openssl.

Here is the leak that found :

_nh_malloc_dbg dbgheap.c 266 dbgheap.obj
Curl_ossl_init ssluse.c 639 ssluse.obj
Curl_ssl_init sslgen.c 163 sslgen.obj
curl_global_init easy.c 256 easy.obj
CTestLibcurlAppApp::InitInstance testlibcurlapp.cpp 54
 CTestLibcurlAppApp TestLibcurlApp.obj

If I change curl_global_init(CURL_GLOBAL_ALL); to
curl_global_init(CURL_GLOBAL_WIN32); and there is no leak!

Sorry for my poor english.

Tim
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-01-19