Lazy Patching Manual Memory Management

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Manual memory management often leads to system crashes and security vulnerabilities due to dangling pointers, while garbage collection ensures memory safety but can become a bottleneck with many cores and large data sets.

Innovation Solution

Implementing a method of safe manual memory management that involves eager relocation of objects when fragmentation exceeds a threshold and lazy patching of references, using metadata to update references when they are used, reducing access violations and memory corruption.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If manual memory management is used, then performance is improved, but memory safety deteriorates due to dangling pointers and access violations

Engineering Contradiction:
ImproveperformanceVSAvoidmemory safety
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The patent introduces an intermediary mechanism (lazy patching system with mapping data) that sits between the manual memory management operations and the actual memory accesses. When objects are relocated, the system creates mapping entries that intercept subsequent accesses to the old locations and redirect them to the new locations, thereby maintaining safety without sacrificing performance.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system performs preliminary actions by pre-establishing mapping data before actual memory access violations occur. When an object is relocated, the mapping entry is created in advance, so that subsequent accesses automatically benefit from the redirection without causing access violations or requiring emergency intervention.

Inventive Principle:
Principle #10Preliminary action

2Reliability

If garbage collection is used, then memory safety is improved, but performance deteriorates due to overhead with many cores and large data sets

Engineering Contradiction:
Improvememory safetyVSAvoidperformance
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

Instead of applying a global garbage collection mechanism to the entire heap, the patent applies local quality by implementing selective tracking and lazy patching only for relocated objects. The mapping data structure allows the system to focus safety efforts on specific objects that have been moved, rather than requiring comprehensive garbage collection of all memory.

Inventive Principle:
Principle #3Local quality

Solution Approach 2:

The lazy patching mechanism provides self-service by automatically handling the safety concerns of relocated objects without requiring external garbage collection intervention. The mapping data structure autonomously redirects accesses and manages the safety of relocated objects, eliminating the need for performance-heavy garbage collection cycles.

Inventive Principle:
Principle #25Self-service

3Stability of the object's composition

If eager relocation of objects is performed, then memory fragmentation is reduced, but access violations increase due to invalid references

Engineering Contradiction:
Improvememory fragmentationVSAvoidaccess violations
Core Design Contradiction:
Stability of the object's compositionVSReliability

Solution Approach 1:

The mapping data structure serves as an intermediary that resolves the conflict between eager relocation and access safety. When objects are eagerly relocated to reduce fragmentation, the mapping entries capture the old-to-new location relationships, allowing the system to maintain both fragmentation reduction and access safety simultaneously.

Inventive Principle:
Principle #24Intermediary (Mediator)

4Reliability

If lazy patching of references is implemented, then access violations are reduced, but device complexity increases due to mapping data management

Engineering Contradiction:
Improveaccess violationsVSAvoidmapping data management
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent applies parameter changes by transforming the complex problem of reference validation into a simpler parameter-based lookup problem. The mapping data structure changes the approach from complex runtime validation logic to simple parameter-based address translation, reducing the operational complexity despite the added data structure.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS10496534B2Manual memory management using lazy patching
Publication Date: 2019.12.03 MICROSOFT TECHNOLOGY LICENSING LLC
  • US10496534B2 patent drawing
  • US10496534B2 patent drawing
  • US10496534B2 patent drawing

AI summary

A method of manual memory management is described. In response to detecting an access violation triggered by the use of an invalid reference to an object in a manual heap, a source of the access in a register or stack is identified. An updated reference for the object using stored mapping data is determined and used to replace the invalid reference in the source.