Memory Leak Detection via Weak Reference Segmentation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Object reference cycles in programming code can lead to memory leaks as objects become unreachable by variables, preventing garbage collection and resulting in memory inefficiency.

Innovation Solution

A method that parses programming code to identify object allocation and reference instructions, generates a memory model, and flags unreachable object reference cycles, recommending the replacement of strong references with weak references to prevent memory leaks.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Extent of automation

If reference counting is used to manage memory, then memory management is automated through garbage collection, but memory leaks occur when objects form unreachable reference cycles

Engineering Contradiction:
Improvememory management automationVSAvoidmemory leakage
Core Design Contradiction:
Extent of automationVSLoss of substance

Solution Approach 1:

The patent segments the reference counting mechanism into two parts: strong reference counting for normal memory management and weak reference tracking for cycle detection. This segmentation allows the system to maintain automated garbage collection while identifying unreachable reference cycles that would otherwise cause memory leaks.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces weak references as an intermediary mechanism between strong references and garbage collection. Weak references serve as mediators that track object relationships without preventing garbage collection, enabling the detection of unreachable reference cycles while maintaining automated memory management.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Stability of the object's composition

If strong references are used to maintain object relationships, then object connectivity is preserved, but unreachable objects in reference cycles cannot be deallocated

Engineering Contradiction:
Improveobject reference stabilityVSAvoidmemory deallocation reliability
Core Design Contradiction:
Stability of the object's compositionVSReliability

Solution Approach 1:

The patent applies different reference qualities to different reference relationships: strong references maintain object connectivity where needed, while weak references are used where connectivity is not essential. This local differentiation allows the system to preserve object relationships where stability is required while enabling deallocation where references become unreachable.

Inventive Principle:
Principle #3Local quality

Solution Approach 2:

The patent changes the reference parameter from always-strong to a mix of strong and weak references. By adjusting the reference strength parameter based on the specific relationship requirements, the system maintains object connectivity where necessary while allowing unreachable objects in cycles to be properly deallocated.

Inventive Principle:
Principle #35Parameter changes

3Productivity

If the programming code is not analyzed for reference cycles, then code execution is efficient, but memory leaks go undetected

Engineering Contradiction:
Improvecode execution efficiencyVSAvoidmemory leak detection
Core Design Contradiction:
ProductivityVSDifficulty of detecting and measuring

Solution Approach 1:

The patent performs preliminary analysis of reference cycles during compilation or code generation, before the program executes. This preliminary action identifies potential memory leak scenarios in advance, allowing the system to maintain efficient runtime execution while having already detected and flagged problematic reference patterns.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS10296314B2Detecting and remedying memory leaks caused by object reference cycles
Publication Date: 2019.05.21 META PLATFORMS INC
  • US10296314B2 patent drawing
  • US10296314B2 patent drawing
  • US10296314B2 patent drawing

AI summary

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.