Font Size: a A A

Research And Implementation Of Dynamic Memory Leak Detection Based On Test Cases

Posted on:2023-03-18Degree:MasterType:Thesis
Country:ChinaCandidate:J J ChenFull Text:PDF
GTID:2568306800466554Subject:Software engineering
Abstract/Summary:PDF Full Text Request
C/C++ language is an inevitable choice for aerospace,military,and embedded systems due to its flexibility,high execution efficiency,and small memory footprint.Programs developed in C/C++ cause irreparable losses due to memory leaks.It is very necessary and practical to detect memory leaks.At present,memory leak detection technology is mainly divided into dynamic detection and static detection.Some existing detection tools use static detection methods,which have the disadvantages of long static analysis time and low accuracy,especially for large-scale software;Some detection tools use dynamic detection technology,which has the disadvantage that it can only detect whether a memory leak occurs in a single branch path.This paper designs a dynamic memory leak detection tool based on test cases for source code through the research on memory leak related knowledge and detection technology.In order to solve the problem that dynamic detection can only detect whether there is a memory leak in one branch path,dynamic symbolic execution technology is used to generate test cases,and for generating test cases,it is proposed to analyze the loop conditions while searching for paths to determine whether there is a memory operation-related problem.The optimization of the statement,compared with the traditional test case generation tool,can reduce many unnecessary test case generation,and can greatly reduce the time spent in generating test cases.The dynamic detection of memory leaks in the instrumentation program through these test cases can avoid the shortcoming of a single path in the traditional dynamic detection,and analyze the memory-related information through the dynamic execution of each path,which also preserves the advantages of fast execution of dynamic detection.In the process of dynamic detection,when encountering memory allocation and release operations,information such as memory address,memory size,and line number can be recorded in time,and this information can be used to determine whether a memory leak occurs in the path and the specific location information of the memory leak.Finally,through functional testing of the memory leak detection tool,in the dynamic detection experiment of a single branch path,it is found that the tool can indeed detect all memory leaks under the branch path.The main technical difficulty in implementing this tool is to choose a suitable instrumentation function.Experiments show that,compared with some existing tools,the dynamic memory leak detection tool based on test cases in this paper can indeed improve the efficiency of code detection.It reduces the time for generating test cases and improves the accuracy of detection.
Keywords/Search Tags:dynamic detection, memory leak, dynamic instrumentation, symbolic execution
PDF Full Text Request
Related items