Static Memory Leak Detection via Control Flow Analysis

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing methods for detecting memory leaks in programs are manual and time-consuming, often requiring significant effort and rework, and are typically limited to runtime detection, failing to identify specific variables or functions causing leaks.

Innovation Solution

A Static Memory Leak Detector (SMLD) tool that tokenizes program code, analyzes control flows using a memory leak pattern to identify incorrect memory allocation and deallocation functions, and generates reports highlighting the source of memory leaks during the development phase, allowing for automated detection and prevention of memory leaks.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If manual methods are used to detect memory leaks, then detection capability is achieved, but time and effort required increase significantly

Engineering Contradiction:
Improvememory leak detection capabilityVSAvoidtime and effort for detection
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent replaces manual mechanical analysis with an automated static analysis system that uses pattern matching and control flow analysis to detect memory leaks. The system automatically parses source code, builds control flow graphs, and identifies memory leak patterns without requiring programmer intervention, thereby resolving the contradiction between detection capability and time consumption.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Solution Approach 2:

The static analysis system enables the code itself to reveal its own memory management issues through automated analysis. The system services the detection need by autonomously analyzing control flows and identifying leaks, eliminating the need for external manual inspection and significantly reducing the time and effort required.

Inventive Principle:
Principle #25Self-service

2Measurement precision

If runtime detection tools are used, then memory leaks can be detected, but rework is required after program development

Engineering Contradiction:
Improvememory leak detectionVSAvoiddevelopment efficiency
Core Design Contradiction:
Measurement precisionVSProductivity

Solution Approach 1:

The patent performs static analysis during the development phase rather than at runtime. By analyzing source code before execution, the system identifies memory leaks in advance, allowing developers to fix issues during the coding stage. This preliminary detection eliminates the need for post-development rework and maintains high productivity.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The static analysis system acts as an intermediary between the developer and the final program execution. It provides early feedback on memory management issues, serving as a mediator that prevents defects from reaching runtime, thereby avoiding costly rework while maintaining development efficiency.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Measurement precision

If existing detection tools are used, then memory leaks are identified, but specific variables or functions causing leaks are not highlighted

Engineering Contradiction:
Improvememory leak detectionVSAvoidlocating leak source
Core Design Contradiction:
Measurement precisionVSDifficulty of detecting and measuring

Solution Approach 1:

The patent segments the analysis by tracking control flows through specific functions and variables. The system breaks down the program into control flow graphs where each node represents a statement or block, and edges represent control flow. This segmentation allows precise identification of which specific variables and functions are responsible for memory leaks, making it easy to locate and fix the source of the problem.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system highlights problematic code regions by marking functions and variables that cause memory leaks. Through visual indication of affected code segments in the analysis results, developers can easily distinguish between clean and problematic code, significantly reducing the difficulty of locating leak sources.

Inventive Principle:
Principle #32Color changes

Data Source

PatentUS9811441B2Method and system for detecting memory leaks in a program
Publication Date: 2017.11.07 INFOSYS LTD
  • US9811441B2 patent drawing
  • US9811441B2 patent drawing
  • US9811441B2 patent drawing

AI summary

A method and a system have been disclosed for detecting one or more memory leaks in a program. The method includes receiving the program code. After receiving the program, the program is tokenized automatically in a predefined format. The predefined format may correspond to a format which is up-loadable to a database. Thereafter, the tokenized program code is analyzed to determine control flows in the program by using a memory leak pattern. The memory leak pattern is an incorrect control flow between the combination of memory allocation and memory de-allocation functions. After analyzing the tokenized program, the memory leaks are identified based on the determined control flows in the program. The memory leaks are identified during the development phase of the program code. Subsequently, the memory leaks are fixed by a programmer.