IP Library Granted Patent US 10,296,314
Granted Patent B2
US 10,296,314 · App. 15/340,752 · Granted May 21, 2019

Detecting and remedying memory leaks caused by object reference cycles

View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 10,296,314
App. No.
15/340,752
Granted
May 21, 2019
Kind
B2
Abstract

Exemplary methods, apparatuses, and systems parse programming code to identify instructions within the programming code to allocate objects and instructions within the programming code to create, delete, and/or update references to the objects. Based upon the identified instructions, a model of memory used when the programming code is executed is generated. The model includes representations of the objects and representations of changes to the references to the objects. Based upon the representations in the model, it is determined that each of a plurality of the objects is connected to another of the plurality of objects by one of the references but unreachable by any variable at a point of execution of the programming code. In response to the determination that the plurality of objects is unreachable, a report is generated to flag the unreachable plurality of objects as a potential memory leak for correction.

Claims (43)

1. A computer-implemented method comprising:

parsing programming code to identify instructions within the programming code to allocate objects and instructions within the programming code to create, delete, and/or update references to the objects;

generating, based upon the identified instructions, a model of memory used when the programming code is executed, wherein the model includes representations of the objects and representations of changes to the references to the objects;

detecting, based upon the representations in the model, a potential memory leak by identifying that each of a plurality of the objects is referenced by another of the plurality of the objects but unreachable by any variable at a point of execution of the programming code; and

generating, in response to the detection of the potential memory leak, a report to flag the potential memory leak, wherein generating the report includes highlighting, in a graphical user interface, a portion of the programming code causing the potential memory leak.

2. The computer-implemented method of claim 1 , wherein:

the plurality of the objects within the model includes a first object and a second object;

the references include a first reference from the first object to the second object and a second reference from the second object to the first object; and

the detection of the potential memory leak by identifying that the plurality of the objects is unreachable includes determining, at the point of execution of the programming code, that the first reference is an only incoming reference for the second object and that the second reference is the only incoming reference for the first object.

3. The computer-implemented method of claim 2 , wherein a removal or modification of a third reference to the first or second object at a previous point of execution of the programming code caused the plurality of the objects to become unreachable.

4. The computer-implemented method of claim 1 , wherein generating the report includes modifying the programming code to include a comment flagging the unreachable plurality of the objects.

5. The computer-implemented method of claim 1 , wherein generating the report includes a recommendation to replace a strong reference with a weak reference.

6. The computer-implemented method of claim 1 , wherein the model of memory is generated using separation logic.

7. The computer-implemented method of claim 1 , wherein the parsing, generating the model, determining the plurality of the objects is unreachable, and generating the report are performed as a part of compilation of the programming code.

8. A non-transitory computer-readable medium storing instructions, which when executed by a processing device, cause the processing device to perform a method comprising:

parsing programming code to identify instructions within the programming code to allocate objects and instructions within the programming code to create, delete, and/or update references to the objects;

generating, based upon the identified instructions, a model of memory used when the programming code is executed, wherein the model includes representations of the objects and representations of changes to the references to the objects;

detecting, based upon the representations in the model, a potential memory leak by identifying that each of a plurality of the objects is referenced by another of the plurality of the objects but unreachable by any variable at a point of execution of the programming code; and

generating, in response to the detection of the potential memory leak, a report to flag the potential memory leak, wherein generating the report includes highlighting, in a graphical user interface, a portion of the programming code causing the potential memory leak.

9. The non-transitory computer-readable medium of claim 8 , wherein:

the plurality of the objects within the model includes a first object and a second object;

the references include a first reference from the first object to the second object and a second reference from the second object to the first object; and

the detection of the potential memory leak by identifying that the plurality of the objects is unreachable includes determining, at the point of execution of the programming code, that the first reference is an only incoming reference for the second object and that the second reference is the only incoming reference for the first object.

10. The non-transitory computer-readable medium of claim 9 , wherein a removal or modification of a third reference to the first or second object at a previous point of execution of the programming code caused the plurality of the objects to become unreachable.

11. The non-transitory computer-readable medium of claim 8 , wherein generating the report includes modifying the programming code to include a comment flagging the unreachable plurality of the objects.

12. The non-transitory computer-readable medium of claim 8 , wherein generating the report includes a recommendation to replace a strong reference with a weak reference.

13. The non-transitory computer-readable medium of claim 8 , wherein the model of memory is generated using separation logic.

14. The non-transitory computer-readable medium of claim 8 , wherein the parsing, generating the model, determining the plurality of the objects is unreachable, and generating the report are performed as a part of compilation of the programming code.

15. An apparatus comprising:

a processing device; and

a memory coupled to the processing device, the memory storing instructions which, when executed by the processing device, cause the apparatus to:

parse programming code to identify instructions within the programming code to allocate objects and instructions within the programming code to create, delete, and/or update references to the objects;

generate, based upon the identified instructions, a model of memory used when the programming code is executed, wherein the model includes representations of the objects and representations of changes to the references to the objects;

detect, based upon the representations in the model, a potential memory leak by identifying that each of a plurality of the objects is referenced by another of the plurality of the objects but unreachable by any variable at a point of execution of the programming code; and

generate, in response to a detection of the potential memory leak, a report to flag the potential memory leak, wherein generating the report includes highlighting, in a graphical user interface, a portion of the programming code causing the potential memory leak.

16. The apparatus of claim 15 , wherein:

the plurality of the objects within the model includes a first object and a second object;

the references include a first reference from the first object to the second object and a second reference from the second object to the first object; and

the detection of the potential memory leak by identifying that the plurality of the objects is unreachable includes determining, at the point of execution of the programming code, that the first reference is an only incoming reference for the second object and that the second reference is the only incoming reference for the first object.

17. The apparatus of claim 16 , wherein a removal or modification of a third reference to the first or second object at a previous point of execution of the programming code caused the plurality of the objects to become unreachable.

18. The apparatus of claim 15 , wherein generating the report includes modifying the programming code to include a comment flagging the unreachable plurality of the objects.

19. The apparatus of claim 15 , wherein generating the report includes a recommendation to replace a strong reference with a weak reference.

20. The apparatus of claim 15 , wherein the model of memory is generated using separation logic.

Assignments (2)
CHANGE OF NAME Recorded Jan 27, 2022
From: FACEBOOK, INC.
To: META PLATFORMS, INC.
Reel/Frame 058871/0336 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 3, 2017
From: DISTEFANO, DINO SALVO; CALCAGNO, CRISTIANO; CHURCHILL, DULMA
To: FACEBOOK, INC.
Reel/Frame 040832/0976 →