Memory-leak identification
AssigneeSap SE
InventorMartin Moser
Life of this patent
Estimating the term…
Abstract
A memory-leak source in a data structure can be identified by counting insertions into the data structure and deletions from the data structure for locations in the execution path of a computer program. These insertion and deletion values can be used to identify at least one location as a memory-leak source that corresponds to an imbalance between insertions and deletions during the execution of the computer program.
Claims19
A method of identifying a memory leak in a data structure, the method comprising:
- accessing a listing of a computer program, the computer program including program elements that create the data structure and operate on the data structure to include one or more objects as components of the data structure;
- identifying at least one object-adding program element that adds at least one object to the data structure and at least one object-removing program element that removes at least one object from the data structure;
- injecting data-structure bookkeeping code into the at least one object-adding program element and the at least one object-removing program element, the data-structure bookkeeping code operating to track a change in a size of the data structure and a corresponding location in an execution path of the computer program;
- executing the computer program with the injected data-structure bookkeeping code to determine a first cumulative change in the size of the data structure at a first location in the execution path of the computer program by summing tracked changes at the first location;
- and
- using the first cumulative change to identify the first location as a source of the memory leak in the data structure, the memory leak corresponding to an increasing allocation of memory beyond a threshold value for leaking memory.
A non-transitory computer-readable medium that stores a memory-leak program to identify a memory leak in a data structure, the memory-leak program including instructions that, when executed by a computer, cause the computer to perform operations comprising:
- accessing a listing of a computer program, the computer program including program elements that create the data structure and operate on the data structure to include one or more objects as components of the data structure;
- identifying at least one object-adding program element that adds at least one object to the data structure and at least one object-removing program element that removes at least one object from the data structure;
- injecting data-structure bookkeeping code into the at least one object-adding program element and the at least one object-removing program element, the data-structure bookkeeping code operating to track a change in a size of the data structure and a corresponding location in an execution path of the computer program;
- executing the computer program with the injected data-structure bookkeeping code to determine a first cumulative change in the size of the data structure at a first location in the execution path of the computer program by summing tracked changes at the first location;
- and
- using the first cumulative change to identify the first location as a source of the memory leak in the data structure, the memory leak corresponding to an increasing allocation of memory beyond a threshold value for leaking memory.
An apparatus configured to identify a memory leak in a data structure, the apparatus comprising a computer to perform operations for:
- a computer-program-listing module that accesses a listing of a computer program, the computer program including program elements that create the data structure and operate on the data structure to include one or more objects as components of the data structure;
- a program-element-identification module that identifies at least one object-adding program element that adds at least one object to the data structure and at least one object-removing program element that removes at least one object from the data structure;
- a code-injection module that injects data-structure bookkeeping code into the at least one object-adding program element and the at least one object-removing program element, the data-structure bookkeeping code operating to track a change in a size of the data structure and a corresponding location in an execution path of the computer program;
- an execution module that executes the computer program with the injected data-structure bookkeeping code to determine a first cumulative change in the size of the data structure at a first location in the execution path of the computer program by summing tracked changes at the first location;
- and
- a memory-leak-identification module that uses the first cumulative change to identify the first location as a source of the memory leak in the data structure, the memory leak corresponding to an increasing allocation of memory beyond a threshold value for leaking memory.
Dependencies are inferred from the claim text.