Wrapper Object Memory Pinning for Garbage Collection
Find Innovative SolutionsGenerate 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
Engineering 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
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.
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.
2Reliability
If managed memory is pinned during asynchronous operations, then memory relocation is prevented ensuring safety, but memory optimization operations are hindered
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.
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
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.
Data Source
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.


