A Dynamic Approach to Locating Memory Leaks

  • Kostyantyn Vorobyov
  • Padmanabhan Krishnan
  • Phil Stocks
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8254)


We present a dynamic approach to memory leak detection and reporting to aid the debugging process. We track memory allocations and aliases during execution, which allows us not only to detect leaks, but also locate the point of the leak in the source code. The level of tracking can be customised by the user. This analysis is safe in the presence of pointer aliasing – a benefit of the dynamic approach, as such problems are hard to solve using static analysis (or lead to many false positives). Our technique works by instrumenting programs with statements that track memory allocations, capture alias information, and monitor potential leaks. By tracking only location and size of memory allocation, rather than monitoring every bit, as is common in other approaches, we keep memory overhead very low. We demonstrate the applicability of our approach on a number of open-source programs and a few SPEC CPU benchmarks. Our experiments show that the overheads compare favourably with current analysis tools such as Valgrind.


Memory leak Program instrumentation Monitoring 


  1. 1.
    Hastings, R., Joyce, B.: Purify: Fast detection of memory leaks and access errors. In: Proceedings of the Winter USENIX Conference, pp. 125–136 (January 1992)Google Scholar
  2. 2.
    Seward, J., Nethercote, N.: Using valgrind to detect undefined value errors with bit-precision. In: Proceedings of the USENIX Annual Technical Conference, USENIX, pp. 17–30 (2005)Google Scholar
  3. 3.
  4. 4.
  5. 5.
    Nielson, H.R., Nielson, F.: Semantics with applications - a formal introduction. Wiley Professional Computing. Wiley (1992)Google Scholar
  6. 6.
    clang: a C language family frontend for LLVM (March 2012),
  7. 7.
    Lattner, C., Adve, V.: LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation. In: Proceedings of the International Symposium on Code Generation and Optimization, CGO 2004. IEEE Computer Society, Washington, DC (2004)Google Scholar
  8. 8.
    Nethercote, N., Seward, J.: Valgrind: A framework for heavyweight dynamic binary instrumentation. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2007, vol. 42, pp. 89–100. ACM, New York (2007)Google Scholar
  9. 9.
    Bruening, D., Zhao, Q.: Practical memory checking with Dr. Memory. In: Proceedings of the Annual IEEE/ACM International Symposium on Code Generation and Optimization, CGO 2011, pp. 213–223. IEEE Computer Society, Washington, DC (2011)Google Scholar
  10. 10.
    Maebe, J., Ronsse, M., Bosschere, K.D.: Precise detection of memory leaks. In: Proceedings of the International Workshop on Dynamic Analysis, pp. 25–31 (May 2004)Google Scholar
  11. 11.
    Clause, J.A., Orso, A.: LEAKPOINT: Pinpointing the causes of memory leaks. In: Proceedings of the ACM/IEEE International Conference on Software Engineering, ICSE 2010, vol. 1, pp. 515–524. ACM (May 2010)Google Scholar
  12. 12.
    Boehm, H.: Dynamic memory allocation and garbage collection. Computers in Physics 9, 297–303 (1995)Google Scholar

Copyright information

© IFIP International Federation for Information Processing 2013

Authors and Affiliations

  • Kostyantyn Vorobyov
    • 1
  • Padmanabhan Krishnan
    • 2
  • Phil Stocks
    • 1
  1. 1.Centre for Software AssuranceBond UniversityGold CoastAustralia
  2. 2.Oracle LabsBrisbaneAustralia

Personalised recommendations