Wrapper Object Memory Pinning for Garbage Collection

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Pinning managed memory in managed execution environments can hinder memory optimization operations of garbage collectors, leading to heap fragmentation and reduced performance, especially when native code routines perform asynchronous operations.

Innovation Solution

The implementation of a wrapper or proxy object that pins and unpins managed memory buffers on demand, allowing native routines to access memory without interfering with garbage collection, by instantiating a wrapper object that sets and releases memory pins during asynchronous operations.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If managed memory is pinned for the entire life of a native code routine, then the native code routine can safely access memory without relocation, but heap fragmentation increases and garbage collection performance deteriorates

Engineering Contradiction:
Improvememory access safetyVSAvoidgarbage collection performance
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent applies dynamics by transitioning from static pinning (for the entire life of the native routine) to dynamic pinning (only during asynchronous operations). The system dynamically determines when pinning is necessary and adjusts the pinning state accordingly, allowing memory to be unpinned during synchronous operations to enable garbage collection while maintaining safety during asynchronous operations.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent applies preliminary action by pinning memory in advance before asynchronous operations begin and unpinning after they complete. This proactive approach ensures memory safety is established before potential relocation issues could occur, while limiting the duration of pinning to minimize impact on garbage collection performance.

Inventive Principle:
Principle #10Preliminary action

2Reliability

If managed memory is pinned during asynchronous operations, then memory relocation is prevented ensuring safety, but memory optimization operations are hindered

Engineering Contradiction:
Improvememory safety during async operationsVSAvoidmemory management complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent introduces a managed execution environment as an intermediary between the native code routine and the memory system. This intermediary manages the pinning and unpinning of memory, tracking the state of asynchronous operations and automatically adjusting memory pinning accordingly, thereby simplifying the overall memory management complexity while ensuring safety.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Reliability

If memory pinning duration is extended to cover the entire native routine lifecycle, then memory access reliability is improved, but memory usage increases and performance decreases

Engineering Contradiction:
Improvememory access reliabilityVSAvoidmemory usage efficiency
Core Design Contradiction:
ReliabilityVSLoss of energy

Solution Approach 1:

The patent applies periodic action by pinning memory only during specific periods (asynchronous operations) rather than continuously throughout the entire native routine lifecycle. The system periodically transitions between pinned and unpinned states based on the operational phase, reducing overall memory pinning duration and improving memory usage efficiency while maintaining reliability when needed.

Inventive Principle:
Principle #19Periodic action

Data Source

PatentUS8769229B2Memory pinning through buffer encapsulation
Publication Date: 2014.07.01 MICROSOFT TECHNOLOGY LICENSING LLC
  • US8769229B2 patent drawing
  • US8769229B2 patent drawing
  • US8769229B2 patent drawing

AI summary

The present invention extends to methods, systems, and computer program products for memory pinning through buffer encapsulation. Within a managed execution environment, a wrapper object encapsulates a memory buffer that is to be shared with a native routine executing in a native execution environment. The wrapper object manages operation of a memory manager on a memory heap corresponding to the memory buffer. The wrapper object includes a first function which sets a pin on the memory buffer and returns a pointer identifying the memory buffer. Setting the pin causes the memory manager to cease moving the memory buffer within the memory heap. The wrapper object also includes a second function which releases the pin on the memory buffer.