Data analysis method and related device

By obtaining and analyzing memory snapshots of the target program and positioning the reference path of the memory leaked object, the problem of low efficiency of memory leak analysis in Internet games is solved, and precise positioning and efficiency improvement is achieved.

CN120386706APending Publication Date: 2025-07-29TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410101147.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-24
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

During the upgrade of the Internet game version, it is difficult for the existing technology to accurately locate the causes of memory leakage, resulting in inefficient memory leakage analysis.

Method used

By obtaining the first memory snapshot and the second memory snapshot of the target program, analyzing the reference path of the target object, sending the corresponding relationship between the target object and the reference path, accurately locate the cause of the memory leakage.

Benefits of technology

It reduces the memory leak analysis workload of technicians, realizes accurate positioning of the causes of memory leaks, and improves the efficiency of memory leak analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120386706A_ABST
    Figure CN120386706A_ABST
Patent Text Reader

Abstract

The invention provides a data analysis method and a related device. The embodiment of the invention can be applied to the technical field of data storage. The method comprises the steps that a first memory snapshot of a target program and a second memory snapshot of the target program are obtained, the first memory snapshot and the second memory snapshot are analyzed to obtain a target object, and the target object is an object with memory leakage in the target program; the reference path of the target object is obtained, the reference path of the target object comprises all references of the target object when the target object is added to the target class of the target program, and the corresponding relation between the target object and the reference path is sent. The technical personnel do not need to check the class to which the target object belongs, so that the memory leak analysis workload of the technical personnel is reduced, the accurate positioning of the occurrence reason of the memory leak is realized, and the memory leak analysis efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data storage, and in particular, to a method for data analysis and related devices. Background Art

[0002] With the continuous development of Internet games, the scenes and characters in Internet games are constantly updated. When the version of an Internet game is upgraded, the workload required for game performance acceptance also increases day by day.

[0003] Conventional game performance acceptance includes memory leak analysis based on a memory report (memreport). Memory leak is the failure of a program to uninstall due to improper memory management of a computer program, that is, the program continues to occupy memory space that is no longer in use. When performing memory leak analysis, it is possible to check for memory leaks by comparing two memreport snapshots.

[0004] However, in the analysis of memory leaks, only the name of the object where the memory leak occurs and the amount of memory occupied by the object with the memory leak are provided. Since the same object may be referenced in multiple classes, it takes a lot of time and manpower to locate the object with the memory leak one by one. On this basis, how to further accurately locate the cause of the memory leak has become an urgent problem to be solved. Summary of the Invention

[0005] Embodiments of this application provide a method for data analysis and related devices, which are used to accurately locate the cause of memory leaks and improve the efficiency of memory leak analysis.

[0006] The first aspect of this application provides a method for data analysis, including:

[0007] Obtain a first memory snapshot of a target program and a second memory snapshot of the target program, where the acquisition time of the first memory snapshot is before the acquisition time of the second memory snapshot;

[0008] Analyze the objects with memory leaks in the target program according to the first memory snapshot and the second memory snapshot to obtain target objects. The target objects are included in the second memory snapshot and not included in the first memory snapshot, or the first memory capacity of the target object is less than the second memory capacity of the target object. The first memory capacity is the memory capacity occupied by the target object in the first memory snapshot, and the second memory capacity is the memory capacity occupied by the target object in the second memory snapshot. The class corresponding to the target object is the target class;

[0009] Obtain the reference path of the target object. The reference path of the target object includes all references to the target object when the target object is added to the target class;

[0010] Send the correspondence between the target object and the reference path of the target object.

[0011] The second aspect of this application provides a data analysis device, including:

[0012] An acquisition unit, configured to acquire a first memory snapshot of a target program and a second memory snapshot of the target program, where the acquisition moment of the first memory snapshot is before the acquisition moment of the second memory snapshot;

[0013] An analysis unit, configured to analyze the objects with memory leaks in the target program according to the first memory snapshot and the second memory snapshot, obtain target objects, where the target objects are included in the second memory snapshot and not included in the first memory snapshot, or, the first memory capacity of the target object is less than the second memory capacity of the target object, the first memory capacity is the memory capacity occupied by the target object in the first memory snapshot, the second memory capacity is the memory capacity occupied by the target object in the second memory snapshot, and the class corresponding to the target object is the target class;

[0014] The acquisition unit is further configured to acquire the reference path of the target object, and the reference path of the target object includes all references to the target object when the target object is added to the target class;

[0015] A sending unit, configured to send the correspondence between the target object and the reference path of the target object.

[0016] In a possible implementation manner of the second aspect, the analysis unit is specifically configured to:

[0017] When the first class name is included in the first memory snapshot and the first object name is not included in the first memory snapshot, determine that the object corresponding to the first object name is the target object, the first class name is the class name in the second memory snapshot, the first object name is the object name in the second memory snapshot, and the first object name is associated with the first class name;

[0018] When the first class name is included in the first memory snapshot, the first object name is included in the first memory snapshot, and the fourth memory capacity is less than the third memory capacity, determine that the object corresponding to the first object name is the target object, the third memory capacity is the memory capacity of the first object in the second memory snapshot, the fourth memory is the memory capacity of the first object in the first memory snapshot, and the first object is the object corresponding to the first object name;

[0019] When the first class name is included in the second memory snapshot and the first class name is not included in the first memory snapshot, determine that the third object is the target object, the third object is included in the second memory snapshot, the class corresponding to the third object is the first class, and the first class is the class corresponding to the first class name.

[0020] In a possible implementation manner of the second aspect, the acquisition unit is specifically configured to:

[0021] When the first type of name is included in the first memory snapshot, and the first object name is included in the first memory snapshot, and the fourth memory capacity is less than the third memory capacity, search for the name of the target object to obtain the reference path of the target object;

[0022] The apparatus further includes a generating unit, configured to generate a correspondence between the target object and a first identifier, where the first identifier is used to identify that the target object is an object with an increased memory capacity.

[0023] In a possible implementation manner of the second aspect, the obtaining unit is specifically configured to generate a reference path of the target object when the first type of name is included in the first memory snapshot and the first object name is not included in the first memory snapshot, or when the first type of name is included in the second memory snapshot and the first type of name is not included in the first memory snapshot;

[0024] The apparatus further includes a generating unit, configured to generate a correspondence between the target object and a second identifier, where the second identifier is used to indicate that the target object is a newly added object.

[0025] In a possible implementation manner of the second aspect, the time interval between the acquisition time of the first memory snapshot and the acquisition time of the second memory snapshot is a first duration.

[0026] In a possible implementation manner of the second aspect, the obtaining unit is further configured to obtain a third memory snapshot of the target program, where the time interval between the acquisition time of the third memory snapshot and the acquisition time of the first memory snapshot is a first duration.

[0027] In a possible implementation manner of the second aspect, the analysis unit is further configured to:

[0028] When the first type of name is included in the second memory snapshot, and the first object name is included in the first memory snapshot, and the third memory capacity is equal to the fourth memory capacity, generate a correspondence between the first object and a third identifier, where the third identifier is used to indicate that the first object is an object with an unchanged memory capacity;

[0029] When the first type of name is included in the second memory snapshot, and the first object name is included in the first memory snapshot, and the fourth memory capacity is greater than the third memory capacity, generate a correspondence between the first object and a fourth identifier, where the fourth identifier is used to indicate that the first object is an object with a decreased memory capacity.

[0030] A third aspect of the present application provides a computer device, including:

[0031] A memory, a transceiver, a processor, and a bus system;

[0032] Wherein, the memory is used to store a program;

[0033] The processor is used to execute programs in the memory, including executing the methods of the above aspects;

[0034] The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.

[0035] The fourth aspect of this application provides a computer-readable storage medium, in which instructions are stored. When it runs on a computer, it enables the computer to execute the methods of the above aspects.

[0036] The fifth aspect of this application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the above aspects.

[0037] From the above technical solutions, it can be seen that the embodiments of this application have the following advantages:

[0038] This application provides a method for data analysis and related devices, which can obtain the first memory snapshot of a target program and the second memory snapshot of the target program, analyze the first memory snapshot and the second memory snapshot to obtain a target object, where the target object is an object that has a memory leak in the target program; obtain the reference path of the target object. The reference path of the target object includes all references to the target object when the target object is added to the target class of the target program, and send the correspondence between the target object and the reference path. This enables technicians to avoid checking the class to which the target object belongs, thereby reducing the workload of technicians for memory leak analysis, achieving accurate positioning of the cause of memory leaks, and improving the efficiency of memory leak analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a schematic diagram of an architecture of a data analysis system provided by an embodiment of this application;

[0040] Figure 2 It is a schematic flowchart of a method for data analysis provided by an embodiment of this application;

[0041] Figure 3 It is a schematic diagram of a method for obtaining a memory snapshot provided by an embodiment of this application;

[0042] Figure 4 It is a schematic diagram of a method for analyzing a memory snapshot provided by an embodiment of this application;

[0043] Figure 5Another schematic diagram of the method for analyzing memory snapshots provided by the embodiments of the present application;

[0044] Figure 6 A schematic diagram of the method for obtaining reference paths provided by the embodiments of the present application;

[0045] Figure 7a A schematic diagram of the method for memory leak analysis provided by the embodiments of the present application;

[0046] Figure 7b Another schematic diagram of the method for memory leak analysis provided by the embodiments of the present application;

[0047] Figure 8 A schematic diagram of newly added objects in the code provided by the embodiments of the present application;

[0048] Figure 9a A schematic diagram of the memory leak schematic provided by the embodiments of the present application;

[0049] Figure 9b Another schematic diagram of the memory leak schematic provided by the embodiments of the present application;

[0050] Figure 10 A schematic structural diagram of the data analysis device provided by the embodiments of the present application;

[0051] Figure 11 Another schematic structural diagram of the data analysis device provided by the embodiments of the present application;

[0052] Figure 12 A schematic structural diagram of the server provided by the embodiments of the present application. Detailed implementation manners

[0053] The embodiments of the present application provide a data analysis method for accurately locating the cause of memory leaks and improving the efficiency of memory leak analysis.

[0054] The terms "first", "second", "third", "fourth", etc. (if any) in the specification, claims and above-mentioned drawings of the present application are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "corresponding to" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those clearly listed steps or units, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0055] To facilitate the understanding of the technical solutions provided by the embodiments of the present application, some key terms used in the embodiments of the present application are explained here:

[0056] Memory leak: It is a type of resource leak in a computer. The main reason is the improper memory management of a computer program, resulting in the loss of control over an allocated memory space. The program continues to occupy the memory space that is no longer in use, or the objects stored in the memory cannot be accessed through the executable code, causing the memory resources to be wasted.

[0057] UE4 (Unreal Engine 4) is a powerful game engine developed by Epic Games. It provides rich functions and tools and is suitable for various types of game development, virtual reality, and real-time visualization projects. Its flexibility and cross-platform support enable developers to create high-quality and engaging game experiences. It is widely used in game development, virtual reality (VR), augmented reality (AR), and real-time visualization and other fields.

[0058] MemReport is a memory analysis report provided by UE4, which includes the total memory usage, object list and memory usage, the number of Actors and information, etc. MemReport can be used to count the memory and check for memory leaks.

[0059] With the continuous development of Internet games, the scenes and characters in Internet games are constantly updated. When the version of an Internet game is upgraded, the workload required for game performance acceptance also increases day by day. When conducting game performance acceptance, memory leak analysis needs to be carried out based on the memreport provided by UE4. Since memreport can count the total memory usage of objects, the object list, and the memory usage of the target program, etc. When conducting memory leak analysis, it is possible to check for memory leaks by comparing two memreport snapshots.

[0060] In the current memory leak analysis, after analyzing two memreports of the target program, it is found that object A has a memory leak, and the memory capacity occupied by object A is memory capacity B. In the target program, multiple different classes can call object A simultaneously. Therefore, object A may have different reference paths in class A and class B. In the case of only knowing that object A has a memory leak, it is necessary to check the reference paths of object A in class A and class B in turn to know the specific reason for the memory leak. When the target program includes multiple different classes, the difficulty of locating the specific reason for the memory leak will increase exponentially, and the time required for technical personnel to locate the specific reason for the memory leak will also increase exponentially.

[0061] How to accurately locate the cause of memory leakage has become an urgent problem to be solved at present.

[0062] In view of the above problems, this application proposes that a first memory snapshot of the target program and a second memory snapshot of the target program can be obtained, and the target object is obtained by analyzing the first memory snapshot and the second memory snapshot. The target object is the object that causes memory leakage in the target program; obtain the reference path of the target object, where the reference path of the target object includes all references to the target object when the target object is added to the target class of the target program, and send the correspondence between the target object and the reference path. This enables technicians to avoid checking the class to which the target object belongs, thereby reducing the workload of technicians for memory leakage analysis, achieving accurate positioning of the cause of memory leakage, and improving the efficiency of memory leakage analysis.

[0063] For easy understanding, please refer to Figure 1 , Figure 1 which is an application environment diagram of the data analysis method in the embodiments of this application. As Figure 1 shown, the data analysis method in the embodiments of this application is applied to a data analysis system. The data analysis system includes: a server and a terminal device; among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. The terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal and the server can be directly or indirectly connected through wired or wireless communication methods, and this application does not make any restrictions in this regard.

[0064] The server first obtains a first memory snapshot of the target program and a second memory snapshot of the target program. The acquisition time of the first memory snapshot is before the acquisition time of the second memory snapshot;

[0065] Analyze the target object in the target program according to the first memory snapshot and the second memory snapshot. The target object is the object that causes memory leakage in the target program. The target object is included in the second memory snapshot and not included in the first memory snapshot, or the first memory capacity of the target object is less than the second memory capacity of the target object. The first memory capacity is the memory capacity occupied by the target object in the first memory snapshot, and the second memory capacity is the memory capacity occupied by the target object in the second memory snapshot;

[0066] Obtain the reference path of the target object. The reference path of the target object includes all references to the target object when the target object is added to the target class of the target program.

[0067] Send the correspondence between the target object and the reference path.

[0068] Next, from the perspective of the server, the method of data analysis in this application will be introduced. Please refer to Figure 2 , the method of data analysis provided by the embodiments of this application includes: step S110 to step S150. Specifically:

[0069] S110. Obtain a first memory snapshot of the target program and a second memory snapshot of the target program;

[0070] Among them, the acquisition moment of the first memory snapshot is before the acquisition moment of the second memory snapshot, and the time interval between the acquisition moment of the first memory snapshot and the acquisition moment of the second memory snapshot is the first duration.

[0071] Exemplarily, the first duration can be 90s, which is not limited here.

[0072] In the embodiments of this application, technicians can set the first duration according to requirements to control the analysis intensity of the memory leak analysis of the target program, improving the flexibility of the solution.

[0073] Exemplarily, the execution process of obtaining the first memory snapshot and the second memory snapshot can be as Figure 3 shown.

[0074] First, execute the first snapshot instruction to obtain the first memory snapshot, and execute the second snapshot instruction to obtain the second memory snapshot. Among them, the first snapshot instruction is "memoryprofiler-NOREF-FULL-FIRST", and the second snapshot instruction is "memoryprofiler-REF-FULL-SECOND".

[0075] Then, after obtaining the first memory snapshot and the second memory snapshot, execute the process snapshot instruction to name the file of the first memory snapshot and the file of the second memory snapshot. For example, the first memory snapshot is named "2023 / 08 / 28_FIRST.mem", and the second memory snapshot is named "2023 / 08 / 28_SECOND.mem". Among them, the process snapshot instruction is "HandleMemoryProfilerCommand".

[0076] After that, execute the create file name instruction to create the file of the first memory snapshot and the file of the second memory snapshot according to the file name. Among them, the create file name instruction is "CreateProfileFilename".

[0077] Finally, execute the snapshot print output instruction to implement the print output of the objects in the snapshot. Among them, the snapshot print output instruction is "memoryreport - full".

[0078] It can be understood that the description of the specific operation methods for obtaining the first memory snapshot and the second memory snapshot here is only an example. In actual applications, it should be set according to the specific scenario to achieve the acquisition of the first memory snapshot and the second memory snapshot. The specific acquisition method is not limited here.

[0079] S120. Analyze the objects with memory leaks in the target program based on the first memory snapshot and the second memory snapshot to obtain the target objects;

[0080] After obtaining the first memory snapshot and the second memory snapshot, analyze the objects with memory leaks in the target program based on the first memory snapshot and the second memory snapshot to obtain the target objects.

[0081] Among them, the target program objects are included in the second memory snapshot and not included in the first memory snapshot, or the first memory capacity of the target object is less than the second memory capacity of the target object. The first memory capacity is the memory capacity occupied by the target program object in the first memory snapshot, and the second memory capacity is the memory capacity occupied by the target object in the second memory snapshot. The class corresponding to the target object is the target class.

[0082] Exemplarily, the specific method of analyzing the objects with memory leaks in the target program based on the first memory snapshot and the second memory snapshot to obtain the target objects can be as Figure 4 and Figure 5 shown as follows:

[0083] First, Figure 4 the relevant class analysis is as follows:

[0084] Taking the first memory snapshot as the comparison file and analyzing the content in the second memory snapshot as an example for the following introduction:

[0085] After obtaining the first memory snapshot and the second memory snapshot, determine whether there is a first class name in the first memory snapshot, where the first class name is included in the second memory snapshot;

[0086] If there is a first class name in the first memory snapshot, execute the relevant object analysis as in Figure 5 to obtain the target objects.

[0087] And after completing the object analysis shown in Figure 5 mark the completion of the analysis of the objects corresponding to the first class.

[0088] When the first type of name does not exist in the first memory snapshot, mark the third object as the target object, generate the correspondence between the first type and the fifth identifier, and generate the correspondence between the target object and the second identifier. Herein, the third object is all the objects corresponding to the first type in the second memory snapshot, the first type is the class corresponding to the first type of name, the second identifier indicates that the target object is a newly added object, and the fifth identifier indicates that the first type is a newly added class in the target program.

[0089] Optionally, content related to the target object can also be added to the memory leak schematic diagram, which is not limited here.

[0090] Then, Figure 5 The object analysis related in

[0091] When the first type of name exists in both the first memory snapshot and the second memory snapshot, further analyze the object list corresponding to the first type.

[0092] Determine whether the first object name is included in the first memory snapshot, and the first object name is included in the second memory snapshot;

[0093] If the first object name is not included in the first memory snapshot, determine the first object as the target object, generate the correspondence between the target object and the second identifier, and the second identifier indicates that the target object is a newly added object, and the first object is the object corresponding to the first object name.

[0094] If the first object name is included in the first memory snapshot, determine whether the third memory capacity is the same as the fourth memory capacity. The third memory capacity is the memory capacity of the first object in the second memory snapshot, and the fourth memory capacity is the memory capacity of the first object in the first memory snapshot;

[0095] When the third memory capacity is the same as the fourth memory capacity, generate the correspondence between the first object and the third identifier, and the third identifier indicates that the first object is an object with an unchanged memory capacity.

[0096] When the third memory capacity is different from the fourth memory capacity, determine whether the third memory capacity is greater than the fourth memory capacity;

[0097] When the third memory capacity is greater than the fourth memory capacity, determine the first object as the target object, generate the correspondence between the target object and the first identifier, and the first identifier indicates that the target object is an object with an increased memory capacity;

[0098] When the third memory capacity is less than the fourth memory capacity, generate the correspondence between the first object and the fourth identifier, and the fourth identifier indicates that the first object is an object with a decreased memory capacity.

[0099] In the embodiments of the present application, new classes are determined by judging whether there are the same classes in the first memory snapshot as in the second memory snapshot; for non-new classes, further analysis is performed to judge whether there are objects that are included in the second memory snapshot but do not exist in the first memory snapshot among the classes that are the same in the first memory snapshot and the second memory snapshot, so as to determine new objects; for the classes that are the same in the first memory snapshot and the second memory snapshot and there are objects in both the first memory snapshot and the second memory snapshot, the capacity of the object in the first memory snapshot and the capacity of the object in the second memory snapshot are judged to determine the objects with increased memory capacity. This provides a reliable implementation method for efficiently realizing memory leak analysis and improves the reliability and real-time efficiency of the solution.

[0100] Optionally, according to the correspondence between the object and the identifier, the first object and the content related to the first object can be added to the memory leak schematic diagram, and there is no limitation here.

[0101] Optionally, the memory leak schematic diagram includes the memory capacity and the number of target objects, and there is no limitation here.

[0102] S130. Obtain the reference path of the target object;

[0103] After analyzing the objects with memory leaks in the target program based on the first memory snapshot and the second memory snapshot and obtaining the target object, the reference path of the target object is obtained. Among them, the reference path of the target object includes all references to the target object when the target object is added to the target class.

[0104] Exemplarily, according to the different correspondences between the target object and the identifier, there are two different situations for obtaining the reference path of the target object, which are specifically as follows:

[0105] Situation 1: When the target object is a new object, generate the reference path of the target object;

[0106] Please refer to Figure 6 , when the target object is a new object, perform reference path analysis on the target object, which is specifically as follows:

[0107] First, execute the instruction to create a reference chain object to implement reference stack acquisition. The instruction to create a reference chain object is "FreferenceChainSearch RefChainSearch(Object,SearchFlag)";

[0108] Then, execute the reference path printing instruction. The reference path printing instruction is "RefChainSearch".

[0109] In the embodiment of the present application, when the target object is a newly added object, the reference path of the target object is obtained by generation, and the reference path of the target object is accurately obtained, improving the reliability of the solution.

[0110] Case 2: When the target object is an object with an increased memory capacity, search for the target object to obtain the reference path of the target object.

[0111] When the target object is an object with an increased memory capacity, since the relevant reference path generation has been executed when the target object newly enters the target program, directly searching for the target object can obtain the reference path of the target object.

[0112] In the embodiment of the present application, when the target object is an object with an increased memory capacity, the reference path of the target object is obtained by searching, without repeated generation, saving storage space, thereby improving the storage utilization efficiency.

[0113] It can be understood that the description of obtaining the reference path of the target object here is only an example, and in actual applications, it should be set according to specific scenarios, and no limitation is made here.

[0114] Optionally, the reference path of the target object can also be added to the memory leak schematic diagram, and no limitation is made here.

[0115] S140. Send the correspondence between the target object and the reference path of the target object.

[0116] Optionally, since the target object and the reference path of the target object are included in the memory leak schematic diagram, sending the correspondence between the target object and the reference path of the target object can be achieved by sending the memory leak schematic diagram, and no limitation is made here.

[0117] In the embodiment of the present application, the first memory snapshot of the target program and the second memory snapshot of the target program are obtained, the target object is obtained by analyzing the first memory snapshot and the second memory snapshot, and the target object is an object with a memory leak in the target program; the reference path of the target object is obtained, where the reference path of the target object includes all references to the target object when the target object is added to the target class of the target program, and the correspondence between the target object and the reference path is sent. This enables technicians to avoid checking the class to which the target object belongs, thereby reducing the workload of memory leak analysis for technicians, achieving accurate positioning of the cause of memory leak, and improving the efficiency of memory leak analysis.

[0118] Optionally, the solution provided by the present application can also be applied to scenarios where continuous memory leak analysis is required. Therefore, after step S140, the solution provided by the present application can further include step S150, specifically:

[0119] S150. Obtain a third memory snapshot of the target program.

[0120] Among them, the time interval between the acquisition moment of the third memory snapshot and the acquisition moment of the second memory snapshot is the second duration. The second duration can be the same as or different from the first duration, and there is no limit here.

[0121] Here, an example where the first duration is the same as the second duration is used for introduction.

[0122] When continuous memory leak analysis needs to be performed, update the first memory snapshot to obtain the updated first memory snapshot, which is the same as the second memory snapshot; update the second memory snapshot to obtain the updated second memory snapshot, which is the same as the third memory snapshot. Perform operations similar to those on the first memory snapshot and the second memory snapshot in the aforementioned steps S110 to S140 on the updated first memory snapshot and the updated second memory snapshot, which will not be elaborated here.

[0123] Specifically, the specific method for continuous memory leak analysis is as Figure 7a shown:

[0124] At the moment when memory leak analysis starts to be performed on the target program, collect the memory snapshot of the target program to obtain the first memory snapshot (mark the target program, set ObjMark to true), and mark all objects in the first memory snapshot. For example, mark the objects in the first memory snapshot as "MarkAnnotation.set";

[0125] After the first duration, collect the memory snapshot of the target program again to obtain the second memory snapshot (perform Markcheck on the target program, set isObjMarkCheck to true). Compare the objects in the second memory snapshot with the objects marked with "MarkAnnotation.set" to obtain the objects that did not appear in the first memory snapshot. These objects are the objects with memory leaks in the target program.

[0126] And after the first duration after obtaining the second memory snapshot, repeat mark and markcheck. Thus, continuous memory leak detection is achieved.

[0127] In the embodiments of the present application, a scheme for automatically and continuously performing memory leak analysis is provided, enabling technicians to avoid repeated setting of memory leak analysis, reducing the workload of technicians, and improving the implementation efficiency of the scheme.

[0128] Combined with the method in the foregoing Figure 2 , the complete process including continuous memory leak analysis is as Figure 7bAs shown, the memory leak troubleshooting and analysis include, in sequence: memory snapshot acquisition, obtaining the leak point by comparing snapshots, performing reference chain analysis on the leak point, continuously acquiring the memory leak point and reporting the memory leak.

[0129] Exemplarily, the newly added objects can be as Figure 8 shown, the UNmarked (new) objects are ParticleSystemComponent and ActorChannel.

[0130] For ease of understanding, the following will be combined with Figure 9a to introduce the memory leak schematic diagram.

[0131] The memory leak schematic diagram includes: a list of newly added objects during memory leak.

[0132] The list of newly added objects includes the name of the target object, the size of the target object, the memory capacity occupied by the target object (ResExcSize), the memory capacity occupied by the target object in the dedicated video memory (VRAM) (ResExcDedVid), and the identifier (flag) corresponding to the target object.

[0133] Among them, ResExcSize represents the total memory occupied by allocation from the dedicated system, shared system memory, dedicated video memory, shared video memory, and other location points.

[0134] In Flag, there may be added and bigger, and in some possible application scenarios, it can also be smaller.

[0135] Optionally, in the memory leak schematic diagram, it can also include a list of newly added textures (texture list).

[0136] The list of newly added textures includes the texture name, texture format, texture width and height (WidthXHeight), texture size, and texture identifier (flag).

[0137] Among them, in the texture identifier, there may be added and bigger, and in some possible application scenarios, it can also be smaller.

[0138] The following will be combined with Figure 9b to introduce another possible memory leak schematic diagram.

[0139] The memory leak schematic diagram includes: the target object and the reference path of the target object. By Figure 9bIt can be known that when the target object is t_core_shapes_add, the reference path of the target object, where the reference path includes Bp_Rifle_SCAR_C:ShootWeaponEffect.

[0140] The device for data analysis in the present application will be described in detail below. Please refer to Figure 10 . Figure 10 FIG. is a schematic diagram of an embodiment of the device 10 for data analysis in an embodiment of the present application. The device 10 for data analysis includes:

[0141] An acquisition unit 110, configured to acquire a first memory snapshot of the target program and a second memory snapshot of the target program, where the acquisition time of the first memory snapshot is before the acquisition time of the second memory snapshot;

[0142] An analysis unit 120, configured to analyze the objects with memory leaks in the target program according to the first memory snapshot and the second memory snapshot to obtain target objects. The target objects are included in the second memory snapshot and not included in the first memory snapshot, or the first memory capacity of the target object is less than the second memory capacity of the target object. The first memory capacity is the memory capacity occupied by the target object in the first memory snapshot, and the second memory capacity is the memory capacity occupied by the target object in the second memory snapshot. The class corresponding to the target object is the target class;

[0143] The acquisition unit 110 is further configured to acquire the reference path of the target object. The reference path of the target object includes all references to the target object when the target object is added to the target class;

[0144] A sending unit 130, configured to send the correspondence between the target object and the reference path of the target object.

[0145] In an embodiment of the present application, a first memory snapshot of the target program and a second memory snapshot of the target program are acquired, the first memory snapshot and the second memory snapshot are analyzed to obtain target objects, and the target objects are objects with memory leaks in the target program; the reference path of the target object is acquired, where the reference path of the target object includes all references to the target object when the target object is added to the target class of the target program, and the correspondence between the target object and the reference path is sent. This enables technicians to avoid checking the class to which the target object belongs, thereby reducing the workload of memory leak analysis for technicians, achieving precise positioning of the cause of memory leaks, and improving the efficiency of memory leak analysis.

[0146] Optionally, the analysis unit 120 is specifically configured to:

[0147] When the first type name is included in the first memory snapshot and the first object name is not included in the first memory snapshot, determine that the object corresponding to the first object name is the target object, the first type name is the class name in the second memory snapshot, the first object name is the object name in the second memory snapshot, and the first object name is associated with the first type name;

[0148] When the first type name is included in the first memory snapshot, the first object name is included in the first memory snapshot, and the fourth memory capacity is less than the third memory capacity, determine that the object corresponding to the first object name is the target object, the third memory capacity is the memory capacity of the first object in the second memory snapshot, the fourth memory is the memory capacity of the first object in the first memory snapshot, and the first object is the object corresponding to the first object name;

[0149] When the first type name is included in the second memory snapshot and the first type name is not included in the first memory snapshot, determine that the third object is the target object, the third object is included in the second memory snapshot, the class corresponding to the third object is the first class, and the first class is the class corresponding to the first type name.

[0150] In the embodiments of the present application, by determining whether there is the same class in the first memory snapshot as in the second memory snapshot, the newly added class is determined; for non-newly added classes, further analysis is performed to determine whether there is an object that is included in the second memory snapshot but not in the first memory snapshot among the classes that are the same in the first memory snapshot and the second memory snapshot, to determine the newly added object; for the classes that are the same in the first memory snapshot and the second memory snapshot and there are objects in both the first memory snapshot and the second memory snapshot, the capacity of the object in the first memory snapshot and the capacity of the object in the second memory snapshot are compared to determine the object with an increased memory capacity. This provides a reliable implementation method for efficiently implementing memory leak analysis, improving the reliability and real-time efficiency of the solution.

[0151] In the Figure 10 corresponding embodiment of the data analysis device provided in the Figure 11 , the obtaining unit 110 is specifically configured to:

[0152] When the first type name is included in the first memory snapshot, the first object name is included in the first memory snapshot, and the fourth memory capacity is less than the third memory capacity, search for the name of the target object to obtain the reference path of the target object;

[0153] The device further includes a generating unit 140, configured to generate the correspondence between the target object and the first identifier, where the first identifier is used to identify that the target object is an object with an increased memory capacity.

[0154] In the embodiment of the present application, when the target object is an object with an increased memory capacity, the reference path of the target object is obtained by searching, without repeated generation, saving storage space, and thus improving the storage utilization efficiency.

[0155] Optionally, the obtaining unit 110 is specifically configured to generate a reference path of the target object when the first class name is included in the first memory snapshot and the first object name is not included in the first memory snapshot, or when the first class name is included in the second memory snapshot and the first class name is not included in the first memory snapshot;

[0156] The apparatus further includes a generating unit 140 for generating a correspondence between the target object and a second identifier, where the second identifier is used to indicate that the target object is a newly added object.

[0157] In the embodiment of the present application, when the target object is a newly added object, the reference path of the target object is obtained by generation, accurately obtaining the reference path of the target object and improving the reliability of the solution.

[0158] Optionally, the time interval between the acquisition time of the first memory snapshot and the acquisition time of the second memory snapshot is a first duration.

[0159] In the embodiment of the present application, a technician can set the first duration according to requirements to control the analysis intensity of the memory leak analysis of the target program, improving the flexibility of the solution.

[0160] Optionally, the obtaining unit 110 is further configured to obtain a third memory snapshot of the target program, where the time interval between the acquisition time of the third memory snapshot and the acquisition time of the first memory snapshot is the first duration.

[0161] In the embodiment of the present application, a solution for automatically and continuously executing the memory leak analysis is provided, enabling a technician to avoid repeatedly setting the memory leak analysis, reducing the workload of the technician, and improving the implementation efficiency of the solution.

[0162] Optionally, the analysis unit 120 is further configured to:

[0163] When the first class name is included in the second memory snapshot, the first object name is included in the first memory snapshot, and the third memory capacity is equal to the fourth memory capacity, generate a correspondence between the first object and a third identifier, where the third identifier is used to indicate that the first object is an object with an unchanged memory capacity;

[0164] When the first class name is included in the second memory snapshot, the first object name is included in the first memory snapshot, and the fourth memory capacity is greater than the third memory capacity, generate a correspondence between the first object and a fourth identifier, where the fourth identifier is used to indicate that the first object is an object with a reduced memory capacity.

[0165] Figure 12 This is a schematic diagram of a server structure provided by an embodiment of the present application. The server 300 may vary greatly due to different configurations or performances, and may include one or more central processing units (CPUs) 322 (for example, one or more processors) and a memory 332, and one or more storage media 330 for storing application programs 342 or data 344 (for example, one or more mass storage devices). Among them, the memory 332 and the storage media 330 may be transient storage or persistent storage. The program stored in the storage media 330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Further, the central processing unit 322 may be configured to communicate with the storage media 330 and execute a series of instruction operations in the storage media 330 on the server 300.

[0166] The server 300 may further include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341, such as Windows Server TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM and so on.

[0167] The steps performed by the server in the above embodiments may be based on the Figure 12 server structure shown.

[0168] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the above-described systems, devices, and units can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein.

[0169] In the embodiments of the present application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works together with other related parts to achieve a predetermined goal, and can be fully or partially implemented by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of the overall module or unit that includes the function of the module or unit.

[0170] In several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, and the indirect couplings or communication connections of devices or units can be in electrical, mechanical, or other forms.

[0171] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0172] In addition, each functional unit in various embodiments of the present application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

[0173] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this 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 for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in various embodiments of the present application. And the aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs and other various media that can store program codes.

[0174] In the embodiments of the present application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an overall module or unit that includes the function of that module or unit.

[0175] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for data analysis, characterized in that, Including: Obtaining a first memory snapshot of a target program and a second memory snapshot of the target program, where the collection moment of the first memory snapshot is before the collection moment of the second memory snapshot; Analyzing, according to the first memory snapshot and the second memory snapshot, an object with memory leakage in the target program to obtain a target object, where the target object is included in the second memory snapshot and not included in the first memory snapshot, or the first memory capacity of the target object is less than the second memory capacity of the target object, the first memory capacity is the memory capacity occupied by the target object in the first memory snapshot, the second memory capacity is the memory capacity occupied by the target object in the second memory snapshot, and the class corresponding to the target object is a target class; Obtaining a reference path of the target object, where the reference path of the target object includes all references to the target object when the target object is added to the target class; Sending the correspondence between the target object and the reference path of the target object.

2. The method according to claim 1, wherein The analyzing, according to the first memory snapshot and the second memory snapshot, an object with memory leakage in the target program to obtain a target object includes: When a first class name is included in the first memory snapshot and a first object name is not included in the first memory snapshot, determining the object corresponding to the first object name as the target object, where the first class name is the class name in the second memory snapshot, the first object name is the object name in the second memory snapshot, and the first object name is associated with the first class name; When the first class name is included in the first memory snapshot, the first object name is included in the first memory snapshot, and a fourth memory capacity is less than a third memory capacity, determining the object corresponding to the first object name as the target object, where the third memory capacity is the memory capacity of the first object in the second memory snapshot, the fourth memory is the memory capacity of the first object in the first memory snapshot, and the first object is the object corresponding to the first object name; When the first class name is included in the second memory snapshot and the first class name is not included in the first memory snapshot, determining a third object as the target object, where the third object is included in the second memory snapshot, the class corresponding to the third object is the first class, and the first class is the class corresponding to the first class name.

3. The method according to claim 2, characterized in that The obtaining the reference path of the target object includes: When the first class name is included in the first memory snapshot, the first object name is included in the first memory snapshot, and the fourth memory capacity is less than the third memory capacity, searching for the name of the target object to obtain the reference path of the target object; The method further includes: Generating a correspondence between the target object and a first identifier, where the first identifier is used to identify that the target object is an object with an increased memory capacity.

4. The method according to claim 2, characterized in that The obtaining the reference path of the target object includes: When the first type of name is included in the first memory snapshot and the first object name is not included in the first memory snapshot, or when the first type of name is included in the second memory snapshot and the first type of name is not included in the first memory snapshot, generate a reference path for the target object; The method further includes: Generate a correspondence between the target object and a second identifier, where the second identifier is used to indicate that the target object is a newly added object.

5. The method according to any one of claims 1 to 4, characterized in that, The time interval between the collection time of the first memory snapshot and the collection time of the second memory snapshot is a first duration.

6. The method according to claim 5, characterized in that, After obtaining the first memory snapshot of the target program and the second memory snapshot of the target program, the method further includes: Obtain a third memory snapshot of the target program, where the time interval between the collection time of the third memory snapshot and the collection time of the first memory snapshot is the first duration.

7. The method according to any one of claims 2 to 4, characterized in that The method further includes: When the first type of name is included in the second memory snapshot, the first object name is included in the first memory snapshot, and the third memory capacity is equal to the fourth memory capacity, generate a correspondence between the first object and a third identifier, where the third identifier is used to indicate that the first object is an object with an unchanged memory capacity; When the first type of name is included in the second memory snapshot, the first object name is included in the first memory snapshot, and the fourth memory capacity is greater than the third memory capacity, generate a correspondence between the first object and a fourth identifier, where the fourth identifier is used to indicate that the first object is an object with a reduced memory capacity.

8. A device for data analysis, characterized in that, Includes: An acquisition unit, configured to acquire a first memory snapshot of a target program and a second memory snapshot of the target program, where the collection time of the first memory snapshot is before the collection time of the second memory snapshot; An analysis unit, configured to analyze an object with a memory leak in the target program according to the first memory snapshot and the second memory snapshot to obtain a target object, where the target object is included in the second memory snapshot and not included in the first memory snapshot, or the first memory capacity of the target object is less than the second memory capacity of the target object, the first memory capacity is the memory capacity occupied by the target object in the first memory snapshot, the second memory capacity is the memory capacity occupied by the target object in the second memory snapshot, and the class corresponding to the target object is the target class; The acquisition unit is further configured to acquire a reference path of the target object, where the reference path of the target object includes all references to the target object when the target object is added to the target class; A sending unit, configured to send the correspondence between the target object and the reference path of the target object.

9. A computer device, characterized in that, Includes: A memory, a transceiver, a processor, and a bus system; Wherein, the memory is used to store programs; The processor is configured to execute the programs in the memory, including executing the data analysis method according to any one of claims 1 to 7; The bus system is used to connect the memory and the processor, so that the memory and the processor can communicate with each other.

10. A computer-readable storage medium includes instructions that, when run on a computer, cause the computer to execute the data analysis method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program, characterized in that, The computer program is executed by a processor to perform the data analysis method according to any one of claims 1 to 7.