2
0

README.memoryleak 1.9 KB

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