Patent ID: 7577943

Claim:
A method of testing for memory leaks during an execution of a program, the method comprising: providing the program to be executed; providing a duplicate version of at least some procedures in the program with instrumentation for capturing a temporal sequence of data references by the program, the duplicate version of at least some procedures in the program being duplicate instrumented code; inserting check code at locations of at least some dispatch placement points; causing execution to proceed in the program upon executing the check code when in a checking phase; causing execution to proceed in the duplicate instrumented code upon executing the check code when in a profiling phase; switching from the checking phase to the profiling phase at a sampling rate adapted in inverse proportion to an execution frequency of a respective code path; tracking a staleness of an object of the program, the staleness of the object of the program based on at least the temporal sequence of data references, wherein the temporal sequence of data references includes at least one of (a) at least one access to the object of the program during the execution of the check code in the profiling phase or (b) the allocation time of the object of the program; determining a memory leak occurs when a staleness predicate is satisfied, the staleness predicate based on at least the staleness of the object of the program; and running the program.