[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
research-article

Towards an understanding of memory leak patterns: an empirical study in Python

Published: 17 June 2023 Publication History

Abstract

Memory leaks, an important and difficult issue in software development, occur when an object is inadvertently retained longer than necessary. Programming languages provide a variety of dynamic memory management methods to support programmers in preventing the introduction of defects that cause memory leaks. However, it is not yet possible to completely free programmers from the work of memory management. Indeed, runtime leak detection is time consuming and usually done after the fact, while manual code inspection requires rich developer experience. Understanding the common patterns of memory leaks can help developers be mindful of leaks or avoid them at an earlier stage during the development process and may further inspire future research. Eight code patterns are found in our case study specifically for memory leaks caused by circular references in Python. The observed patterns can explain 91.64% of the memory leaks in the studied projects. Our work can guide important decisions about the possibility of identifying memory leaks with static code analysis.

References

[1]
Campos, E. C., & Maia, M. D. A. (2017). Common bug-fix patterns: a large-scale observational study. In ACM/IEEE International Symposium on Empirical Software Engineering and Measurement. ACM.
[2]
Cherem, S., Princehouse, L., & Rugina. R. (2007). Practical memory leak detection using guarded value-flow analysis. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pp. 480–491.
[3]
Christopher TW Reference count garbage collection Software: Practice and Experience 1984 14 6 503-507
[4]
Clause, J., & Orso, A. (2010). Leakpoint: Pinpointing the causes of memory leaks. In Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering (vol. 1), ICSE ’10, pp. 515–524.
[5]
Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to algorithms. MIT Press, Cambridge, MA, third edition.
[6]
Distefano, D., & Filipovic, I. (2010). Memory leaks detection in Java by bi-abductive inference. In International Conference on Fundamental Approaches to Software Engineering (FASE), pp. 278–292.
[7]
Fan, G., Wu, R., Shi, Q., et al. (2019). Smoke: Scalable path-sensitive memory leak detection for millions of lines of code. In 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE). IEEE.
[8]
Ghanavati M, Costa D, Seboek J, et al. Memory and resource leak defects and their repairs in Java projects Empirical Software Engineering 2020 25 678-718
[9]
Hanam, Q., Brito, F. S. D. M., & Mesbah, A. (2016). Discovering bug patterns in JavaScript. ACM Sigsoft International Symposium on Foundations of Software Engineering. ACM, 2016, 144–156.
[10]
Hu, M., & Zhang, Y. (2020). The Python/C API: Evolution, usage statistics, and bug patterns. In 2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE.
[11]
Jump, M., & McKinley, K. S. (2007). Cork: Dynamic memory leak detection for garbage-collected languages. In Proceedings of the 34th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 31–38.
[12]
Jung, C., Lee, S., Raman, E., & Pande, S. (2014). Automated memory leak detection for production use. In Proceedings of the 36th International Conference on Software Engineering, ICSE 2014, pp. 825–836.
[13]
Liu, T., Curtsinger, C., & Berger, E. D. (2016). DoubleTake: Fast and precise error detection via evidence-based dynamic analysis. In IEEE/ACM International Conference on Software Engineering. IEEE.
[14]
Lo, D., Nagappan, N., & Zimmermann, T. (2015). How practitioners perceive the relevance of software engineering research. In Joint Meeting on Foundations of Software Engineering. ACM.
[15]
McBeth JH On the reference counter method Communications of ACM 1963 6 9 575-584
[16]
McCarthy J Recursive functions of symbolic expressions and their computation by machine, part I Communications of the ACM 1960 3 4 184-195
[17]
Orlovich, M., & Rugina, R. (2006). Memory leak analysis by contradiction. In Static Analysis Symposium (SAS), pp. 405–424.
[18]
Pan, K., Kim, S., & Whitehead, E. J. (2009) Toward an understanding of bug fix patterns. Empirical Software Engineering, 14(3), 286–315.
[19]
Python Programming Language Homepage. Retrieved June 13, 2023, from https://www.python.org
[21]
Shaham, R., Kolodner, E. K., & Sagiv, M. (2000). Automatic removal of array memory leaks in Java. In International Conference on Compiler Construction (CC), pp. 50–66.
[22]
Sor, V., & Srirama, S. N. (2014). Memory leak detection in Java: Taxonomy and classification of approaches. Journal of Systems and Software, 96, 139–151.
[23]
Sui Y, Ye D, and Xue J Detecting memory leaks statically with full-sparse value-flow analysis IEEE Transactions on Software Engineering 2014 40 2 107-122
[24]
Sun, X., Xu, S., Guo, C., et al. (2018). A projection-based approach for memory leak detection. In IEEE Computer Software & Applications Conference. IEEE.
[25]
Tan L, Liu C, Li Z, et al. Bug characteristics in open source software Empirical Software Engineering 2014 19 6 1665-1705
[26]
Xu, G., & Rountev, A. (2008). Precise memory leak detection for java software using container profiling. In Proceedings of the 30th International Conference on Software Engineering, ICSE ’08, pp. 151–160.
[27]
Xu, G., Bond, M. D., Qin, F., & Rountev, A. (2011). Leakchaser: Helping programmers narrow down causes of memory leaks. In Proceedings of the 32Nd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pp. 270–282.
[28]
Yan, D., Xu, G., Yang, S., et al. (2014). LeakChecker: Practical static memory leak detection for managed languages. In Proceedings of Annual IEEE/ACM International Symposium on Code Generation and Optimization. ACM.
[29]
Zhong, H., & Su, Z. (2015). An empirical study on real bug fixes. In IEEE/ACM IEEE International Conference on Software Engineering. ACM.

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image Software Quality Journal
Software Quality Journal  Volume 31, Issue 4
Dec 2023
548 pages

Publisher

Kluwer Academic Publishers

United States

Publication History

Published: 17 June 2023
Accepted: 18 May 2023

Author Tags

  1. Memory leak
  2. Circular reference
  3. Code pattern

Qualifiers

  • Research-article

Funding Sources

  • National Science Foundation of China
  • Zhejiang Provincial National Science Foundation of China

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 0
    Total Downloads
  • Downloads (Last 12 months)0
  • Downloads (Last 6 weeks)0
Reflects downloads up to 14 Dec 2024

Other Metrics

Citations

View Options

View options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media