Automated Memory Leak Detection via Code Instrumentation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing methods for detecting memory leaks in executable code, especially in large industrial or commercial software, are inefficient and require manual debugging, which is impractical due to the complexity and size of such codes, necessitating an automated system for identifying and correcting memory leaks.

Innovation Solution

A computer-implemented method that repeatedly executes portions of executable code with dynamic memory allocation and deallocation requests, generating records for each allocation and deallocation, and identifies memory leaks by counting records with identical code identifications and memory sizes, mapping these to the corresponding source code fragments for correction.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If manual debugging is used to detect memory leaks in large industrial or commercial software, then developers can identify and correct memory leaks, but the process becomes impractical due to the complexity and size of the code

Engineering Contradiction:
Improvememory leak detection accuracyVSAvoidcode complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The system automatically detects memory leaks without requiring manual debugging intervention. The executable code instruments itself to monitor memory allocation and deallocation, generating records that are automatically analyzed to identify leaks, thus making the debugging process self-service and eliminating the need for manual code inspection

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

An intermediary detection system is introduced between the executable code and the developer. This system includes a detection module that intercepts memory allocation and deallocation operations, records them with unique identifiers, and automatically analyzes the records to identify memory leaks, serving as a mediator that translates complex code behavior into actionable leak information

Inventive Principle:
Principle #24Intermediary (Mediator)

2Measurement precision

If repetitive execution of code portions is performed to detect memory leaks, then automated detection accuracy improves, but the execution time increases

Engineering Contradiction:
Improvememory leak detection accuracyVSAvoidexecution time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The system performs preliminary actions by instrumenting the code during compilation or loading to insert detection code that automatically tracks memory operations. This preliminary setup enables subsequent repetitive executions to efficiently detect leaks without requiring complex analysis during each run, as the detection infrastructure is already in place

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system creates copies of the executable code with detection instrumentation embedded. These instrumented copies can be executed repeatedly for testing purposes while the original production code remains unchanged. The copies generate detailed records of memory operations that can be analyzed without affecting production performance

Inventive Principle:
Principle #26Copying

3Measurement precision

If detailed records are generated for each memory allocation and deallocation, then memory leak identification precision improves, but the data processing volume increases

Engineering Contradiction:
Improvememory leak identification precisionVSAvoiddata processing volume
Core Design Contradiction:
Measurement precisionVSQuantity of substance

Solution Approach 1:

The detection system segments the monitoring process by creating unique identifiers for each memory allocation and associating them with specific code fragments. This segmentation allows the system to track individual memory operations independently, enabling precise leak identification without requiring analysis of all memory operations as a single large dataset

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system performs preliminary grouping and filtering of memory records based on unique identifiers and code fragment associations. By pre-organizing the detailed allocation and deallocation records into structured groups before analysis, the system reduces the computational burden of processing raw data while maintaining complete tracking information for accurate leak detection

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS9778969B2Automatic memory leak detection
Publication Date: 2017.10.03 SAP SE
  • US9778969B2 patent drawing
  • US9778969B2 patent drawing
  • US9778969B2 patent drawing

AI summary

A method comprises: executing an executable code by a computer processor; repetitively executing at least a portion of the executable code comprising dynamic memory allocation requests and dynamic memory deallocation requests, wherein a repetition number of the repetitive executions is an integer value greater than one; in response to execution of each of the dynamic memory allocation requests generating a record, each of the records comprising a unique memory identification of the main memory dynamically allocated upon the execution of the each of the dynamic memory allocation requests and a unique code identification of a fragment of the executable code and/or of a fragment of a source code corresponding to the fragment of the executable code.