Garbage Collection Marking Phase Weak Pointer Handling

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In memory management systems employing garbage collection, the presence of weak pointers complicates the termination of the marking phase during garbage collection, as they can render objects reachable that were not initially marked, leading to incomplete marking and potential memory leaks.

Innovation Solution

A method is introduced where a garbage collection thread manages a heap of memory by indicating the marking phase and performing a handshake operation with mutator threads to ensure accurate marking, using conversion status variables and thread counts to synchronize the marking phase completion, and replacing weak pointers pointing to unreachable objects with null values during the sweep phase.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If weak pointers are allowed to point to objects during the marking phase, then objects can remain reachable and avoid premature collection, but the marking phase may terminate incorrectly leading to incomplete marking and potential memory leaks

Engineering Contradiction:
Improvecorrectness of garbage collectionVSAvoidcomplexity of marking phase termination
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The system performs preliminary actions by having mutator threads add pointers to a set during the marking phase before termination is determined. This ensures that all reachable objects are identified before the marking phase ends, preventing both premature collection and incomplete marking. The set accumulates pointers incrementally, and termination only occurs when the set is confirmed empty, guaranteeing correctness.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system uses feedback mechanisms where the garbage collection thread continuously monitors the set of pointers added by mutator threads. The marking phase termination is conditioned on feedback from the set being empty, creating a closed-loop control system that ensures all reachable objects are marked before collection begins. This feedback-driven approach resolves the contradiction by making termination correctness dependent on actual marking completeness.

Inventive Principle:
Principle #23Feedback

2Reliability

If the garbage collection thread waits for mutator threads to finish adding pointers, then marking completeness is ensured, but the garbage collection process experiences increased pause times

Engineering Contradiction:
Improvecompleteness of markingVSAvoidpause time during garbage collection
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The system maintains continuity of useful action by allowing mutator threads to continue executing and adding pointers to the set throughout the marking phase, rather than pausing them. The garbage collection thread operates concurrently, processing the set as pointers are added. This continuous operation reduces pause times while ensuring marking completeness through the termination condition that waits for the set to be empty.

Inventive Principle:
Principle #20Continuity of useful action

Solution Approach 2:

The system performs preliminary accumulation of pointers in the set during the marking phase, allowing mutator threads to prepare the complete set of reachable objects incrementally. This preliminary action enables the garbage collection thread to process marking information continuously without requiring mutator threads to stop, thereby reducing pause times while maintaining marking completeness.

Inventive Principle:
Principle #10Preliminary action

3Reliability

If weak pointers are replaced with null values during the sweep phase, then memory leaks are prevented, but additional processing overhead is introduced

Engineering Contradiction:
Improveprevention of memory leaksVSAvoidprocessing overhead during sweep phase
Core Design Contradiction:
ReliabilityVSUse of energy by moving object

Solution Approach 1:

The system extracts and removes weak pointers from the heap during the sweep phase by replacing them with null values. This extraction process eliminates the potential for memory leaks by ensuring that objects previously reachable only through weak pointers are properly collected. The selective removal of only weak pointers (not strong pointers) minimizes unnecessary processing overhead while achieving the reliability goal of preventing memory leaks.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The system discards weak pointers that point to unreachable objects during the sweep phase and recovers the memory they referenced for future allocation. By identifying and discarding only the necessary weak pointers (those pointing to collected objects), the system prevents memory leaks while minimizing processing overhead through targeted rather than exhaustive processing.

Inventive Principle:
Principle #34Discarding and recovering

Data Source

PatentEP3462324B1Pointers in a memory managed system
Publication Date: 2021.02.17 HEWLETT PACKARD ENTERPRISE DEV LP
  • EP3462324B1 patent drawingFigure 1
  • EP3462324B1 patent drawingFigure 2
  • EP3462324B1 patent drawingFigure 3

AI summary

Examples disclosed herein relate to pointers in a memory managed system. A garbage collection thread in a garbage collection system indicates via a first indication, that the garbage collection system has entered a marking phase, the garbage collection system managing a heap of memory. The garbage collection thread attempts to modify a conversion status variable, associated with a mutator thread belonging to a set of mutator threads associated with the garbage collection system, from a first conversion status value, indicating that the mutator thread is performing a weak pointer conversion operation, to a second conversion status value indicating that a handshake is required between the garbage collection thread and the mutator thread. The garbage collection thread determines that the conversion status variable does not contain the second conversion status value. The garbage collection thread determines that a set of pointers is empty. The garbage collection thread attempts to indicate, via a third indication, that the marking phase has ended, wherein indicating using the third indication comprises determining that no mutator thread belonging to the set of mutator threads has provided a second indication indicating that the indicating mutator thread intends to add a pointer to the set of pointers. The garbage collection thread determines that the marking phase has ended when the attempt is successful. The garbage collection thread indicates, via a fourth indication, that the garbage collection system is still in the marking phase when the attempt is successful.