Method, device and equipment for detecting and repairing Java memory leak and storage medium

By constructing multimodal feature vectors using a pre-trained large language model, Java memory leaks can be automatically detected and repaired, solving the problem of low efficiency in manual analysis in existing technologies and achieving efficient and accurate memory management.

CN123048369APending Publication Date: 2026-11-06NETWORK TECH CO LTD SHANGHAI XIAO WAY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611254794.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-18
Publication Date
2026-11-06

AI Technical Summary

Technical Problem

Existing Java memory leak detection methods rely on manual analysis, which is inefficient and prone to false positives and false negatives, and cannot achieve automated repair.

Method used

A pre-trained large language model is used to analyze multi-dimensional data, construct multimodal feature vectors, automatically detect memory leak points and types, and generate repair strategies through root cause analysis to achieve end-to-end automated repair.

Benefits of technology

It improves the intelligence level of memory management, reduces labor costs, enhances detection accuracy and efficiency, and enables intelligent detection and automatic repair of memory leaks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123048369A_ABST
    Figure CN123048369A_ABST
Patent Text Reader

Abstract

This application relates to a method, apparatus, device, and storage medium for detecting and repairing Java memory leaks. It includes: acquiring multi-dimensional data; constructing multi-modal feature vectors based on the multi-dimensional data; analyzing the multi-modal feature vectors using a large language model to obtain memory usage patterns and garbage collection behavior patterns; detecting and identifying memory leaks based on the memory usage patterns and garbage collection behavior patterns to obtain leak points and leak types; performing root cause analysis of leaks using the large language model based on the leak points and leak types to obtain root cause analysis results; generating a target repair strategy based on the root cause analysis results; repairing the Java application using the target repair strategy to obtain repair results; if the repair results do not meet preset conditions, adjusting the target repair strategy and returning to the step of analyzing the multi-modal feature vectors. This application can achieve intelligent detection and automatic repair of memory leaks, improving the efficiency and accuracy of memory management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Java memory management technology, and in particular to a method, apparatus, device and storage medium for detecting and repairing Java memory leaks. Background Technology

[0002] In existing technical solutions, there are three main methods for detecting Java memory leaks: the first is memory leak detection based on static code analysis, which mainly uses static analysis tools to scan Java code and detect potential memory leak risks; the second is memory analysis based on runtime monitoring, which mainly uses tools such as MAT and JProfiler to monitor the application's runtime memory status and analyze memory leaks; and the third is memory analysis based on traditional machine learning, which mainly uses traditional machine learning algorithms such as decision trees and random forests to analyze memory usage patterns.

[0003] However, the analysis process of the above three methods requires manual intervention. Technicians need to spend a lot of time checking data and analyzing memory, which not only leads to low detection efficiency, but also easily results in false positives or false negatives due to insufficient human experience, affecting the accuracy of memory leak detection. Secondly, most existing detection solutions can only stay at the "problem discovery" stage. Even if technicians make repair suggestions based on experience, they cannot achieve automated repair. Summary of the Invention

[0004] This application provides a method, apparatus, device, and storage medium for detecting and repairing Java memory leaks, aiming to solve the problem that traditional methods require manual data screening and memory analysis, resulting in low efficiency and accuracy in memory leak detection.

[0005] In a first aspect, embodiments of this application provide a method for detecting and repairing Java memory leaks, the method comprising: Obtain multi-dimensional data from a Java application; Based on the aforementioned multi-dimensional data, a multimodal feature vector is constructed; The multimodal feature vectors are analyzed using a pre-trained large language model to obtain memory usage patterns and garbage collection behavior patterns; Based on the memory usage pattern and the garbage collection behavior pattern, memory leaks are detected and identified to obtain the leak points and leak types. Based on the leak point and the leak type, a pre-trained large language model is used to perform leak root cause analysis to obtain the root cause analysis results. Based on the root cause analysis results, a target remediation strategy is generated; The Java application is repaired using the target repair strategy, and the repair result is obtained. Determine whether the repair result meets the preset conditions. If not, adjust the target repair strategy and return to the step of analyzing the multimodal feature vector using a pre-trained large language model.

[0006] A further technical solution is that the multi-dimensional data includes memory data from the Java application runtime, garbage collection data, source code information, business context, and historical leakage data. The construction of a multimodal feature vector based on the multi-dimensional data includes: Extract memory usage features, GC pattern features, code semantic features, business features, and historical leakage features from the memory data, the garbage collection data, the source code information, the business context, and the historical leakage data; The memory usage features, GC mode features, code semantic features, business features, and historical leakage features are aligned and fused to obtain a multimodal feature vector.

[0007] A further technical solution is that the detection and identification of memory leaks to obtain leak points includes: Analyze the creation stack of the leaked object to locate the specific code location where the leaked object was created; The call chain and business logic of the creation stack at the specific code location are analyzed to obtain the analysis results; Based on the analysis results, a location feature vector is constructed for the specific code location to determine the leak point.

[0008] A further technical solution is that the leakage types include object reference leakage, collection class leakage, cache leakage, and listener leakage. The root cause analysis of the leakage is performed using a pre-trained large language model to obtain the root cause analysis results, including: If the leakage type is the object reference leakage, then the reference chain analysis strategy is used to perform leakage root cause analysis using a pre-trained large language model to obtain the root cause analysis results. If the leakage type is the set-type leakage, then the pre-trained large language model is used to perform root cause analysis of the leakage using the set size analysis strategy to obtain the root cause analysis results; If the leakage type is the cache leakage, then the pre-trained large language model is used to perform cache lifecycle analysis strategy to perform root cause analysis of the leakage and obtain the root cause analysis results. If the leakage type is the listener leakage, then the pre-trained large language model is used to perform leakage root cause analysis using the event listener analysis strategy to obtain the root cause analysis results.

[0009] A further technical solution is that, if the leakage type is an object reference leakage, a reference chain analysis strategy is used with a pre-trained large language model to perform root cause analysis of the leakage, and the root cause analysis results are obtained, including: Analyze the reference chains and dependencies of leaked objects in a Java application; Construct an object reference path graph based on the reference chain and dependencies of the leaked object; Using the pre-trained large language model, semantic features are extracted and topological structure is analyzed on the object reference path graph to identify key nodes and abnormal reference relationships in the reference chain, and the complexity of the reference chain is calculated. Based on the complexity and the abnormal reference relationships, root cause analysis results are generated.

[0010] A further technical solution is that the Java application is repaired using the target repair strategy to obtain a repair result, including: Using the target repair strategy, code or configuration repairs are performed on at least one of the reference management, resource management, and cache management aspects of the Java application to obtain the repair result.

[0011] A further technical solution is that the preset conditions include preset memory optimization thresholds, preset performance improvement thresholds, and preset stability thresholds. The determination of whether the repair result meets the preset conditions includes: Determine whether the repair result meets the preset memory optimization threshold; If the repair result meets a preset memory optimization threshold, then it is determined whether the repair result meets a preset performance improvement threshold. If the repair result meets a preset performance improvement threshold, then it is determined whether the repair result meets a preset stability threshold.

[0012] Secondly, embodiments of this application also provide a Java memory leak detection and repair apparatus, which includes a unit for performing the above-described method.

[0013] Thirdly, embodiments of this application also provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.

[0014] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the above-described method.

[0015] This application provides a method, apparatus, device, and storage medium for detecting and repairing Java memory leaks. The method includes: acquiring multi-dimensional data of a Java application; constructing a multimodal feature vector based on the multi-dimensional data; analyzing the multimodal feature vector using a pre-trained large language model to obtain memory usage patterns and garbage collection behavior patterns; detecting and identifying memory leaks based on the memory usage patterns and garbage collection behavior patterns to obtain leak points and leak types; performing root cause analysis of leaks using the pre-trained large language model based on the leak points and leak types to obtain root cause analysis results; generating a target repair strategy based on the root cause analysis results; repairing the Java application using the target repair strategy to obtain a repair result; determining whether the repair result meets preset conditions; if not, adjusting the target repair strategy and returning to the step of analyzing the multimodal feature vector using the pre-trained large language model.

[0016] This application's embodiments, by introducing a pre-trained large language model, can automatically complete the entire process from multimodal data acquisition, feature fusion, leak detection, root cause analysis to generating remediation strategies and executing remediation. Furthermore, this application introduces a feedback adjustment mechanism; when the remediation result does not meet preset conditions, the system automatically adjusts the target remediation strategy and re-analyzes and re-remediates. This end-to-end automated processing method replaces the traditional model that relies on manual memory analysis and manual writing of remediation code, greatly reducing labor costs and improving the intelligence level of Java application memory management, thereby improving the efficiency and accuracy of Java application memory management. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0020] Figure 1A flowchart illustrating the first embodiment of the Java memory leak detection and repair method provided in this application; Figure 2 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0022] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0023] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0024] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0025] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0026] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0027] To address the aforementioned issues, this application provides a method for detecting and repairing Java memory leaks, which enables intelligent detection and automatic repair of memory leaks, thereby improving the efficiency and accuracy of memory management.

[0028] See Figure 1 , Figure 1 This application provides a flowchart illustrating a first embodiment of a Java memory leak detection and repair method, the method comprising the following steps: Step 110: Obtain multi-dimensional data from the Java application.

[0029] Step 120: Construct a multimodal feature vector based on the multidimensional data.

[0030] In steps 110 and 120, preprocessing and semantic encoding can be performed on the multi-dimensional data. Preprocessing may include standardizing the multi-dimensional data into a standard format, extracting key features from the multi-dimensional data, and converting the multi-dimensional data into a serialized model input. Semantic encoding includes memory pattern encoding (e.g., encoding memory usage patterns into vector representations), sequence encoding (e.g., using Transformer to encode memory usage sequences), and structure encoding (e.g., encoding structural information about memory usage), and the fusion of various semantic information types.

[0031] For example, the multi-dimensional data includes memory data of the Java application runtime, garbage collection data, source code information, business context, and historical leakage data. In step 120, memory usage features, GC pattern features, code semantic features, business features, and historical leakage features can be extracted from the memory data, the garbage collection data, the source code information, the business context, and the historical leakage data. Then, the memory usage features, the GC pattern features, the code semantic features, the business features, and the historical leakage features are aligned and fused to obtain a multimodal feature vector.

[0032] Specifically, memory usage characteristics can include memory allocation, object lifecycle, and reference relationships between objects; GC mode characteristics can include garbage collection frequency, collection effect, and pause time; code semantic characteristics can include the syntax structure of Java code, memory operations, and object creation; and business characteristics can include business logic, data access patterns, and cache usage.

[0033] Step 130: Analyze the multimodal feature vectors using a pre-trained large language model to obtain memory usage patterns and garbage collection behavior patterns.

[0034] Step 130 mainly includes the memory usage pattern analysis stage and the GC pattern analysis stage.

[0035] Specifically, the memory usage pattern analysis phase mainly analyzes memory allocation patterns, which may include object creation patterns, memory allocation patterns, and object reference patterns.

[0036] Among them, object creation patterns mainly involve analyzing the creation frequency and lifecycle patterns of objects; identifying the types of objects created frequently and their creation locations; analyzing the timing and business scenarios of object creation; evaluating the performance impact and memory consumption of object creation; and constructing feature vectors and optimization suggestions for object creation patterns.

[0037] The memory allocation pattern analysis mainly involves analyzing the size distribution and frequency of memory allocations; identifying large object allocations and frequent small object allocations; analyzing the timing and triggering conditions of memory allocations; evaluating the impact of memory allocations on GC; and constructing feature representations and optimization strategies for memory allocation patterns.

[0038] Object reference patterns primarily involve analyzing the reference relationships and dependency chains between objects; identifying circular references and strong reference chains; analyzing the lifecycle and release timing of references; evaluating the impact of reference patterns on memory reclamation; and constructing feature vectors and optimization suggestions for object reference patterns.

[0039] The GC mode analysis phase mainly involves garbage collection analysis, which can include GC frequency analysis, GC effect analysis, and GC pause analysis.

[0040] Among them, GC frequency analysis mainly involves analyzing the triggering frequency and interval of GC; identifying GC frequency anomalies and performance bottlenecks; analyzing the relationship between GC frequency and memory usage; evaluating the impact of GC frequency on application performance; and constructing feature vectors and optimization suggestions for GC frequency analysis.

[0041] GC performance analysis mainly involves analyzing the effectiveness of GC and the amount of memory released; identifying poor GC performance and insufficient memory reclamation; analyzing the relationship between GC performance and object lifecycle; evaluating the impact of GC performance on memory usage; and constructing feature representations and optimization strategies for GC performance analysis.

[0042] GC pause analysis mainly involves analyzing GC pause time and frequency; identifying GC pause anomalies and performance issues; analyzing the relationship between GC pauses and business load; assessing the impact of GC pauses on user experience; and constructing feature vectors and optimization suggestions for GC pause analysis.

[0043] Step 140: Based on the memory usage pattern and the garbage collection behavior pattern, detect and identify memory leaks to obtain the leak points and leak types.

[0044] In some embodiments, the specific location of a memory leak can be intelligently located based on memory usage analysis and code semantic understanding. In this case, a multi-dimensional location analysis method can be used to locate the leak point. For example, the leak can be located by code location (such as locating the specific code location where the leak occurs), analyzing the call chain and reference path of the leaked object, analyzing the impact of business logic on the memory leak, and analyzing the time pattern and trend of the leak occurrence to achieve the location analysis of the leak point.

[0045] Specifically, the process of locating and analyzing leak points can employ stack analysis, reference chain analysis, and business logic analysis. Stack analysis can include: analyzing the creation stack of the leaked object to locate the specific code location where the leaked object was created; analyzing the call chain and business logic of the creation stack at the specific code location to obtain analysis results; assessing the complexity and risk of fixing the code location; constructing a location feature vector for the specific code location based on the analysis results; identifying the leak point; and providing remediation suggestions.

[0046] Reference chain analysis can include analyzing the reference chains and dependencies of leaked objects; identifying key nodes and bottlenecks in the reference chains; analyzing the complexity and optimization space of the reference chains; evaluating the accuracy and completeness of the reference chain analysis; and constructing feature representations and optimization strategies for the reference chain analysis.

[0047] Business logic analysis can include analyzing the impact of business logic on memory usage; identifying memory management issues in business logic; analyzing the triggering effect of business scenarios on memory leaks; evaluating the feasibility and effectiveness of business logic optimization; and constructing feature vectors and optimization suggestions for business logic analysis.

[0048] In some embodiments, the memory leak identification phase primarily focuses on leak pattern detection. These leak types (i.e., leak patterns) include object reference leaks, collection class leaks, cache leaks, and listener leaks. For object reference leak detection, the main focus is on detecting situations where objects cannot be garbage collected; identifying excessively long object reference chains and circular references; analyzing the root causes and scope of impact of object leaks; assessing the severity and remediation priority of object leaks; and constructing feature vectors and remediation suggestions for object leak detection. For collection class leak detection, the main focus is on detecting situations where collection class objects continuously grow; identifying issues where collection class elements cannot be released; analyzing the business scenarios and triggering conditions of collection class leaks; assessing the performance impact and remediation costs of collection class leaks; and constructing feature representations and optimization strategies for collection class leak detection. For cache leak detection, the main focus is on detecting situations where cached objects cannot expire and be cleaned up; identifying inappropriate caching strategies and lifecycle management issues; analyzing the business impact and user experience of cache leaks; assessing the complexity and effectiveness of cache leak remediation; and constructing feature vectors and optimization suggestions for cache leak detection.

[0049] Step 150: Based on the leak point and the leak type, perform root cause analysis of the leak using a pre-trained large language model to obtain the root cause analysis results.

[0050] Root cause analysis can specifically include reference chain analysis (such as analyzing the reference chain and dependencies of objects), lifecycle analysis (such as analyzing the lifecycle and release timing of objects), business scenario analysis (such as analyzing the impact of business scenarios on memory usage), and system architecture analysis (such as analyzing the impact of system architecture on memory management).

[0051] Root cause analysis can also include design flaw analysis, implementation problem analysis, and configuration problem analysis. Specifically, design flaw analysis mainly analyzes memory management defects in the system design; identifies the impact of architectural design on memory leaks; analyzes the impact of design patterns on memory usage; assesses the complexity and cost of fixing design flaws; and constructs feature vectors and remediation suggestions for design flaw analysis. Implementation problem analysis mainly analyzes memory management problems in code implementation; identifies the impact of implementation details on memory leaks; analyzes the impact of code quality on memory usage; assesses the feasibility and effectiveness of implementation problem remediation; and constructs feature representations and optimization strategies for implementation problem analysis. Configuration problem analysis mainly analyzes the impact of system configuration on memory management; identifies the impact of configuration parameters on memory usage; analyzes the preventive effect of configuration optimization on memory leaks; assesses the simplicity and effectiveness of configuration problem remediation; and constructs feature vectors and optimization suggestions for configuration problem analysis.

[0052] In some embodiments, the leakage types include object reference leakage, collection class leakage, cache leakage, and listener leakage. The root cause analysis of the leakage using a pre-trained large language model to obtain the root cause analysis results includes: 1) If the leakage type is the object reference leakage, then the reference chain analysis strategy is used to perform leakage root cause analysis using a pre-trained large language model to obtain the root cause analysis results; Specifically, this can involve analyzing the reference chains and dependencies of leaked objects in a Java application; constructing an object reference path graph based on the reference chains and dependencies of the leaked objects; using the pre-trained large language model to perform semantic feature extraction and topological structure analysis on the object reference path graph, identifying key nodes and abnormal reference relationships in the reference chains, and calculating the complexity of the reference chains; and generating root cause analysis results based on the complexity and the abnormal reference relationships.

[0053] 2) If the leakage type is the set-type leakage, then the pre-trained large language model is used to perform root cause analysis of the leakage using the set size analysis strategy to obtain the root cause analysis results; 3) If the leakage type is the cache leakage, then the pre-trained large language model is used to perform cache lifecycle analysis to analyze the root cause of the leakage and obtain the root cause analysis results. 4) If the leakage type is the listener leakage, then the pre-trained large language model is used to perform leakage root cause analysis using the event listener analysis strategy to obtain the root cause analysis results.

[0054] In some embodiments, after performing root cause analysis on memory leaks, the impact of the leak can also be assessed, specifically including performance impact analysis, stability impact analysis, and business impact analysis. Specifically, performance impact analysis can include analyzing the impact of memory leaks on system performance; assessing the impact of leaks on GC performance and pause times; analyzing the impact of leaks on application response time; assessing the impact of leaks on system throughput; and constructing feature vectors and optimization suggestions for performance impact analysis. Stability impact analysis can include analyzing the impact of memory leaks on system stability; assessing the impact of leaks on system availability; analyzing the impact of leaks on system reliability; assessing the impact of leaks on system scalability; and constructing feature representations and optimization strategies for stability impact analysis. Business impact analysis can include analyzing the impact of memory leaks on business functions; assessing the impact of leaks on user experience; analyzing the impact of leaks on business metrics; assessing the impact of leaks on business continuity; and constructing feature vectors and remediation suggestions for business impact analysis.

[0055] Step 160: Generate a target remediation strategy based on the root cause analysis results.

[0056] The target repair strategy includes memory optimization strategies and code repair solutions, which may include code refactoring optimization (such as solving memory problems through code refactoring), configuration tuning optimization (such as optimizing memory usage through configuration tuning), architecture optimization (such as optimizing memory management through architecture adjustment), and algorithm optimization (such as reducing memory consumption through algorithm optimization).

[0057] Specifically, the optimization strategy generation phase mainly focuses on code refactoring strategies, including object lifecycle optimization, memory allocation optimization, and collection class optimization. Object lifecycle optimization primarily involves optimizing the timing of object creation and destruction; implementing object pooling and caching mechanisms; optimizing object references and dependencies; implementing weak and soft reference optimization; and generating code templates for object lifecycle optimization. Memory allocation optimization mainly involves optimizing memory allocation strategies and sizes; implementing memory pre-allocation and reuse mechanisms; optimizing large object allocation and fragmentation management; implementing memory allocation monitoring and tuning; and generating configuration suggestions for memory allocation optimization. Collection class optimization mainly involves optimizing the selection and configuration of collection classes; implementing capacity management and expansion strategies for collection classes; optimizing element management and cleanup for collection classes; implementing performance monitoring and tuning for collection classes; and generating code refactoring schemes for collection class optimization.

[0058] Step 170: Use the target repair strategy to repair the Java application and obtain the repair result.

[0059] In some embodiments, the target repair strategy can be used to repair the code or configuration of at least one of the reference management, resource management, and cache management of a Java application to obtain a repair result.

[0060] Specifically, reference management repair mainly involves automatically adding object reference management code; implementing automatic reference cleanup and release mechanisms; optimizing reference chains and dependencies; implementing reference monitoring and exception handling; and generating code patches for reference management repair. Resource management repair mainly involves automatically adding resource management code; implementing the try-with-resources pattern; optimizing resource lifecycle management; implementing resource monitoring and exception handling; and generating code templates for resource management repair. Cache management repair mainly involves automatically adding cache management code; implementing cache expiration and cleanup mechanisms; optimizing cache strategies and configurations; implementing cache monitoring and performance tuning; and generating configuration schemes for cache management repair.

[0061] Step 180: Determine whether the repair result meets the preset conditions. If not, adjust the target repair strategy and return to the step of using a pre-trained large language model to analyze the multimodal feature vector.

[0062] In some embodiments, the preset conditions include a preset memory optimization threshold, a preset performance improvement threshold, and a preset stability threshold. Determining whether the repair result meets the preset conditions includes: determining whether the repair result meets the preset memory optimization threshold; in response to the repair result meeting the preset memory optimization threshold, determining whether the repair result meets the preset performance improvement threshold; and in response to the repair result meeting the preset performance improvement threshold, determining whether the repair result meets the preset stability threshold.

[0063] In step 180, the repair results can be evaluated and verified, specifically including memory usage improvement evaluation, performance improvement evaluation, and stability improvement evaluation. The memory usage improvement evaluation can include assessing the memory usage after the repair; analyzing the effectiveness of memory leak resolution; evaluating the improvement in memory usage efficiency; analyzing the optimization effect of memory allocation; and generating a memory usage improvement evaluation report. The performance improvement evaluation can include assessing the system performance after the repair; analyzing improvements in GC performance and pause time; assessing improvements in application response time; analyzing improvements in system throughput; and generating a performance improvement evaluation report. The stability improvement evaluation mainly includes assessing the system stability after the repair; analyzing improvements in system availability; assessing improvements in system reliability; analyzing improvements in system scalability; and generating a stability improvement evaluation report.

[0064] This embodiment, by introducing a pre-trained large language model, can automatically complete the entire process from multimodal data acquisition, feature fusion, leak detection, root cause analysis to generating remediation strategies and executing remediation. Furthermore, this application introduces a feedback adjustment mechanism. When the remediation result is determined not to meet preset conditions, the system automatically adjusts the target remediation strategy and re-analyzes and re-remediates. This end-to-end automated processing method replaces the traditional model that relies on manual memory analysis and manual writing of remediation code, greatly reducing labor costs and improving the intelligence level of Java application memory management, thereby improving the efficiency and accuracy of Java application memory management.

[0065] Based on the above methods for detecting and repairing Java memory leaks, this application also provides a Java memory leak detection and repair system. This system adopts a layered microservice architecture design, including an infrastructure layer, a data acquisition layer, a large language model analysis layer, an intelligent decision-making layer, an execution optimization layer, and a feedback optimization layer.

[0066] Specifically, the infrastructure layer, as the underlying support of the entire system, is primarily responsible for providing the basic environment and tool integration required for Java application execution and analysis. This includes the Java runtime environment (such as JDK, JVM, and memory management APIs) to ensure the system can access and monitor target applications; an analysis tool integration module that integrates professional tools such as MAT, JProfiler, and heap dump analysis to support in-depth memory analysis; a monitoring system module that enables real-time, comprehensive monitoring of memory usage and GC performance; and a configuration center that provides centralized configuration management and dynamic update capabilities, ensuring flexible configuration and efficient collaboration among system components.

[0067] The data acquisition layer focuses on obtaining multi-dimensional raw data from the target Java application. Its main functions include: memory usage data acquisition, providing real-time information on memory usage, object allocation, and GC execution; GC log analysis, parsing garbage collection logs to extract key performance indicators; heap dump analysis, identifying potential memory leak objects through parsing heap dump files; and code semantic extraction, extracting semantic information and memory usage patterns from the source code to provide rich contextual data for subsequent intelligent analysis.

[0068] The large language model analysis layer serves as the intelligent core of the system. This layer leverages the powerful understanding and reasoning capabilities of the large language model to perform in-depth analysis of the collected data. Specifically, it covers: memory pattern recognition, analyzing application memory usage patterns based on the large language model to identify abnormal behavior; leak point location, intelligently analyzing and locating the specific code location and cause of memory leaks; memory optimization, generating targeted memory optimization strategies and remediation suggestions; and code understanding, deeply understanding the memory usage semantics of Java code to uncover potential optimization opportunities.

[0069] The intelligent decision-making layer performs comprehensive judgment and generates decisions based on the analysis results of the large language model. Its main functions include: memory leak detection, automatically identifying and confirming memory leaks and their potential risks; leak point location, further pinpointing the root cause of the leak and assessing its impact range; automatic remediation strategy generation, generating specific remediation strategies based on leak characteristics; and memory optimization suggestions, outputting detailed code optimization and refactoring recommendations to provide clear action guidelines for the execution layer.

[0070] The execution optimization layer is responsible for translating the strategies and suggestions from the decision-making layer into practical actions. Through deep integration and adaptation with tools such as MAT and JProfiler, it enables the invocation of memory analysis capabilities; at the same time, it has the ability to execute code refactoring and memory optimization, and can automatically or assistedly execute code refactoring, optimization operations and performance tuning, thus translating intelligent decisions into actual code improvements and performance enhancements.

[0071] The feedback optimization layer, acting as the system's self-evolution engine, is responsible for evaluating and providing feedback on optimization results. Through the effect evaluation module, it quantifies and analyzes the effectiveness of memory optimization strategies; utilizing a model learning mechanism, it continuously trains and optimizes the large language model based on feedback data, improving the accuracy of its analysis and decision-making; through a strategy update mechanism, it periodically iterates and optimizes the strategy library and rule set; and with the help of a performance monitoring module, it continuously tracks memory performance and system stability to ensure the system's long-term efficient operation.

[0072] It should be noted that in the system architecture of this application, both the Java application and the memory analysis tool adopt an integrated architecture. The Java application integrated architecture mainly includes two core features: application monitoring integration and development tool integration. Regarding application monitoring integration, the system implements in-depth monitoring of JVM memory and garbage collection (GC) status, while integrating application performance monitoring, business monitoring, application and error log monitoring, and monitoring of key business and performance indicators. Regarding development tool integration, this architecture provides a memory analysis plugin embedded in the integrated development environment (IDE) and fully integrates with mainstream build tools such as Maven and Gradle, unit and integration testing tools, as well as CI / CD pipelines and automated deployment tools, thereby achieving seamless access and comprehensive monitoring of the entire Java application lifecycle. The memory analysis tool integrated architecture deeply integrates mainstream professional analysis tools in the industry, mainly including two core modules: MAT integration and JProfiler integration. Among them, the MAT integration module fully incorporates its powerful heap dump analysis, memory leak detection, object deep analysis and automated report generation functions, providing support for in-depth investigation of static memory snapshots; while the JProfiler integration module focuses on dynamic runtime monitoring, integrating its memory monitoring, performance analysis, thread analysis and real-time monitoring functions, thereby realizing real-time tracking of the running status of Java applications and multi-dimensional performance analysis.

[0073] Furthermore, this application can optimize large language models and in-memory analysis execution. Large language model optimization can employ model compression and inference acceleration techniques. Model compression techniques can include knowledge distillation (e.g., using a small model to learn the predictive ability of a large model), model pruning (e.g., removing unimportant neurons and connections), quantization techniques (e.g., using low-precision values ​​to reduce computational overhead), and model parallelism (e.g., distributing the model across multiple devices for parallel computation). Inference acceleration techniques can include batch processing optimization (e.g., merging multiple analysis requests for batch processing), caching analysis results (e.g., caching frequently used analysis results), asynchronous analysis (e.g., using asynchronous mechanisms to improve analysis concurrency), and approximate computation (e.g., using approximate algorithms to balance accuracy and speed). Thus, through large language model optimization, analysis latency is significantly reduced in response speed, successfully meeting millisecond-level real-time analysis requirements; in terms of cost control, model compression technology reduces model size by 75%, significantly reducing deployment and maintenance costs; in terms of processing power, analysis throughput is increased by 600%, easily handling large-scale concurrent analysis; and in terms of resource efficiency, resource utilization is improved by 70%, greatly optimizing the return on hardware investment.

[0074] Memory analysis execution optimization includes batching of analysis operations and concurrency control optimization. Batching of analysis operations mainly involves introducing efficient analysis pipeline technology, enabling the system to merge and process scattered analysis requests. Specifically, this strategy covers batch memory analysis, batch leak detection, and batch optimization suggestion generation. By merging multiple independent analysis tasks, the system scheduling overhead is significantly reduced, and the overall pipeline efficiency is significantly improved. Concurrency control optimization mainly addresses resource contention issues in high-concurrency scenarios. The system employs multi-dimensional concurrency optimization methods. First, a read-write separation strategy is implemented to isolate read and write operations to improve concurrency performance. Second, a fine-grained locking mechanism is introduced to minimize lock contention, and combined with lock-free data structures to further eliminate synchronization bottlenecks. In addition, asynchronous I / O operations are fully adopted, effectively improving the system's concurrency and responsiveness when handling multiple tasks. Optimization through memory analysis not only significantly reduced memory analysis latency by 75%, greatly improving the developer experience and troubleshooting efficiency, but also achieved superior concurrency and high throughput performance. Concurrency processing capacity increased by 500%, and overall system throughput increased by 600%, easily handling the high-concurrency analysis needs of enterprise-level large-scale codebases. Furthermore, while performing high-intensity analysis tasks, system resource consumption was reduced by 55%, significantly improving hardware resource utilization efficiency.

[0075] In summary, this application has achieved significant technological breakthroughs in memory analysis effectiveness, cost-effectiveness, and intelligence. Regarding core performance indicators, intelligent analysis dramatically increased the accuracy of memory leak detection from 62% to 96.4% (an improvement of over 34%), and the leak point location accuracy reached 92.8% (an improvement of over 25%). Simultaneously, analysis latency plummeted from 800ms to below 80ms, achieving a leap in analysis efficiency of 900%. This millisecond-level real-time analysis capability not only meets stringent real-time requirements but also intelligently balances multiple objectives such as memory usage, system performance, and stability. In terms of practical application benefits, this solution, through preventative analysis and intelligent troubleshooting, successfully reduced memory problem debugging time by 65%, reduced memory leak-related operational failures by 55%, and lowered the memory leak incidence rate by over 85%, thereby significantly improving the overall system stability and comprehensive development and operation efficiency.

[0076] Corresponding to the above-described methods for detecting and repairing Java memory leaks, this application also provides a device for detecting and repairing Java memory leaks. This device includes a unit for executing the aforementioned methods for detecting and repairing Java memory leaks, and can be configured in terminals such as desktop computers, tablet computers, and laptops.

[0077] like Figure 2 As shown in the figure, this application provides a computer device including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114. Memory 113 is used to store computer programs; In one embodiment of this application, when the processor 111 executes a program stored in the memory 113, it implements the Java memory leak detection and repair method provided in any of the foregoing method embodiments, including: Obtain multi-dimensional data from a Java application; Based on the aforementioned multi-dimensional data, a multimodal feature vector is constructed; The multimodal feature vectors are analyzed using a pre-trained large language model to obtain memory usage patterns and garbage collection behavior patterns; Based on the memory usage pattern and the garbage collection behavior pattern, memory leaks are detected and identified to obtain the leak points and leak types. Based on the leak point and the leak type, a pre-trained large language model is used to perform leak root cause analysis to obtain the root cause analysis results. Based on the root cause analysis results, a target remediation strategy is generated; The Java application is repaired using the target repair strategy, and the repair result is obtained. Determine whether the repair result meets the preset conditions. If not, adjust the target repair strategy and return to the step of analyzing the multimodal feature vector using a pre-trained large language model.

[0078] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program may be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.

[0079] Therefore, embodiments of this application also provide a computer-readable storage medium storing a computer program thereon, wherein when the computer program is executed by a processor, it implements the steps of the Java memory leak detection and repair method provided in any of the foregoing method embodiments, including: Obtain multi-dimensional data from a Java application; Based on the aforementioned multi-dimensional data, a multimodal feature vector is constructed; The multimodal feature vectors are analyzed using a pre-trained large language model to obtain memory usage patterns and garbage collection behavior patterns; Based on the memory usage pattern and the garbage collection behavior pattern, memory leaks are detected and identified to obtain the leak points and leak types. Based on the leak point and the leak type, a pre-trained large language model is used to perform leak root cause analysis to obtain the root cause analysis results. Based on the root cause analysis results, a target remediation strategy is generated; The Java application is repaired using the target repair strategy, and the repair result is obtained. Determine whether the repair result meets the preset conditions. If not, adjust the target repair strategy and return to the step of analyzing the multimodal feature vector using a pre-trained large language model.

[0080] The storage medium is a physical, non-transient storage medium, such as a USB flash drive, external hard drive, read-only memory (ROM), magnetic disk, or optical disk, or any other physical storage medium capable of storing program code. The computer-readable storage medium can be non-volatile or volatile.

[0081] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.

[0082] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.

[0083] The steps in the methods of this application embodiment can be adjusted, merged, or deleted according to actual needs. The units in the apparatus of this application embodiment can be merged, divided, or deleted according to actual needs. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0084] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0085] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0086] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Since these modifications and variations fall within the scope of the claims and their equivalents, this application also intends to include these modifications and variations.

[0087] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for detecting and repairing Java memory leaks, characterized in that, The method includes: Obtain multi-dimensional data from a Java application; Based on the aforementioned multi-dimensional data, a multimodal feature vector is constructed; The multimodal feature vectors are analyzed using a pre-trained large language model to obtain memory usage patterns and garbage collection behavior patterns; Based on the memory usage pattern and the garbage collection behavior pattern, memory leaks are detected and identified to obtain the leak points and leak types. Based on the leak point and the leak type, a pre-trained large language model is used to perform leak root cause analysis to obtain the root cause analysis results. Based on the root cause analysis results, a target remediation strategy is generated; The Java application is repaired using the target repair strategy, and the repair result is obtained. Determine whether the repair result meets the preset conditions. If not, adjust the target repair strategy and return to the step of analyzing the multimodal feature vector using a pre-trained large language model.

2. The method according to claim 1, characterized in that, The multi-dimensional data includes runtime memory data of the Java application, garbage collection data, source code information, business context, and historical leak data. The construction of a multimodal feature vector based on this multi-dimensional data includes: Extract memory usage features, GC pattern features, code semantic features, business features, and historical leakage features from the memory data, the garbage collection data, the source code information, the business context, and the historical leakage data; The memory usage features, GC mode features, code semantic features, business features, and historical leakage features are aligned and fused to obtain a multimodal feature vector.

3. The method according to claim 1, characterized in that, The detection and identification of memory leaks, to obtain the leak points, includes: Analyze the creation stack of the leaked object to locate the specific code location where the leaked object was created; The call chain and business logic of the creation stack at the specific code location are analyzed to obtain the analysis results; Based on the analysis results, a location feature vector is constructed for the specific code location to determine the leak point.

4. The method according to claim 1, characterized in that, The leak types include object reference leaks, collection class leaks, cache leaks, and listener leaks. The root cause analysis of the leaks is performed using a pre-trained large language model, and the root cause analysis results include: If the leakage type is the object reference leakage, then the reference chain analysis strategy is used to perform leakage root cause analysis using a pre-trained large language model to obtain the root cause analysis results. If the leakage type is the set-type leakage, then the pre-trained large language model is used to perform root cause analysis of the leakage using the set size analysis strategy to obtain the root cause analysis results; If the leakage type is the cache leakage, then the pre-trained large language model is used to perform cache lifecycle analysis strategy to perform root cause analysis of the leakage and obtain the root cause analysis results. If the leakage type is the listener leakage, then the pre-trained large language model is used to perform leakage root cause analysis using the event listener analysis strategy to obtain the root cause analysis results.

5. The method according to claim 4, characterized in that, If the leakage type is an object reference leakage, then a reference chain analysis strategy is used with a pre-trained large language model to perform root cause analysis of the leakage, and the root cause analysis results are obtained, including: Analyze the reference chains and dependencies of leaked objects in a Java application; Construct an object reference path graph based on the reference chain and dependencies of the leaked object; Using the pre-trained large language model, semantic features are extracted and topological structure is analyzed on the object reference path graph to identify key nodes and abnormal reference relationships in the reference chain, and the complexity of the reference chain is calculated. Based on the complexity and the abnormal reference relationships, root cause analysis results are generated.

6. The method according to claim 1, characterized in that, The process of repairing the Java application using the target repair strategy to obtain repair results includes: Using the target repair strategy, code or configuration repairs are performed on at least one of the reference management, resource management, and cache management aspects of the Java application to obtain the repair result.

7. The method according to claim 1, characterized in that, The preset conditions include preset memory optimization thresholds, preset performance improvement thresholds, and preset stability thresholds. Determining whether the repair result meets the preset conditions includes: Determine whether the repair result meets the preset memory optimization threshold; If the repair result meets a preset memory optimization threshold, then it is determined whether the repair result meets a preset performance improvement threshold. If the repair result meets a preset performance improvement threshold, then it is determined whether the repair result meets a preset stability threshold.

8. A Java memory leak detection and repair device, characterized in that, Includes a unit for performing the method as described in any one of claims 1-7.

9. A computer device, characterized in that, The computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, can implement the method as described in any one of claims 1-7.