A resource leakage monitoring method and terminal
By employing a cross-platform resource leak monitoring method that utilizes detailed information logging and asynchronous disk writing technology, the limitations of existing tools in cross-platform and cross-language support are overcome, enabling flexible resource leak monitoring and accurate leak detection, thereby improving system performance and user experience.
Patent Information
- Application Number
- CN202410972107.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2044-07-19
AI Technical Summary
Existing resource leak monitoring tools have limitations in cross-platform and cross-language support, poor data scalability and flexibility, and cannot effectively identify resource leak problems in various programming environments.
By recording detailed information of operation instructions and performing formatted conversion, and using buffer storage and callback functions to asynchronously write to disk, combined with asynchronous loading and SQL analysis, cross-platform resource leak monitoring is achieved, potential leaks are identified, and related information is analyzed.
It improves the accuracy and reliability of resource leak detection, reduces system resource overhead, ensures data integrity and recoverability, supports multi-dimensional data analysis, and enhances user interaction experience and system applicability.
Smart Images

Figure CN118897774B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of resource monitoring, in particular to a resource leakage monitoring method and terminal. BACKGROUND
[0002] At present, various resource leakage monitoring tools exist on the market, such as Valgrind, AddressSanitizer, LeakSanitizer, Deleaker and other special leakage diagnosis tools. These tools mainly monitor resource leakage in specific programming environments and can provide analysis data for memory leakage, handle leakage and other problems. They track and identify memory leakage problems through various technical means, such as registering memory allocation, releasing hook functions, macro definition replacement and binary translation. Even though they are effective in memory management, error debugging and performance monitoring, they each have limitations, such as poor data scalability and flexibility, limited support for leakage types, and inability to support cross-platform and cross-language. Therefore, there is an urgent need for a resource leakage monitoring method and terminal that can solve the above problems. SUMMARY
[0003] The technical problem to be solved by the present application is to provide a resource leakage monitoring method and terminal that can be applied to various programming environments and operating systems, implement cross-platform monitoring, and provide flexibility and scalability for resource leakage monitoring through a flexible data processing mechanism.
[0004] To solve the above technical problems, the technical scheme adopted by the present application is:
[0005] A resource leakage monitoring method, comprising the steps of:
[0006] S1, recording detailed information of an operation instruction according to the operation instruction, formatting and converting the detailed information and adding it to a buffer area, the detailed information including general information and custom information, the general information including an operation type, and the custom information including a type name and a reference chain;
[0007] S2, if the disk write time reaches a time threshold or the capacity of the buffer area reaches a capacity threshold, writing the detailed information to the disk by executing a callback function;
[0008] S3, periodically reading disk data in an asynchronous loading mode, pairing according to the operation type in the general information of the detailed information, and if there are unpaired "application" and "release" operation types, determining that it is a potential resource leakage, and analyzing the associated information of the resource leakage according to the type name and the reference chain in the custom information of the detailed information.
[0009] To solve the above technical problems, the application adopts another technical solution:
[0010] A resource leakage monitoring terminal comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements each step of the above resource leakage monitoring method when executing the computer program.
[0011] The application has the beneficial effects that: the application provides a resource leakage monitoring method and terminal, detailed information of an operation instruction is recorded according to the operation instruction, the detailed information is formatted and converted and added to a buffer area, the write logic of an atomic operation is simple, the required applied memory is less, and the handle resource can be released immediately after the file is written, reducing the system resource overhead; if the disk write time reaches a time threshold or the capacity of the buffer area reaches a capacity threshold, the detailed information is written to the disk by executing a callback function, ensuring the integrity and recoverability of the data, improving the accuracy and reliability of subsequent data analysis; the disk data is read periodically in an asynchronous loading mode, independently of the main program, avoiding performance degradation caused by preempting hardware resources, eliminating the influence on the performance and stability of the "monitored program", and performing pairing judgment according to the operation type in the general information of the detailed information, if there are unpaired "application" and "release" operation types, it is determined as a potential resource leakage, and the associated information of the resource leakage is analyzed according to the type name and reference chain in the custom information of the detailed information, the resource leakage object is accurately identified, and the accuracy and reliability of resource leakage detection are improved. In summary, the application separates the data recording and analysis links, records the related information of the atomic operation to the disk, greatly reduces the performance overhead, and at the same time provides integrity and recoverability guarantee for subsequent data analysis; the data is analyzed by pairing based on the detailed information of the operation instruction, so as to identify the resource leakage type and leakage reason, and further mine the reference relationship between the resource leakage objects, facilitate to find the objects with root problems, and thus realize resource leakage monitoring. BRIEF DESCRIPTION OF DRAWINGS
[0012] Figure 1 A flowchart of a resource leakage monitoring method of an embodiment of the application;
[0013] Figure 2 A schematic diagram of a resource leakage monitoring terminal of an embodiment of the application;
[0014] Figure 3 A whole flowchart of a resource leakage monitoring method of an embodiment of the application;
[0015] Figure 4 A class diagram of a resource leakage monitoring method of an embodiment of the application;
[0016] Label description:
[0017] 1. A resource leakage monitoring terminal; 2. a memory; 3. a processor. DETAILED DESCRIPTION
[0018] To illustrate the technical content of the present application, the purposes and effects achieved are described in detail below in conjunction with the embodiments and the accompanying drawings.
[0019] Please refer to Figure 1 The embodiment of the present application provides a resource leakage monitoring method, comprising the steps of:
[0020] S1, recording detailed information of the operation instruction according to the operation instruction, and adding the detailed information to a buffer area after format conversion, wherein the detailed information comprises general information and custom information, the general information comprises an operation type, and the custom information comprises a type name and a reference chain;
[0021] S2, if the disk writing time reaches a time threshold or the capacity of the buffer area reaches a capacity threshold, writing the detailed information to a disk by executing a callback function;
[0022] S3, periodically reading disk data in an asynchronous loading mode, pairing according to the operation type in the general information of the detailed information, and if there are unpaired "application" and "release" operation types, determining that it is a potential resource leakage, and analyzing the associated information of the resource leakage according to the type name and the reference chain in the custom information of the detailed information.
[0023] From the above description, the beneficial effects of the present application are that the present application provides a resource leakage monitoring method and terminal, detailed information of an operation instruction is recorded according to the operation instruction, the detailed information is formatted and converted and added to a buffer, the write logic of an atomic operation is simple, the required applied memory is less, and the handle resource can be released immediately after the file is written, reducing the system resource overhead; if the disk write time reaches a time threshold or the capacity of the buffer reaches a capacity threshold, the detailed information is written to the disk by executing a callback function, ensuring the integrity and recoverability of the data, and improving the accuracy and reliability of subsequent data analysis; the disk data is read periodically in an asynchronous loading manner, independent of the main program running, avoiding performance degradation caused by preempting hardware resources, eliminating the influence on the performance and stability of the "monitored program", and performing pairing judgment according to the operation type in the general information, if there are unpaired "application" and "release" operation types, it is determined as a potential resource leakage, and the associated information of the resource leakage is analyzed according to the type name and reference chain in the custom information of the detailed information, the resource leakage object is accurately identified, and the accuracy and reliability of resource leakage detection are improved. In summary, the present application separates the data recording and analysis links, records the related information of the atomic operation to the disk, greatly reduces the performance overhead, and at the same time provides integrity and recoverability guarantee for subsequent data analysis; the data is analyzed by pairing based on the detailed information of the operation instruction, so as to identify the resource leakage type and leakage reason, and further can mine the reference relationship between the resource leakage objects, facilitate to find the objects with root problems, so as to realize resource leakage monitoring.
[0024] Further, the step S2 further comprises:
[0025] If the detailed information fails to be written to the disk, the write-to-disk failure data is returned to the buffer by executing the callback function, the write-to-disk failure data is processed by the buffer, and the detailed information is re-written to the disk.
[0026] From the above description, the callback function is executed to cope with the data write failure, an error handling mechanism is provided, the write operation can be properly handled when problems are encountered, the system fault tolerance is improved, at the same time, the data is re-written to the disk, which helps to prevent data loss and ensure data integrity and persistent storage.
[0027] Further, the step S1 further comprises:
[0028] The system is initialized, and the operation instruction is listened to, wherein the initialization operation comprises setting a time threshold, and setting a callback function for the buffer.
[0029] From the above description, when initializing the system, the time threshold is set, the data writing time is flexibly controlled to meet different task requirements, the disk I / O operation is optimized, and the disk I / O efficiency is improved; the callback function is set for the buffer area, the decoupling between modules is realized, and the subsequent asynchronous thread writes data to the disk.
[0030] Further, the type name and reference chain in the custom information according to the detailed information are analyzed to obtain related information of the resource leakage, including:
[0031] The object corresponding to the type name in the custom information is counted by means of the SQL statement, and it is judged whether there is a resource abuse situation;
[0032] Based on the reference chain in the custom information, the "reference chain" relationship is analyzed by means of the SQL statement, and the reference relationship between the objects with problems is mined.
[0033] From the above description, different fields are expanded for different types of leakage, the custom information is used to better count the hot problems of leakage, and targeted solutions are provided, and the reference chain field is added, the SQL statement is used for statistical analysis, and the reference relationship between the objects with problems is mined, so that the objects with root problems can be found, and other objects with reference relationship can be found, and all resource leakage problems can be solved.
[0034] Further, the step S3 further includes:
[0035] The analysis result is obtained, the final analysis result is shown to the user by means of SQL query and data processing on the analysis result.
[0036] From the above description, by providing interface support, the user can use the custom SQL statement to flexibly and multidimensionally count and analyze the analysis result, view the graphical analysis result, enhance the user interaction experience, and provide the SQL statement template, facilitate the user to imitate and migrate to the own analysis work, the system function is simple and easy to use.
[0037] Please refer to Figure 2 Another embodiment of the application provides a resource leakage monitoring terminal, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements each step of the above-mentioned resource leakage method when executing the computer program.
[0038] The above-mentioned resource leakage monitoring method and terminal of the application are suitable for identifying resource leakage causes and solving resource leakage, which will be described in detail in the following embodiments:
[0039] Embodiment one
[0040] Referring to Figure 1 A resource leakage monitoring method, comprising the steps of:
[0041] S1, according to the operation instruction, record the detailed information of the operation instruction, format conversion and add to the buffer, the detailed information includes general information and custom information, the general information includes operation type, the custom information includes type name, reference chain.
[0042] In this embodiment, according to the operation instruction, the detailed information of the operation instruction is recorded, which ensures that all related information is captured and saved, and provides complete information basis for subsequent data analysis and processing; the detailed information is converted and formatted, so as to ensure that the format is simple and universal, so as to optimize the storage space and improve the data processing efficiency, and reduce the system resource overhead; at the same time, the detailed information after conversion is stored in the buffer, realizing fast data access and processing, and the detailed information is divided into general information and custom information, providing flexible data processing mechanism to adapt to different application scenarios.
[0043] Before step S1, it also includes initializing system and listening operation instruction, wherein, the initialization operation includes setting time threshold, setting callback function for buffer, flexibly controlling disk writing time to meet different task requirements, optimizing disk I / O operation, improving disk I / O efficiency, setting callback function for buffer, allowing system to automatically trigger data writing disk operation when reaching certain conditions, realizing decoupling between modules, so that subsequent asynchronous thread can obtain data and reduce the burden of main thread.
[0044] S2, if the disk writing time reaches the time threshold or the capacity of the buffer reaches the capacity threshold, the detailed information is written into the disk by executing the callback function.
[0045] In this embodiment, by setting the time threshold and the capacity threshold, the frequency and quantity of data writing to the disk are effectively controlled, the performance degradation caused by frequent disk operation is avoided, the integrity and recoverability of data are ensured, and the accuracy and reliability of subsequent data analysis are improved; the callback function is executed, the detailed information is written into the disk by using asynchronous processing mode, the main thread is avoided to be blocked, and the overall performance is improved.
[0046] Further, step S2 further includes: if the detailed information fails to be written into the disk, the data failing to be written into the disk is returned to the buffer by executing the callback function, the buffer processes the data failing to be written into the disk and rewrites the detailed information into the disk, provides error processing mechanism, ensures that the writing operation can be properly processed when encountering problems, improves system fault tolerance, and rewrites the disk after the processing step is finished, which helps to prevent data loss and ensure data integrity and persistent storage.
[0047] S3, periodically reading disk data in an asynchronous loading manner, performing matching judgment according to the operation type in the general information of the detailed information, if there are unpaired "application" and "release" operation types, determining as potential resource leakage, and analyzing the associated information of the resource leakage according to the type name and reference chain in the custom information of the detailed information.
[0048] In the embodiment, the potential resource leakage is detected by matching recognition according to the operation type and the matching result, so as to identify the resource leakage type and the resource leakage reason. For example, the "ID" is used as the unique identifier of the resource, for the data of the same ID, if there are two pieces of data of "application" and "release" pairing, it means that the resource corresponding to the ID has been effectively released, and there will be no resource leakage problem; if there is only one piece of data of "application" and no data of "release", it means that the resource corresponding to the ID causes resource leakage, and resource leakage processing is needed.
[0049] In the embodiment, the associated information of the resource leakage is analyzed according to the type name and reference chain in the custom information of the detailed information, including: counting the objects corresponding to the type name in the custom information by means of SQL statement, and judging whether there is resource abuse; based on the reference chain in the custom information, the "reference chain" relationship is analyzed by means of SQL statement, the reference relationship between the objects with problems is mined, different fields are expanded for different types of leakage, such as: type name, object name, reference chain, all related references, etc., so as to mine a series of other objects referenced behind the object according to the reference chain, which is beneficial to better count the resource leakage problem and solve it specifically. In addition, the fields of physical memory overhead, object and sub-object material memory overhead, display memory overhead, object and sub-object display memory overhead can be added, and further from multiple angles, the various overheads of memory and display are recorded, so as to facilitate resource management and improve system performance.
[0050] Further, the step S3 further includes: obtaining the analysis result, and showing the final analysis result to the user by means of SQL query and data processing on the analysis result, and the system provides interface support to allow the user to use the custom SQL statement for flexible and multi-dimensional statistics and analysis. Even for the same database table that has been recorded, different SQL statements can be written to perform different dimension statistics, so that the data can be analyzed from different angles, and the system applicability and flexibility are improved, so as to adapt to different needs and occasions.
[0051] Embodiment two
[0052] Please refer to Figure 3 andFigure 4 , Figure 3 is a whole flow chart of a resource leakage monitoring method, Figure 4 is a class diagram of a resource leakage monitoring method, in Figure 1 Based on the embodiment shown in the figure, the embodiment gives a resource leakage monitoring method applied to monitor game resource leakage, taking an Unreal game as an example, and the steps include:
[0053] Step one, initialize the system and listen to operation instructions, wherein the initialization operation includes setting a time threshold, setting a callback function for the buffer area.
[0054] In this embodiment, the Init method in the LeakLogger class is called when the game starts, which is executed only once in the entire application lifecycle, sets appropriate permissions for the process to access system-level resource information, initializes the SQLite database environment for data storage, and initializes the underlying modules in the system, including setting the time threshold, setting the callback function for multiple underlying modules, thereby decoupling between modules to facilitate subsequent asynchronous threads to obtain data and reduce the burden on the main thread. In addition, the RegisterWithDispatch method is used to register LeakLogger in the system dispatcher to facilitate the reception of resource application or release operation instructions.
[0055] Step two, record the detailed information of the operation instruction according to the operation instruction, format convert the detailed information and add it to the buffer area, the detailed information includes general information and custom information, the general information includes operation type, the custom information includes type name, reference chain.
[0056] In this embodiment, when the game triggers resource application and release operations, Figure 3 the LeakLogger class in the figure responds to the operation, and the LeakLogger class encapsulates the atomic operation information recording function, according to different parameter values, through the AddLog function to record the detailed information of the atomic operation, such as the parameter value is "true", indicating the resource "application" operation, the parameter value is "flase" indicating the resource "release operation", recording the allocated memory size, timestamp, code call stack and other information, ensuring that all related information is captured and saved, providing a complete information basis for subsequent data analysis and processing, executing the ResourceRecord class to create a resource record instance, and storing the detailed information as a formatted dictionary through the ToDictionary function, thereby ensuring that the format is simple and general, and temporarily storing it to the memory buffer area through the AddToBuffer function of the BufferManager class, so as to facilitate subsequent fast access and processing of data.
[0057] Step three, if the disk write time reaches the time threshold or the capacity of the buffer reaches the capacity threshold, write the detailed information to the disk by executing the callback function.
[0058] In this embodiment, BufferManager triggers FlushBuffer method according to the time threshold set by SetWriteInterval method, such as every 30 milliseconds, or the capacity threshold of the buffer, such as 100 records, executes the callback function, calls WriteData function of PersistentStorage through asynchronous thread, writes the detailed information to the database file of the disk, avoids blocking the main thread, and reduces the impact on game performance.
[0059] Step four, if the detailed information fails to be written to the disk, return the write-to-disk failure data to the buffer by executing the callback function, process the write-to-disk failure data by the buffer, and re-write the detailed information to the disk.
[0060] In this embodiment, if the data write fails, PersistentStorage executes the callback function sent by the upper LeakLogger class in advance, thereby indirectly feeding back the error to BufferManager, and BufferManager processes the write-to-disk failure data and re-executes the WriteData function of PersistentStorage class to write the data to the disk, provides an error handling mechanism, ensures that the write operation is properly handled when problems are encountered, improves the system fault tolerance, helps to prevent data loss, and ensures data integrity and persistent storage.
[0061] Step five, periodically read the disk data in an asynchronous loading manner, perform pairing judgment according to the operation type in the general information of the detailed information, if there are unpaired “application” and “release” operation types, determine that it is a potential resource leak, and analyze the associated information of the resource leak according to the type name and reference chain in the custom information of the detailed information.
[0062] In the embodiment, the DataReader reads data from the disk periodically and loads asynchronously through the ReadDataAsync method, ensuring that the main program is not blocked, and the data is passed to the LeakDetector for data analysis to identify resource leakage patterns after the data loading is completed. The LeakDetector identifies "leakage" issues based on "application" and "release" operations. For example, using "ID" as a unique identifier for resources, if there are two data pairs of "application" and "release" for the same ID, it means that the resource corresponding to the ID has been effectively released and will not cause resource leakage. If there is only one "application" data and no "release" data, it means that the resource corresponding to the ID causes resource leakage and needs to be handled.
[0063] In the embodiment, the associated information of the resource leakage is analyzed according to the type name and reference chain in the custom information of the detailed information, including: counting the objects corresponding to the type name in the custom information by means of SQL statements to determine whether there is a resource abuse situation; based on the reference chain in the custom information, using SQL statements to analyze the "reference chain" relationship, and mining the reference relationship between the objects with problems, and extending different fields for different types of leakage, such as: type name, object name, reference chain, all related references, etc. to facilitate mining a series of other objects behind the reference of the object according to the reference chain, which is beneficial to better statistics of resource leakage problems and targeted solutions. In addition, fields such as physical memory overhead, object and sub-object material memory overhead, video memory overhead, object and sub-object video memory overhead can be added to further record various overheads in terms of memory and video memory from multiple angles to facilitate resource management and improve system performance.
[0064] In some embodiments, the SQL statements can be used to further analyze the "reference chain" and "external object chain" relationships from the following four angles:
[0065] 1. Parent-child relationship: sort the data according to the type and name in the external object chain field to identify which type of resource or object is most frequently used as a parent object of other objects;
[0066] 2. Reference relationship: sort the data according to the all related references field to analyze the highest frequency reference relationship and display the objects most commonly involved in the reference chain;
[0067] 3. Reference frequency: sort the data according to the all related references field to count the objects with the most reference times to identify the specific objects of the leaked resources;
[0068] 4. Frame load: According to the frame number field, the data is sorted, and the top 10 frames with the most records are displayed to determine the frames that cause stuttering, request a large number of resources, or even exhaust resources.
[0069] Step six, obtain the analysis result, and show the final analysis result to the user by performing SQL query and data processing on the analysis result.
[0070] In this embodiment, LeakDetector obtains data and performs analysis by executing the GetRecord method, SqlExecutor obtains the analysis result from LeakDetector, SqlExecutor performs SQL statement execution, query and data processing tasks by executing the ExecuteSQL method, and provides sorting, statistics and paging functions, UIDisplay obtains the data processed by the SQL statement from SqlExecutor, and executes the DisplayData method to display the analysis result to the user in the form of a graphical interface, provides a user interface to support user interaction, allows the user to select different SQL files to execute different statistical instructions, and further enhances the practicality and interactivity of the system.
[0071] Embodiment three
[0072] Please refer to Figure 2 A resource leakage monitoring terminal 1, comprising a memory 2, a processor 3, and a computer program stored on the memory 2 and executable on the processor 3, wherein the processor 3 implements each step of the resource leakage monitoring method of embodiment one when executing the computer program.
[0073] In summary, the application provides a resource leakage monitoring method and terminal. According to the operation instruction, detailed information of the operation instruction is recorded, and all related information is captured and saved, thereby providing a complete information basis for subsequent data analysis and processing. The detailed information is formatted and converted and added to a buffer, thereby ensuring simple and universal format, optimizing storage space and improving data processing efficiency, and reducing system resource overhead. The system is initialized, the operation instruction is monitored, a time threshold is set, the disk writing time is flexibly controlled to meet different task requirements, a callback function is set for the buffer to allow the system to automatically trigger data writing to the disk operation when a specific condition is reached, the modules are decoupled to facilitate subsequent asynchronous threads to obtain data and reduce the burden of the main thread. The data writing to the disk frequency and quantity are controlled according to the time threshold or the capacity threshold to avoid performance degradation caused by frequent disk operations, ensure data integrity and recoverability, and improve the accuracy and reliability of subsequent data analysis. If data writing to the disk fails, the callback function is executed to return the data writing to the disk failure data to the buffer, the buffer processes the data writing to the disk failure data, and the detailed information is written to the disk again, thereby providing an error processing mechanism, ensuring that the writing operation can be properly processed when problems occur, improving system fault tolerance, and re-writing to the disk after the processing step is completed, which helps to prevent data loss, ensures data integrity and persistent storage. Through asynchronous loading and periodic analysis of disk data, matching recognition is performed according to the operation type, and potential resource leakage detection is realized according to the matching result, thereby identifying resource leakage types and resource leakage reasons. According to the type name and reference chain in the custom information of the detailed information, the associated information of the resource leakage is analyzed, including: using SQL statements to count the objects corresponding to the type name in the custom information to determine whether there is resource abuse; based on the reference chain in the custom information, using SQL statements to analyze the "reference chain" relationship to mine the reference relationship between the objects with problems, and extending different fields for different types of leakage to facilitate mining of a series of other objects referenced behind the objects according to the reference chain, which is beneficial to better statistics and targeted solutions of resource leakage problems; obtaining the analysis result, performing SQL query and data processing on the analysis result, and showing the final analysis result to the user, the system provides interface support, allows the user to use custom SQL statements for flexible and multi-dimensional statistics and analysis, improves system applicability and flexibility, and is suitable for different requirements and occasions.
[0074] Therefore, the embodiments of the present application can realize the following beneficial effects: by separating the data recording and analysis links, using multi-thread technology for data writing operation, running the analysis link independently of the main program, avoiding preempting hardware resources and competing for monitored program resources, reducing resource overhead and system crash risk, and the system performance and stability are more optimal; the data recording link helps to prevent data loss, ensure data persistent storage, and protect data integrity and recoverability by writing data to the disk in time; using Sqlite as the data storage solution can meet the use in various programming environments and operating systems, thereby realizing cross-platform and cross-language, and the read-write timing and handle life cycle can be flexibly controlled, and the disk I / O efficiency is high; the data analysis link allows users to use custom SQL statements for flexible and multi-dimensional statistics and analysis, thereby the data can be analyzed from different angles, improving data scalability and flexibility, and supporting monitoring of various resource leakage types to adapt to different needs and occasions; interface support is provided to facilitate users to view graphical analysis results, enhance user interaction experience, and provide SQL statement templates to facilitate users to imitate and migrate to their own analysis work, the system function is simple and easy to use; in addition, the data storage format of the present application is compatible with the analysis scheme commonly used in artificial intelligence, facilitating the introduction of AI technology for higher-level data analysis and early warning, and improving the ability to mine and solve resource leakage problems.
[0075] The above description is only an embodiment of the present application, and does not limit the patent scope of the present application, and any equivalent transformation or direct or indirect application in related technical fields using the content of the present application specification and drawings is also included in the patent protection scope of the present application.
Claims
1. A resource leak monitoring method characterized by, The method comprises the steps of: S1, recording detailed information of the operation instruction according to the operation instruction, and adding the detailed information to a buffer after format conversion, wherein the detailed information comprises general information and custom information, the general information comprises an operation type, and the custom information comprises a type name and a reference chain; S2, if a disk writing time reaches a time threshold or a capacity of the buffer reaches a capacity threshold, writing the detailed information to the disk by executing a callback function; S3, periodically reading disk data in an asynchronous loading mode, performing pairing judgment according to the operation type in the general information of the detailed information, determining a potential resource leakage if there are unpaired "application" and "release" operation types, and analyzing associated information of the resource leakage according to the type name and the reference chain in the custom information of the detailed information; The step S2 further comprises: if the detailed information fails to be written to the disk, returning writing-disk-failure data to the buffer by executing the callback function, processing the writing-disk-failure data by the buffer, and re-writing the detailed information to the disk; The method further comprises the steps of: initializing a system and listening to operation instructions, wherein the initialization operation comprises setting a time threshold and setting a callback function for the buffer; analyzing the associated information of the resource leakage according to the type name and the reference chain in the custom information of the detailed information, comprising: counting objects corresponding to the type name in the custom information by means of a SQL statement, and determining whether there is a resource abuse situation; analyzing a "reference chain" relationship by means of a SQL statement based on the reference chain in the custom information, and mining a reference relationship between objects with problems; The method further comprises the steps of: obtaining an analysis result, and showing a final analysis result to a user by performing SQL query and data processing on the analysis result.
2. A resource leak monitoring terminal comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the following steps when executing the computer program: S1, recording detailed information of the operation instruction according to the operation instruction, and adding the detailed information to a buffer after format conversion, wherein the detailed information comprises general information and custom information, the general information comprises an operation type, and the custom information comprises a type name and a reference chain; S2, if a disk writing time reaches a time threshold or a capacity of the buffer reaches a capacity threshold, writing the detailed information to the disk by executing a callback function; S3, periodically reading disk data in an asynchronous loading mode, performing pairing judgment according to the operation type in the general information of the detailed information, determining a potential resource leakage if there are unpaired "application" and "release" operation types, and analyzing associated information of the resource leakage according to the type name and the reference chain in the custom information of the detailed information; The step S2 further comprises: if the detailed information fails to be written to the disk, returning writing-disk-failure data to the buffer by executing the callback function, processing the writing-disk-failure data by the buffer, and re-writing the detailed information to the disk; The method further comprises the steps of: initializing a system and listening to operation instructions, wherein the initialization operation comprises setting a time threshold and setting a callback function for the buffer; Initialize the system to listen to operation instructions, wherein the initialization operation includes setting a time threshold and setting a callback function for a buffer; According to the type name and the reference chain in the custom information of the detailed information, analyze the associated information of the resource leakage, including: With the help of SQL statements, count the objects corresponding to the type name in the custom information, and determine whether there is a resource abuse situation; Based on the reference chain in the custom information, use SQL statements to analyze the "reference chain" relationship, and mine the reference relationship between the objects with problems; The step S3 further includes: Obtain the analysis result, perform SQL query and data processing on the analysis result, and show the final analysis result to the user.
Citation Information
Patent Citations
Mobile terminal TCP communication method and device, equipment and storage medium
CN113645308A
Memory leak detection method and device, equipment and storage medium
CN116610569A