US 9,811,441 B2
Method and system for detecting memory leaks in a program
Radhika Santhanakrishnan, Karnataka (IN); Venu Gopala Krishna Kishore Anumakonda, Andhra Pradesh (IN); Chintan Vinodray Raval, Gujarat (IN); and Tejaswitha Nutikattu, Andhra Pradesh (IN)
Assigned to Infosys Limited, Bangalore (IN)
Appl. No. 14/193
Filed by Radhika Santhanakrishnan, Karnataka (IN); Venu Gopala Krishna Kishore Anumakonda, Andhra Pradesh (IN); Chintan Vinodray Raval, Gujarat (IN); and Tejaswitha Nutikattu, Andhra Pradesh (IN)
PCT Filed Mar. 23, 2011, PCT No. PCT/IN2011/000194
§ 371(c)(1), (2), (4) Date Apr. 24, 2014,
PCT Pub. No. WO2012/127482, PCT Pub. Date Sep. 27, 2012.
Prior Publication US 2014/0298302 A1, Oct. 2, 2014
Int. Cl. G06F 11/36 (2006.01)
CPC G06F 11/3624 (2013.01) [G06F 11/3604 (2013.01); G06F 11/3664 (2013.01)] 33 Claims
OG exemplary drawing
 
1. A method executed by one or more computing devices for statically detecting one or more memory leaks in program code, the method comprising:
receiving, by at least one of the one or more computing devices, the program code, wherein the program code is written in a programming language;
tokenizing, by at least one of the one or more computing devices, the program code to generate tokenized program code by identifying conditional logics in the program code at a function level via a stacking mechanism;
uploading, by at least one of the one or more computing devices, the tokenized program code to a first database;
creating, by at least one of the one or more computing devices, one or more memory leak patterns corresponding to the programming language of the program code via a transaction memory pointer, wherein the one or more memory leak patterns comprises a first sequence of control flow elements, the control flow elements comprising a first combination of memory allocation and memory de-allocation functions known to cause a memory leak;
uploading, by at least one of the one or more computing devices, the one or more memory leak patterns to a second database, wherein the second database can be the first database;
analyzing, by at least one of the one or more computing devices, the tokenized program code stored in the first database to determine one or more control flows in the program code by identifying memory allocation and de-allocation functions for variables in the conditional logics, including all possible combinations of a given variable with other variables available within the applicable conditional logic, and matching control flows of functions and pointer variables in the program code against the one or more memory leak patterns, wherein the one or more determined control flows comprise a second sequence of control flow elements, the control flow elements comprising a second combination of memory allocation and memory de-allocation functions in the program code;
determining, by at least one of the one or more computing devices, whether the one or more determined control flows match any of the one or more memory leak patterns by comparing the second combination in the one or more determined control flows to the first combination in the one or more memory leak patterns; and
identifying, by at least one of the one or more computing devices, one or more potential memory leaks if the second combination matches the first combination.