Article Details

Title · Authors · Abstract · Keywords · DOI · References

Methods for Tracking Heap Memory in C Language

WANG Weihong1, CHEN Shuai2

(1.Tianjin College, University of Science and Technology Beijing, Tianjin 301830, China; 2.Dawning Information Industry Co., Ltd., Tianjin 300384, China)

Received: 2025-03-01

Section:Computer Technology · 2025, Vol. 9, No. 14 · Pages:108-112 · 2096-4706(2025)14-0108-05 · CLC number:TP312 · Document code:A · DOI:10.19850/j.cnki.2096-4706.2025.14.020 · Updated:2026-12-03

Abstract

In order to track and monitor the process of heap memory application and deallocation in C Language programs and quickly resolve memory leak issues, this paper studies the usage and dynamic changes of heap memory. Through research and experiments on memory management, memory leaks, memory tracking and other issues, the paper modifies the implementation of malloc and free interfaces in C Language standard library by using the method of rewriting function interfaces based on the WARP feature of the GNU linker, thus completing the function of recording heap memory usage. By using the red-black tree data structure to record key node information of heap memory, a heap memory tracking method in C Language is proposed, and the software method of rewriting malloc and free interfaces is realized. While realizing heap memory tracking, this method improves the efficiency of adding, deleting and searching nodes, and can effectively reduce the impact on the running time and efficiency of business processes during heap memory tracking and monitoring.

Keywords

C Language; memory tracking; memory leak; compiler WARP feature

References

  1. [1] Chen Nan. Dynamic Memory Real time Monitor Based on C++[J]. Computer System Applications, 2016, 25 (12): 262-267
  2. [2] Chen Junjie. Research and Implementation of Dynamic Detection of Memory Leakage Based on Test Cases [D]. Nanchang: Nanchang University, 2022
  3. [3] He Kai. Checking and solving memory leaks in embedded Linux [J]. Modern Computer, 2020 (11): 78-82
  4. [4] Zhao Changyu, Wang Xilong. Research on Embedded Software Memory Management Methods [J]. Science and Innovation, 2024 (16): 129-131
  5. [5] Analysis and Detection Method Design of Memory Leakage Mechanisms in Zhang Jing, Huang Zhiqiu, Shen Guohua, et al. C Programs [J]. Computer Engineering and Science, 2020, 42 (5): 776-787
  6. [6] Cai Zhiqiang, Ding Liping, He Yeping. A Virtual Machine based Dynamic Memory Leakage Detection Method [J]. Computer Applications and Software, 2012, 29 (9): 10-13+153
  7. [7] Zhao Changyu, Wang Xilong. Research on Embedded Software Memory Management Methods [J]. Science and Innovation, 2024 (16): 129-131
  8. [8] Chen Chaohui, Duan Xiong. Design and Implementation of Efficient Memory Allocation Algorithm Based on TLSF Algorithm [J]. Computer Engineering and Science, 2024, 46 (11): 1916-1923
  9. [9] Zhao Xinghua. Implementing Memory Management Optimization with New Linux Kernel Features [J]. Network Security and Informatization, 2024 (7): 163-165
  10. [10] Ma Yingzi, Chen Zhe, Yin Jiale, et al. Memory Security Vulnerability Detection Combining Fuzzy Testing and Dynamic Analysis [J]. Computer Science, 2024, 51 (2): 352-358
  11. [11] Yin Jiale, Chen Zhe. Fuzzy testing method for memory security vulnerabilities combined with dynamic analysis [J/OL]. Computer Science, 2024:1-11 [2022-02-04] http://kns.cnki.net/kcms/detail/50.1075.TP.20241227.1407.004.html.
  12. [12] Ma Botao, Sun Peng, Zhu Xiaoyong. A Review of Red Black Tree Algorithm Research [J]. Network New Media Technology, 2018, 7 (4): 56-62

About the authors

Wang Weihong (1997-), female, Han ethnicity, from Puyang, Henan Province, teaching assistant, master's degree, research direction: memory usage in C language; Chen Shuai (1994-), male, Han ethnicity, from Shangqiu, Henan, is a software development engineer with a bachelor's degree. His research direction is Linux driver development.