Empirical Study of Memory Performance and Safety Issues of Golang Programs
Author:
Affiliation:

Clc Number:

TP311

Fund Project:

  • Article
  • |
  • Figures
  • |
  • Metrics
  • |
  • Reference
  • |
  • Related
  • |
  • Cited by
  • |
  • Materials
  • |
  • Comments
    Abstract:

    The Go programming language (Golang), as an emerging programming language, achieves efficient automatic memory management through compile-time escape analysis and runtime garbage collection. It also provides built-in data types such as interface, slice, and map, which significantly enhance development efficiency and program performance. However, these features also introduce memory performance and safety challenges that differ from those in traditional languages like C/C++. This study uses static code analysis to empirically study memory performance and safety problems in Go programs. The framework PatStat, designed based on CodeQL, is employed to analyze open-source repositories on GitHub. This framework uses the declarative language QL to examine code patterns related to memory performance in open-source repositories, facilitating both manual summarization and automatic detection of memory safety problems. The research covers memory access characteristics and patterns of memory safety problems. An analysis of 996 Go open-source projects, updated within the past year, reveals that field accesses and dereference operations account for significant portions of memory access in Go programs, at 25.44% and 17.63%, respectively. This indicates the importance of field sensitivity and points-to analysis in Go program analysis and optimization. Moreover, implicit memory allocation resulting from Go’s unique interface type conversions is another key area for optimization. Through manual analysis of 130 Issues involving memory leaks, invalid memory addresses or null pointer dereferences, and dangling pointers, the study identifies 10 Issue patterns, noting that dangling pointer problems are rare in Go. These Issues typically require around 30 days for resolution but often demand only a few dozen lines of code changes. The findings offer insights for optimizing Go programs and mitigating memory safety concerns. Furthermore, a linter is developed to detect the Issue pattern, which involves the assignment of a slice expression that may lead to memory leaks. This tool identifies 6 Issues in real-world projects, one of which receives positive feedback.

    Reference
    Related
    Cited by
Get Citation

李清伟,丁伯尧,张昱,陈金宝. Go语言程序的内存性能与安全问题实证研究.软件学报,2026,37(3):1197-1224

Copy
Share
Article Metrics
  • Abstract:
  • PDF:
  • HTML:
  • Cited by:
History
  • Received:December 09,2024
  • Revised:February 17,2025
  • Adopted:
  • Online: January 14,2026
  • Published: March 06,2026
You are the firstVisitors
Copyright: Institute of Software, Chinese Academy of Sciences Beijing ICP No. 05046678-4
Address:4# South Fourth Street, Zhong Guan Cun, Beijing 100190,Postal Code:100190
Phone:010-62562563 Fax:010-62562533 Email:jos@iscas.ac.cn
Technical Support:Beijing Qinyun Technology Development Co., Ltd.

Beijing Public Network Security No. 11040202500063