Font Size: a A A

An Intelligent Approach For Detecting Memory Leaks In C Programs

Posted on:2020-03-06Degree:MasterType:Thesis
Country:ChinaCandidate:Y W ZhuFull Text:PDF
GTID:2428330575457997Subject:Computer technology
Abstract/Summary:PDF Full Text Request
Memory leak,as a common bug for C programs,can seriously degrade the perfor-mance and security of the program.The root cause of memory leaks is the artificial neg-ligence of developers when managing memory.At present,the main detection methods of memory leaks are static analysis and dynamic testing.The dynamic testing requires the program to be instrumented or externally monitored and actually executed.Its abil-ity to detect bugs is highly dependent on test cases and requires high running overhead.Static analysis technique is widely used by academia and industry because it does not need to actually execute the program and can quickly detect bugs.However,due to the large program size and complex program structure,the inadequacy of static analysis ability may lead to false negatives.In more cases,the conservative strategy adopted by static analysis often leads to a large number of false positives in the analysis report.The false positives are mainly confirmed by experienced professionals after they have a deep understanding of the warnings and related programs,which is time-consuming and laborious.In the field of software engineering,machine learning technology has made progress in the mining and statistics of empirical knowledge.Therefore,an intelligent approach for detecting memory leaks in C programs is proposed.We use machine learning tech-nology to mine the empirical knowledge in the historical data of static analysis warn-ings,and summarize the memory leak modes and the reasons for false positives in static analysis to classify the memory leak features obtained by the static analysis,so as to optimize the process of memory leak detection and the quality of warning generation.The main work of this paper is as follows:1.A memory leak detection model is built.Based on the analysis of the mechanism of memory leak in C programs,the memory leak features are defined.Based on the historical data of manual confirmation of static analysis warnings,the machine learning technology is used to mine the knowledge and experience in warning con-firmation,and the memory leak modes and the reasons for false positives in static analysis are summarized,thus the memory leak detection model is built,and the model is evaluated and validated.2.An intelligent approach for detecting memory leaks is proposed.The memory leak decision rules based on the memory leak detection model are defined by using mem-ory leak features.Then we extract the memory leak features of the program to be tested by static analysis,and use the memory leak decision rules to directly give the results of the program to be tested or input the memory leak features into the mem-ory leak detection model for classification.On this basis,aiming at the memory leak warnings reported by other static analysis tools,we make a secondary analy-sis of the warning-related programs,and use the intelligent approach for detecting memory leaks to confirm and classify the warnings.3.Based on the above work,a prototype tool for intelligent approach for detecting memory leaks is implemented,and experimental research is carried out.The mem-ory leak detection model is built based on scikit-learn and the prototype tool is implemented on an open source framework.In the experiment,we select 16 C pro-grams in the benchmark programs such as SPEC2000 and Siemens,and carry out experiments with the prototype tool.The experimental results show that the intelli-gent approach for detecting memory leaks can effectively reduce the false positives of static analysis,and the classification of static analysis warnings can also reduce the workload of manual verification.
Keywords/Search Tags:Memory Leak, Static Analysis, Machine Learning, Warning Classification
PDF Full Text Request
Related items