Memory Management Mechanism for Preventing Dangling Pointers

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing programming languages like C++ face challenges in ensuring type-safety during memory management, leading to potential type violations when memory is reused, which can be difficult to diagnose and debug.

Innovation Solution

A memory management mechanism that explicitly deallocates memory regions and scans for pointers to nullify them before reusing the memory, preventing dangling pointer issues and ensuring type-safety through an incremental cleaning process that runs periodically with program execution.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Quantity of substance

If memory is reused after deallocation without cleaning, then memory efficiency is improved, but type-safety deteriorates due to dangling pointers

Engineering Contradiction:
Improvememory efficiencyVSAvoidtype-safety
Core Design Contradiction:
Quantity of substanceVSReliability

Solution Approach 1:

The patent applies preliminary action by scanning for and nullifying pointers to deallocated memory before the memory is reused. This preparatory cleaning process ensures that when memory is reallocated, any lingering pointers have already been set to null, preventing dangling pointer issues while enabling immediate memory reuse.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent extracts the harmful dangling pointers from the memory system by identifying and nullifying them during the cleaning process. This separation removes the problematic pointers from the deallocated memory regions before reuse, preserving memory efficiency while eliminating the type-safety risk.

Inventive Principle:
Principle #2Taking out (Extraction)

2Reliability

If conventional garbage collection is used to ensure type-safety, then type-safety is improved, but system overhead increases

Engineering Contradiction:
Improvetype-safetyVSAvoidsystem overhead
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent implements self-service by having the program itself perform the cleaning operation through explicit calls to the memory management mechanism. Rather than relying on a separate garbage collection system, the program manually scans and nullifies pointers to deallocated memory, reducing system overhead while maintaining type-safety.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The patent discards the complex garbage collection approach and recovers memory through a simpler explicit deallocation and cleaning process. The memory management mechanism provides a lightweight interface that allows programs to manually manage memory cleanup, reducing the burden on the system while ensuring type-safety.

Inventive Principle:
Principle #34Discarding and recovering

3Productivity

If memory is not cleaned before reuse, then productivity is maintained, but harmful factors increase due to undetected programming errors

Engineering Contradiction:
Improveexecution efficiencyVSAvoidprogramming errors
Core Design Contradiction:
ProductivityVSObject-affected harmful factors

Solution Approach 1:

The patent introduces feedback by providing a mechanism that detects and reports dangling pointers before they cause errors. The cleaning process scans for and identifies pointers to deallocated memory, allowing programmers to detect and fix issues before they manifest as runtime errors, thus maintaining productivity while reducing harmful factors.

Inventive Principle:
Principle #23Feedback

Solution Approach 2:

The patent applies beforehand cushioning by nullifying pointers in advance before they can cause programming errors. This preventive measure creates a buffer against potential errors by ensuring that any attempt to access deallocated memory through lingering pointers will result in null pointer exceptions rather than undefined behavior.

Inventive Principle:
Principle #11Beforehand cushioning (Prior cushioning)

Data Source

PatentUS8255887B2Method and apparatus for re-using memory allocated for data structures used by software processes
Publication Date: 2012.08.28 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US8255887B2 patent drawing
  • US8255887B2 patent drawing
  • US8255887B2 patent drawing

AI summary

A memory management mechanism requires data structures to be explicitly deallocated in the programming code, but deallocation does not immediately make the memory available for reuse. Before a deallocated memory region can be reused, memory is scanned for pointers to the deallocated region, and any such pointer is set to null. The deallocated memory is then available for reuse. Preferably, deallocated memory regions are accumulated, and an asynchronous memory cleaning process periodically scans memory to nullify the pointers. In order to prevent previously scanned memory becoming contaminated with a dangling pointer before the scan is finished, any write to a pointer is checked to verify that the applicable target address has not been deallocated.