Skip to main content
Log in

Demand-Driven Memory Leak Detection Based on Flow- and Context-Sensitive Pointer Analysis

  • Regular Paper
  • Published:
Journal of Computer Science and Technology Aims and scope Submit manuscript

Abstract

We present a demand-driven approach to memory leak detection algorithm based on flow- and context-sensitive pointer analysis. The detection algorithm firstly assumes the presence of a memory leak at some program point and then runs a backward analysis to see if this assumption can be disproved. Our algorithm computes the memory abstraction of programs based on points-to graph resulting from flow- and context-sensitive pointer analysis. We have implemented the algorithm in the SUIF2 compiler infrastructure and used the implementation to analyze a set of C benchmark programs. The experimental results show that the approach has better precision with satisfied scalability as expected.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Hastings R, Joyce B. Fast detection of memory leaks and access errors. In Proc. the Winter USENIX Conference, San Francisco, USA, Winter, 1992, pp.125–136.

  2. Bush W R, Pincus J D, Sielaff D J. A static analyzer for finding dynamic programming errors. Software — Practice and Experience, 2000, 30(7): 775–802.

    Article  MATH  Google Scholar 

  3. Xie Y, Aiken A. Saturn: A scalable framework for error detection using Boolean satisfiability. ACM Trans. Program. Lang. Syst., 2007, 29(3): 16.

    Article  Google Scholar 

  4. Evans D. Static detection of dynamic memory errors. In Proc. SIGPLAN Conference on Programming Language Design and Implementation (PLDI’96), Philadelphia, USA, May 21–24, 1996, pp.44–53.

  5. Engler D R, Chen D Y, Chou A. Bugs as inconsistent behavior: A general approach to inferring errors in systems code. In Proc. Symposium on Operating Systems Principles, Chateau Lake Louise, Canada, Oct. 21–24, 2001, pp.57–72.

  6. Hallem S, Chelf B, Xie Y, Engler D. A system and language for building system-specific, static analyses. In Proc. the ACM SIGPLAN 2002 Conference on Programming Language Design and Implementation (PLDI’02), New York, NY, USA, ACM Press, 2002, pp.69–82.

  7. Orlovich M, Rugina R. Memory leak analysis by contradiction. In Proc. SAS, Seoul, Korea, August 29–31, 2006, pp.405–424.

  8. Emami M, Ghiya R, Hendren L J. Context-sensitive interprocedural points-to analysis in the presence of function pointers. In Proc. SIGPLAN Conference on Programming Language Design and Implementation, Orlando, USA, June 20–24, 1994, pp.242–256.

  9. Hind M, Burke M, Carini P, Choi J D. Interprocedural pointer alias analysis. ACM Transactions on Programming Languages and Systems, 1999, 21(4): 848–894.

    Article  Google Scholar 

  10. Rugina R, Rinard M. Pointer analysis for multithreaded programs. In Proc. the ACM SIGPLAN 1999 Conference on Programming Language Design and Implementation (PLDI’99), New York, NY, USA, ACM Press, 1999, pp.77–90.

  11. Xen source. http://www.xensource.com/xen/about.html.

  12. Wilson R P, Lam M S. Efficient context-sensitive pointer analysis for C programs. In Proc. the ACM SIGPLAN 1995 Conference on Programming Language Design and Implementation (PLDI’95), New York, NY, USA, ACM Press, 1995, pp.1–12.

  13. Duesterwald E, Gupta R, Soffa M L. Demand-driven computation of interprocedural data flow. In Proc. the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’95), New York, NY, USA, ACM Press, 1995, pp.37–48.

  14. Horwitz S, Reps T, Sagiv M. Demand interprocedural dataflow analysis. In Proc. the 3rd ACM SIGSOFT Symposium on Foundations of Software Engineering (SIGSOFT’95), New York, NY, USA, ACM Press, 1995, pp.104–115.

  15. Sharir M, Pnueli A. Two Approaches to Interprocedural Data Flow Analysis. Program Flow Analysis: Theory and Applications, Muchnick S, Jones N (eds.), Prentice Hall Inc, 1981.

  16. Ryder B G, Landi W A, Stocks P A, Zhang S, Altucher R. A schema for interprocedural modification side-effect analysis with pointer aliasing. ACM Trans. Program. Lang. Syst., 2001, 23(2): 105–186.

    Article  Google Scholar 

  17. Austin T M. Pointer-intensive benchmark suite, version 1.1. 1995, http://www.cs.wisc.edu/~austin/ptr-dist.html.

  18. Austin T M, Breach S E, Sohi G S. Efficient detection of all pointer and array access errors. SIGPLAN Not., 1994, 29(6): 290–301.

    Article  Google Scholar 

  19. Cherem S, Princehouse L, Rugina R. Practical memory leak detection using guarded value-flow analysis. In Proc. the 2007 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’07), New York, NY, USA, ACM Press, 2007, pp.480–491.

  20. Heine D L, Lam M S. Static detection of leaks in polymorphic containers. In Proc. ICSE, Shanghai, China, May 20–28, 2006, pp.252–261.

  21. Heine D L, Lam M. A practical flow-sensitive and contextsensitive C and C++ memory leak detector. In Proc. the ACM SIGPLAN 2004 Conference on Programming Language Design and Implementation, San Diego, USA, June 9–11, 2003, pp.168–181.

  22. Xie Y, Aiken A. Context- and path-sensitive memory leak detection. In Proc. the 10th European Software Engineering Conference held jointly with 13th ACM SIGSOFT International Symposium on Foundations of Software Engineering (ESEC/FSE-13), New York, NY, USA, ACM Press, 2005, pp.115–125.

  23. Nurit Dor, Michael Rodeh, Shmuel Sagiv. Checking cleanness in linked lists. In Proc. Static Analysis Symposium, Santa Barbara, USA, June 29–July 1, 2000, pp.115–134.

  24. Hackett B, Rugina R. Region-based shape analysis with tracked locations. In Proc. the 32nd ACM SIGPLAN–SIGACT Symposium on Principles of Programming Aanguages (POPL’05), New York, NY, USA, ACM Press, 2005, pp.310–323.

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Ji Wang.

Additional information

This work is supported by the National Natural Science Foundation of China under Grant Nos. 60725206, 60673118, and 90612009, the National High-Tech Research and Development 863 Program of China under Grant No. 2006AA01Z429, the National Basic Research 973 Program of China under Grant No. 2005CB321802, the Program for New Century Excellent Talents in University under Grant No. NCET-04-0996, and the Hunan Natural Science Foundation under Grant No. 07JJ1011.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Wang, J., Ma, XD., Dong, W. et al. Demand-Driven Memory Leak Detection Based on Flow- and Context-Sensitive Pointer Analysis. J. Comput. Sci. Technol. 24, 347–356 (2009). https://doi.org/10.1007/s11390-009-9229-0

Download citation

  • Received:

  • Revised:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11390-009-9229-0

Keywords

Navigation