Memory Tracker for C++ Leak and Overflow Detection

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing systems for managing memory in computer applications, particularly in C and C++ programs, face challenges such as memory leaks, buffer overflows, and release type mismatch errors, which can lead to system crashes and performance issues.

Innovation Solution

A method and system for tracking memory allocation and release activities using a memory tracker that implements standard C and C++ memory functions, employing an indexed data structure like a red-black tree to manage allocated memory blocks, and adding integrity checks and memory allocation types to detect errors.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If conventional memory allocation functions (malloc, new, etc.) are used in C and C++ programs, then memory management flexibility is maintained, but memory safety issues such as leaks, buffer overflows, and release type mismatches occur

Engineering Contradiction:
Improvememory safetyVSAvoidmemory management complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent introduces an intermediary layer between the programmer and the operating system memory allocation functions. This intermediary memory tracker intercepts all memory allocation and release operations, automatically tracking memory blocks and detecting errors such as leaks, buffer overflows, and release type mismatches without requiring changes to the programmer's code logic.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system performs preliminary actions by pre-defining memory allocation types and associating them with specific release methods before memory operations occur. The memory tracker maintains a record of allocated memory blocks with their types, enabling automatic verification and error detection before actual memory release operations are executed.

Inventive Principle:
Principle #10Preliminary action

2Reliability

If memory tracking and error detection mechanisms are implemented, then memory error detection capability is improved, but system performance overhead increases

Engineering Contradiction:
Improveerror detection capabilityVSAvoidsystem performance
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The memory tracker implements selective tracking by focusing only on the essential aspects of memory management - recording allocation types, tracking memory block locations and sizes, and verifying release operations. This partial action approach provides comprehensive error detection capability while avoiding the overhead of complete memory operation logging or analysis.

Inventive Principle:
Principle #16Partial or excessive action

3Reliability

If comprehensive memory tracking is implemented to detect all memory errors, then memory error coverage is improved, but implementation complexity increases

Engineering Contradiction:
Improvememory error coverageVSAvoidimplementation complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent segments memory error detection into three distinct functional components: (1) tracking memory allocation operations and recording allocation types, (2) monitoring memory release operations and verifying type matching, and (3) detecting buffer overflow conditions. This segmentation allows each component to be implemented independently and simplifies the overall system architecture.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system changes the parameter being tracked from detailed memory operation logs to essential memory block metadata (allocation type, size, location). By focusing on these critical parameters rather than complete operation histories, the system achieves comprehensive error coverage with reduced implementation complexity.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS12277329B2Method and system for tracking memory usage
Publication Date: 2025.04.15 LIPINGDATA CORP
  • US12277329B2 patent drawing
  • US12277329B2 patent drawing
  • US12277329B2 patent drawing

AI summary

A method and system track memory allocation and release activities to detect memory leak, buffer overflow, and release type mismatch errors in a computing system. The memory tracker computes the necessary size of the allocated memory block and calls operating system provided functions to allocate and release raw memory blocks. Raw memory blocks are formatted into allocated memory blocks. An indexed data structure stores the allocated memory blocks. The user memory address is used as the index key value. The memory blocks are removed from the indexed data structure when the programs release the memory. The memory blocks remaining in the indexed data structure are considered memory leaks when the memory tracker terminates. The memory tracker adds bytes to the end of memory blocks for the integrity check and detects possible buffer overflow errors. Memory allocation type is added in the allocated memory blocks for release type mismatch errors.