1 $Id: README.memoryleak,v 1.1.1.1 2008-09-23 16:32:05 hoffman Exp $
6 \___|\___/|_| \_\_____|
8 How To Track Down Suspected Memory Leaks in libcurl
9 ===================================================
13 Please note that this memory leak system is not adjusted to work in more
14 than one thread. If you want/need to use it in a multi-threaded app. Please
20 Rebuild libcurl with -DCURLDEBUG (usually, rerunning configure with
21 --enable-debug fixes this). 'make clean' first, then 'make' so that all
22 files actually are rebuilt properly. It will also make sense to build
23 libcurl with the debug option (usually -g to the compiler) so that debugging
24 it will be easier if you actually do find a leak in the library.
26 This will create a library that has memory debugging enabled.
28 Modify Your Application
30 Add a line in your application code:
32 curl_memdebug("dump");
34 This will make the malloc debug system output a full trace of all resource
35 using functions to the given file name. Make sure you rebuild your program
36 and that you link with the same libcurl you built for this purpose as
41 Run your program as usual. Watch the specified memory trace file grow.
43 Make your program exit and use the proper libcurl cleanup functions etc. So
44 that all non-leaks are returned/freed properly.
48 Use the tests/memanalyze.pl perl script to analyze the dump file:
50 tests/memanalyze.pl dump
52 This now outputs a report on what resources that were allocated but never
53 freed etc. This report is very fine for posting to the list!
55 If this doesn't produce any output, no leak was detected in libcurl. Then
56 the leak is mostly likely to be in your code.