Targeted Resource Leak Detection via Partial Code Tracking

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing resource leak detection methods incur high overheads and low efficiency, limiting their ability to detect memory leaks in real-time environments, making it difficult to identify and address leaks that occur during actual program operation, which can lead to service disruptions.

Innovation Solution

A method that focuses on tracking specific target resources called by partial code within a program, determining storage resource amounts, and identifying resource leak locations based on preset conditions, allowing for online detection without tracking all code or resource allocations, thereby reducing performance overheads and improving detection efficiency.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If all memory allocation and release operations are tracked and recorded in log files, then memory leak detection can be performed, but detection overhead becomes high and efficiency decreases

Engineering Contradiction:
Improvememory leak detection accuracyVSAvoiddetection efficiency
Core Design Contradiction:
Measurement precisionVSProductivity

Solution Approach 1:

The patent segments the monitoring scope from all memory operations to only target code sections that are suspected or likely to contain leaks. This is achieved by allowing users to specify target code ranges (e.g., through annotations or configuration), thereby dividing the monitoring task into focused segments rather than uniformly monitoring entire programs. This segmentation reduces the volume of operations that need to be tracked while maintaining detection accuracy for critical areas.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent applies different monitoring strategies to different code regions. Target code sections are monitored with detailed tracking of allocation and release operations, while non-target sections receive minimal or no monitoring. This local differentiation ensures high detection precision where needed (in target code) while minimizing overhead in other areas, effectively resolving the contradiction between comprehensive detection and operational efficiency.

Inventive Principle:
Principle #3Local quality

2Reliability

If comprehensive resource tracking is performed, then resource leak detection capability is improved, but performance overhead increases and affects normal service running

Engineering Contradiction:
Improveresource leak detection capabilityVSAvoidperformance overhead
Core Design Contradiction:
ReliabilityVSUse of energy by moving object

Solution Approach 1:

The monitoring system is segmented to operate only on specified target code sections rather than entire programs. This is implemented through configuration mechanisms that define monitoring boundaries, allowing the system to focus computational resources on detecting leaks in critical areas while leaving other code paths unaffected. This segmentation reduces the performance overhead from comprehensive tracking to localized monitoring overhead.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent implements partial monitoring by selectively applying detection mechanisms only to target code sections that are most likely to contain leaks or are most critical to the system. This partial action approach provides sufficient detection capability for high-risk areas without incurring the full overhead of comprehensive monitoring across all code, thus balancing reliability improvement with performance preservation.

Inventive Principle:
Principle #16Partial or excessive action

3Productivity

If memory leak detection is performed only at test or debug stages, then detection overhead is manageable, but leaks occurring during actual runtime cannot be detected

Engineering Contradiction:
Improvedetection efficiencyVSAvoidruntime leak detection capability
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The patent designs the monitoring system to be universal across multiple execution phases. The same target code monitoring mechanism can be applied during testing, debugging, and production runtime environments. This is achieved through lightweight instrumentation that can be activated or deactivated based on runtime conditions, allowing the system to maintain detection capability across all stages without requiring separate detection mechanisms for each phase.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Solution Approach 2:

The monitoring system is made dynamic by allowing configuration of target code sections and monitoring intensity based on runtime conditions. During production runs, the system can dynamically adjust which code sections are monitored based on operational context, enabling efficient runtime detection without the overhead of comprehensive monitoring. This dynamic adaptability allows the system to provide runtime leak detection capability while maintaining acceptable performance characteristics.

Inventive Principle:
Principle #15Dynamics

Data Source

PatentEP3171274B1Resource leak detecting method and apparatus
Publication Date: 2019.07.10 HUAWEI TECH CO LTD
  • EP3171274B1 patent drawingFigure 1
  • EP3171274B1 patent drawingFigure 2~3
  • EP3171274B1 patent drawingFigure 4

AI summary

Embodiments of the present invention disclose a resource leak detection method, apparatus, and system. The method includes: obtaining a target resource called when target code of a program runs, where the target code is partial code in program code; determining a first storage resource amount occupied by the target resource; determining whether the first storage resource amount occupied by the target resource satisfies a first preset condition; and if the first storage resource amount occupied by the target resource satisfies the first preset condition, determining a storage location of the target code as a resource leak location. In the embodiments of the present invention, the target code of the program can be tracked, and further, by means of detection, the storage location of the target code can be determined as the resource leak location. It is unnecessary to track all resource allocation and release, thereby reducing performance overheads and improving resource leak detection efficiency.