2
0

README.memoryleak 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. $Id$
  2. _ _ ____ _
  3. ___| | | | _ \| |
  4. / __| | | | |_) | |
  5. | (__| |_| | _ <| |___
  6. \___|\___/|_| \_\_____|
  7. How To Track Down Suspected Memory Leaks in libcurl
  8. ===================================================
  9. Single-threaded
  10. Please note that this memory leak system is not adjusted to work in more
  11. than one thread. If you want/need to use it in a multi-threaded app. Please
  12. adjust accordingly.
  13. Build
  14. Rebuild libcurl with -DCURLDEBUG (usually, rerunning configure with
  15. --enable-debug fixes this). 'make clean' first, then 'make' so that all
  16. files actually are rebuilt properly. It will also make sense to build
  17. libcurl with the debug option (usually -g to the compiler) so that debugging
  18. it will be easier if you actually do find a leak in the library.
  19. This will create a library that has memory debugging enabled.
  20. Modify Your Application
  21. Add a line in your application code:
  22. curl_memdebug("filename");
  23. This will make the malloc debug system output a full trace of all resource
  24. using functions to the given file name. Make sure you rebuild your program
  25. and that you link with the same libcurl you built for this purpose as
  26. described above.
  27. Run Your Application
  28. Run your program as usual. Watch the specified memory trace file grow.
  29. Make your program exit and use the proper libcurl cleanup functions etc. So
  30. that all non-leaks are returned/freed properly.
  31. Analyze the Flow
  32. Use the tests/memanalyze.pl perl script to analyze the memdump file:
  33. tests/memanalyze.pl < memdump
  34. This now outputs a report on what resources that were allocated but never
  35. freed etc. This report is very fine for posting to the list!
  36. If this doesn't produce any output, no leak was detected in libcurl. Then
  37. the leak is mostly likely to be in your code.