IP Library Granted Patent US 9,785,549
Granted Patent B2
US 9,785,549 · App. 11/741,549 · Granted Oct 10, 2017

Managing object lifetime for native/managed peers

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 9,785,549
App. No.
11/741,549
Granted
Oct 10, 2017
Kind
B2
Abstract

A system that manages lifetime of an object is provided. The system analyzes references on multiple objects to determine reachability of a native peer and dynamically transitions between native and managed object lifetime management systems based on the analysis. When a native peer is not reachable by a native application reference, the system weakens references to a managed peer avoiding memory leaks and clones the native references to the managed side to avoid premature collection. The system performs an optimized cleanup during object system shutdown wherein the references between managed and native peers are released and SafeHandles are suppressed from finalization. The system employs a pending remove list that stores a reference to a weak reference of a managed peer to eliminate race conditions that occur during finalization.

Claims (43)

1. A computer-implemented object lifetime management system, comprising:

a processor; and

a computer-readable storage device storing instructions that, when executed by the processor, cause the processor to implement a reference counting component, an analysis component, and a garbage collection component;

the reference counting component configured to determine a reference count for one or more objects;

the analysis component configured to dynamically transition the one or more objects between a native object lifetime management system, which utilizes a reference counting component to determine a lifetime of one or more native object peers and a managed object lifetime management system, which utilizes a garbage collection component to control a lifetime of one or more managed object peers, the analysis component further configured to at least one of

modify a strength of a reference by weakening or strengthening the reference from a native object peer to a managed object peer based on the analysis of the references on the one or more objects, or

duplicate at least one reference between multiple native object peers on the native object lifetime management system to the managed object lifetime management system; and

the garbage collection component configured to reclaim resources utilized by the managed object peers based on information provided by the reference counting component and by the analysis component.

2. The computer-implemented system of claim 1 , wherein the analysis component is configured to analyze external references to the native object peer.

3. The computer-implemented system of claim 2 , wherein the analysis component is configured to weaken the reference from the native object peer to the managed object peer when external references to the native object peer do not exist, wherein at least one of the external references is at least one of a direct reference or an indirect reference.

4. The computer-implemented system of claim 2 , wherein the analysis component is configured to strengthen the reference from the native object peer to the managed object peer when at least one of a direct reference or an indirect reference is made to the native object peer, wherein the direct reference and the indirect reference are external references.

5. The computer-implemented system of claim 1 , further comprising an optimization component configured to release references between managed object peers and native object peers during shutdown of an object system.

6. The computer-implemented system of claim 1 , further comprising an optimization component configured to suppress at least one managed object peer that holds the reference to the native object peer from finalization during shutdown of an object system.

7. A computer-readable storage device storing computer-executable instructions that, when executed by a processor, cause the processor to:

analyze references on one or more objects;

automatically transition the one or more objects between a native object lifetime management system, which utilizes a reference counting mechanism to determine a lifetime of one or more native object peers, and a managed object lifetime management system, which utilizes a garbage collection mechanism to control a lifetime of one or more managed object peers, based on the analysis of the references on the one or more objects;

perform at least one of modify a strength of a reference by weakening or strengthening the reference from a native object peer to a managed object peer based on the analysis of the references on the one or more objects or duplicate at least one reference between multiple native object peers on the native object lifetime management system to the managed object lifetime management system; and

employ at least one of the native object lifetime management system or the managed object lifetime management system to destroy an unused object.

8. The computer-readable storage device of claim 7 , further storing computer-executable instructions that, when executed by a processor, cause the processor to:

determine at least one of a direct reference, or an indirect reference, on the one or more objects, wherein the direct reference and the indirect reference are external references.

9. The computer-readable storage device of claim 8 , further storing computer-executable instructions that, when executed by a processor, cause the processor to:

perform the duplicating at least one reference based on the analysis of the references on the one or more objects.

10. The computer-readable storage device of claim 8 , further storing computer-executable instructions that, when executed by a processor, cause the processor to:

weaken the reference when external references to the native object peer do not exist.

11. The computer-readable storage device of claim 9 , wherein the analysis is an analysis of the external references to a native object.

12. The computer-readable storage device of claim 7 , further storing computer-executable instructions that, when executed by a processor, cause the processor to:

release references between the managed object peer and the native object, of the one or more objects, during object system shutdown.

13. The computer-readable storage device of claim 7 , further storing computer-executable instructions that, when executed by a processor, cause the processor to:

suppress, from finalization during object system shutdown, the managed object peer that holds the reference to the native object.

14. A computer-implemented method to dynamically transition between a native object lifetime management system and a managed object lifetime management system, wherein the dynamic transitioning reduces a likelihood of at least one of memory leaks or premature destruction of a managed object peer, the computer-implemented method comprising:

executing on a processor, computer-executable instructions that, when executed, cause the processor to perform:

analyzing references on one or more native object peers;

dynamically transitioning the one or more native object peers between a native object lifetime management system, which utilizes a reference counting mechanism to determine a lifetime of one or more native object peers, and a managed object lifetime management system, which utilizes a garbage collection mechanism to control a lifetime of one or more managed object peers, based on the analysis;

performing at least one of modifying a strength of a reference by weakening or strengthening the reference from a native object peer to a managed object peer based on said analyzing or duplicating at least one reference between multiple native object peers on the native object lifetime management system to the managed object lifetime management system; and

employing at least one of the native object lifetime management system or the managed object lifetime management system to reclaim resources utilized by an unused object.

15. The computer-implemented method of claim 14 , wherein said

strengthening comprises strengthening the reference from the native object peer to the managed object peer when at least one of a direct reference or an indirect reference is made to the native object peer, wherein the direct reference and the indirect reference are external references; and wherein said

weakening comprises weakening a reference from the native object peer to the managed object peer when external references to the native object peer do not exist.

16. The computer-implemented method of claim 14 , wherein said duplicating is based on the analysis.

17. The computer-implemented method of claim 14 , further comprising optimizing object system shutdown by releasing references between managed object peers and the one or more native object peers.

18. A computer-readable storage device having stored thereon computer-executable instructions that, when executed, cause a processor to perform the computer-implemented method of claim 14 .

19. The system of claim 1 , further comprising a storage component configured to store a pending list that includes a reference to a weak reference on a managed object peer to avoid a race condition during finalization.

20. The system of claim 19 , wherein the race condition occurs when the managed object peer is recreated at the same time as the managed object peer is finalized.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 9, 2014
From: MICROSOFT CORPORATION
To: MICROSOFT TECHNOLOGY LICENSING, LLC
Reel/Frame 034542/0001 →