Automatic removal of array memory leaks
AssigneeInternational Business Machines Corporation
InventorsElliot Karl Kolodner, Ran Shaham, Mooly Sagiv
Life of this patent
Estimating the term…
Abstract
A method for memory management in execution of a program by a computer having a memory includes identifying in the program an array of array elements. At a given point in the program, a range of the elements is determined within the array such that none of the elements in the array outside the range is alive at the point. Information regarding the determined range is passed to a memory management function, so that memory locations are associated with the array elements, responsive to the determined range.
Claims58
A method for memory management in execution of a program by a computer having a memory, comprising:
- identifying in the program an array of array elements;
- determining at a given point in the program a range of the elements within the array such that none of the elements in the array outside the range is alive at the point;
- and
- passing information regarding the determined range to a memory management function, so that memory locations are associated with the array elements responsive to the determined range.
A method for program execution, comprising:
- receiving code corresponding to a program module, which includes a data field containing information that identifies a range within an array of elements used in the program module such that at a specified point in execution of the program module, none of the elements in the array outside the range is alive;
- running the code so as to assign memory locations to the elements in the array;
- and
- reclaiming during run time of the code the memory locations assigned to at least some of the elements in the array that are outside the range, whereby the reclaimed locations may be assigned to other elements and a memory leak is prevented in the execution of the program.
A method for software verification, comprising:
- creating an array of vectors, each vector comprising an array of vector elements;
- adding a new vector to the array;
- adding a new vector element to the new vector, such that a memory location is assigned to the element;
- removing the element without explicitly assigning the element to null;
- repeating the steps of adding a new vector, adding a new vector element to the new vector, and removing the element a given number of times, whereby a memory error that occurs due to repeating the steps is detected.
Programming apparatus, comprising:
- a memory, which stores program code including an array of elements;
- and
- a processor, coupled to read from and write to the memory, which finds at a given point in the program a range of the elements within the array such that none of the elements in the array outside the range is alive at the point, responsive to which range the processor manages the assignment of memory locations to the elements in the array during execution of the program code.
Apparatus for program execution, comprising:
- a memory, which stores code corresponding to a program module, which includes a data field containing information that identifies a range within an array of elements used in the program module, such that at a specified point in execution of the program module, none of the elements in the array outside the range is alive;
- and
- a processor, which runs the code while assigning locations in the memory to the elements in the array, such that during run time, the memory locations assigned to at least some of the elements in the array that are outside the range are reclaimed, whereby the reclaimed locations may be assigned to other elements so that a memory leak is prevented in the execution of the program.
Apparatus for software verification, comprising:
- a memory, having a given size;
- and
- a processor, coupled to read from and write to the memory, which creates an array of vectors, each vector comprising vector elements, and successively adds new vectors to the array and adds and then removes new elements to the new vectors a given number of times without explicitly assigning the removed elements to null, thereby to determine whether a memory error occurs due to an array memory leak.
A computer software product for detection of memory leaks in computer code defining a computer program, the product comprising a computer-readable medium in which are embedded computer-readable instructions in an executable file, which when read by a computer, cause the computer to identify in the program an array of elements and to find at a given point in the program a range of the elements within the array such that none of the elements in the array outside the range is alive at the point, and to pass information regarding the determined range to a memory management function, so that memory locations are associated with the array elements responsive to the determined range.
A computer software product for use in execution of computer code defining a program module, which module includes a data field containing information that identifies a range within an array of elements used in the program module such that at a specified point in the execution of the program module, none of the elements in the array outside the range is alive, the product comprising a computer-readable medium in which are embedded computer-readable instructions in an executable file, which when read by a computer, cause the computer to reclaim during the execution of the code memory locations assigned to at least some of the elements in the array that are outside the range, whereby the reclaimed locations may be assigned to other elements and a memory leak is prevented in the execution of the program.
A computer software product, comprising a Java language class embedded in a computer-readable medium, the class containing computer-readable data, including a data structure in which information specific to the class is stored, the data in the structure including a data field containing information that identifies a range within an array of elements used in the class, such that at a specified point in execution of the class, none of the elements in the array outside the range is alive, and such that when a computer on which a Java Virtual Machine is running reads the data in the class, the information in the data field causes the computer to reclaim memory locations assigned to at least some of the elements in the array that are outside the range, whereby the reclaimed locations may be assigned to other elements and a memory leak is prevented in execution of the program.
Dependencies are inferred from the claim text.