Memory object reference analysis method, apparatus, device, and storage medium
By using socket connections and deserialization, the memory object reference information of the game application is obtained, which solves the problem of insufficient memory analysis in existing technologies and realizes a detailed display and optimization of the game memory object reference relationship.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN WANGYU COMPUTER NETWORK CO LTD
- Filing Date
- 2022-02-14
- Publication Date
- 2026-06-23
AI Technical Summary
In current game application development, the analysis of memory object resource usage can only be done through the console commands that come with the engine to output memory reports, and more in-depth memory analysis is not possible.
By obtaining memory object query requests, the serialization information of memory objects is obtained from the preloaded application to be monitored using socket connections, and then deserialized to generate memory object reference analysis information.
It enables in-depth analysis of memory object reference relationships during game application operation, helping users optimize memory usage and improve game performance.
Smart Images

Figure CN114490440B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for memory object reference analysis. Background Technology
[0002] With the development of computer technology, object-oriented software development methodologies have emerged and continued to evolve. Object-oriented methods facilitate the analysis, design, and programming of complex systems in a way that is more human-understandable. Simultaneously, object-oriented programming effectively improves programming efficiency; through encapsulation techniques, message mechanisms allow for the rapid development of entirely new systems, much like building blocks. Object-oriented programming refers to both a programming paradigm and a programming methodology. An object is a concrete implementation of a class. It uses objects as the basic unit of a program, encapsulating program and data within them to improve software reusability, flexibility, and extensibility. For example, in the field of game development, object-oriented game engines can be used as development tools for game applications.
[0003] In current game application development, the analysis of memory object resource usage is generally done through the console commands provided by the game engine, which output memory reports. Developers can then analyze detailed memory usage data during game runtime based on these reports. However, these memory reports only contain relevant memory usage data and cannot provide more in-depth memory analysis. Summary of the Invention
[0004] Therefore, it is necessary to provide a memory object reference analysis method, apparatus, computer device, storage medium, and computer program product that can perform in-depth memory analysis to address the above-mentioned technical problems.
[0005] Firstly, this application provides a method for analyzing memory object references. The method includes:
[0006] Obtain the memory object query request and find the memory object address information corresponding to the memory object query request;
[0007] Activate the preloaded editor tool application to obtain the memory object serialization information from the preloaded application to be monitored by using a socket connection method based on the memory object address information;
[0008] The serialized information of the memory object is deserialized to obtain the memory object reference information corresponding to the memory object query request;
[0009] Memory object reference analysis information is generated based on the memory object reference information.
[0010] Firstly, this application provides another method for memory object reference analysis. The method includes:
[0011] Obtain the memory object query request and find the memory object address information corresponding to the memory object query request;
[0012] Based on the memory object address information, the memory monitoring object is accessed using a socket connection method;
[0013] Obtain the memory object serialization information fed back by the memory monitoring object;
[0014] The serialized information of the memory object is deserialized to obtain the memory object reference information corresponding to the memory object query request;
[0015] Memory object reference analysis information is generated based on the memory object reference information.
[0016] Thirdly, this application also provides a memory object reference analysis apparatus. The apparatus includes:
[0017] The request acquisition module is used to acquire memory object query requests and find the memory object address information corresponding to the memory object query requests.
[0018] The object access module is used to access the memory monitoring object using a socket connection method based on the memory object address information.
[0019] The serialization information acquisition module is used to acquire the memory object serialization information fed back by the memory monitoring object;
[0020] The deserialization processing module is used to deserialize the serialized information of the memory object and obtain the memory object reference information corresponding to the memory object query request.
[0021] The information display module is used to generate memory object reference analysis information based on the memory object reference information.
[0022] Fourthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0023] Obtain the memory object query request and find the memory object address information corresponding to the memory object query request;
[0024] Based on the memory object address information, the memory monitoring object is accessed using a socket connection method;
[0025] Obtain the memory object serialization information fed back by the memory monitoring object;
[0026] The serialized information of the memory object is deserialized to obtain the memory object reference information corresponding to the memory object query request;
[0027] Memory object reference analysis information is generated based on the memory object reference information.
[0028] Fifthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0029] Obtain the memory object query request and find the memory object address information corresponding to the memory object query request;
[0030] Based on the memory object address information, the memory monitoring object is accessed using a socket connection method;
[0031] Obtain the memory object serialization information fed back by the memory monitoring object;
[0032] The serialized information of the memory object is deserialized to obtain the memory object reference information corresponding to the memory object query request;
[0033] Memory object reference analysis information is generated based on the memory object reference information.
[0034] Sixthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0035] Obtain the memory object query request and find the memory object address information corresponding to the memory object query request;
[0036] Based on the memory object address information, the memory monitoring object is accessed using a socket connection method;
[0037] Obtain the memory object serialization information fed back by the memory monitoring object;
[0038] The serialized information of the memory object is deserialized to obtain the memory object reference information corresponding to the memory object query request;
[0039] Memory object reference analysis information is generated based on the memory object reference information.
[0040] The aforementioned memory object reference analysis method, apparatus, computer device, storage medium, and computer program product include a method that, after obtaining a memory object query request, locates the memory object address information corresponding to the query request; accesses the memory monitoring object using a socket connection based on the memory object address information; obtains the memory object serialization information returned by the memory monitoring object; performs deserialization processing on the serialized information to obtain the memory object reference information corresponding to the query request; and generates memory object reference analysis information based on the reference information. The memory object reference analysis method of this application can obtain the memory object serialization information from the memory monitoring object via a socket connection, thereby deserializing it to obtain the corresponding memory object reference relationship. This enables the identification and display of memory object reference relationships during the operation of the memory monitoring object, thus allowing for more in-depth memory object reference analysis. Attached Figure Description
[0041] Figure 1 This is a flowchart illustrating a memory object reference analysis method in one embodiment;
[0042] Figure 2 This is a flowchart illustrating a memory object reference analysis method in another embodiment;
[0043] Figure 3 This is a schematic diagram illustrating the process of obtaining the serialization information of a memory object in one embodiment.
[0044] Figure 4 This is a schematic diagram illustrating the process of obtaining the serialization information of the memory object requested based on memory reference information in one embodiment.
[0045] Figure 5 This is a schematic diagram illustrating the process of generating memory object serialization information in one embodiment.
[0046] Figure 6 This is a flowchart illustrating the writing process to a memory object in one embodiment.
[0047] Figure 7 This is a flowchart illustrating the user-side use of a memory object reference analysis method in one embodiment;
[0048] Figure 8 Here is a flowchart of a memory object reference analysis method in another embodiment;
[0049] Figure 9 This is a structural block diagram of a memory object reference analysis device in one embodiment;
[0050] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0052] In this article, it is important to understand the following terms:
[0053] UE: Unreal Engine is a very popular game development tool that can be used to develop different types of games, including PC games, mobile games, and console games.
[0054] Editor tools: These are tools integrated into the game engine editor, facilitating users to perform tasks such as resource manipulation, configuration adjustments, and data analysis.
[0055] Runtime: refers to the program environment in which the game runs.
[0056] Memory reference: refers to the memory dependency relationship between different data objects.
[0057] UObject: The type of memory object managed by UE.
[0058] Lua: A concise, lightweight, and extensible scripting language.
[0059] Socket: A socket is an endpoint for bidirectional communication between processes on different machines in a network.
[0060] Serialization: The process of converting information from a memory object into a form that can be stored or transmitted.
[0061] Deserialization: the inverse process of serialization
[0062] adb: short for Android Debug Bridge, is a PC-based command-line tool for debugging Android devices.
[0063] JSON is a lightweight data exchange format that is easy to read, as well as easy to parse and generate.
[0064] In one embodiment, such as Figure 1 As shown, a memory object reference analysis method is provided. This embodiment illustrates the method's application to a terminal. It is understood that this method can also be applied to a server, or to a system including both a terminal and a server, and implemented through interaction between the terminal and the server, or between terminals. When implemented through a single terminal, the method includes the following steps:
[0065] Step 102: Obtain the memory object query request and find the memory object address information corresponding to the memory object query request.
[0066] In this application, a memory object query request is submitted by the user to the terminal to retrieve reference information related to a specified memory object. Specifically, the memory object reference analysis method of this application is applied to an application to be monitored, developed based on object-oriented programming. Object-oriented programming is both a programming paradigm and a programming methodology. An object is a concrete implementation of a class. It uses objects as the basic unit of a program, encapsulating programs and data to improve software reusability, flexibility, and extensibility. This application can display a list of all objects in the application under monitoring during its runtime through the terminal's operation page. The user can initiate a memory object query request to the terminal by clicking on a memory object in the object list on the page. The memory object address information refers to the memory address of the memory object in the application under monitoring. The application under monitoring can find the target memory object requested by the user based on the memory object address information, and then identify the memory object reference information corresponding to the found target memory object. In one embodiment, the memory object reference analysis method of this application can be used to display the memory object application relationships of a game running on the terminal.
[0067] Specifically, the memory object reference analysis method of this application identifies the reference relationships corresponding to each object in the application under monitoring during its operation, and then analyzes these memory object references. Users can perform a more in-depth analysis of object memory during the operation of the application under monitoring based on the displayed memory object reference relationships, thereby achieving optimization of the application. First, the application under monitoring needs to be started. During the operation of the application, a list of all objects running in the application can be displayed on the terminal's screen. Users can query and select the target memory objects to be displayed on the terminal, and then generate a memory object query request. After receiving the memory object query request, the terminal, based on the preset information of the application under monitoring, finds the memory object address information corresponding to the memory object query request.
[0068] Step 104: Activate the preloaded editor tool application to obtain the memory object serialization information from the preloaded application to be monitored by using a socket connection method based on the memory object address information.
[0069] The editor tool application refers to the application used to display memory object reference relationship information. The terminal can preload the editor tool application and the application to be monitored, allowing users to view the memory object reference information of the application under test through the editor tool application. The application to be monitored is the application containing the target memory object in the memory object reference analysis. The memory object reference analysis method of this application can display the memory object reference relationships in the application under test through the editor tool application during the application's runtime, thereby helping users gain a deeper understanding of the memory usage information of the application under test during runtime. A socket connection, or Socket connection, is an abstraction of the endpoint for bidirectional communication between application processes on different hosts in a network. A socket is one end of process communication on the network, providing a mechanism for application-layer processes to exchange data using network protocols. In terms of its position, the socket connects to the application process upstream and the network protocol stack downstream; it is the interface for applications to communicate through network protocols and the interface for applications to interact with the network protocol stack. Memory object serialization information refers to the memory object reference information after serialization. Since the information of memory objects is generally immovable in the application under test, serialization can convert the information of memory objects into a storable or transmittable form. This application's solution primarily establishes a connection between a pre-loaded editor tool application on the terminal and a pre-loaded application to be monitored. The editor tool application and the application to be monitored can run on the same terminal or on different terminals. Serialization refers to the process of converting a memory object into a sequence of bytes. The resulting memory object serialization information can be a JSON (JavaScript Object Notation) file, which includes information such as the memory object's name, type, address, path, and references. Serialization is mainly used to ensure the integrity and transmissibility of objects when transmitting and saving them. Serialization converts objects into an ordered byte stream for transmission over a network or storage in a local file.
[0070] Specifically, after determining the memory object address information, the terminal can control a pre-loaded editor tool application to generate corresponding query information based on the memory object address information. Then, through a socket connection, the query information is input into the pre-loaded and running application to be monitored, from which the corresponding memory object serialization information is obtained. In one embodiment, the application to be monitored in this application is specifically a game application developed based on a game engine. In this case, the editor tool application can be integrated into the game engine to achieve memory object reference monitoring during game development.
[0071] Step 106: Deserialize the serialized information of the memory object to obtain the memory object reference information corresponding to the memory object query request.
[0072] Step 108: Generate memory object reference analysis information based on memory object reference information.
[0073] Deserialization, in contrast to serialization, refers to the process of restoring a byte sequence into a memory object. Deserialization can reconstruct the object based on the object state and description information stored in the memory object's serialization information, thus obtaining the memory object's reference information. Memory object reference analysis specifically refers to displaying the reference relationships of target memory objects in the monitored application to the user in a more intuitive way, such as through a reference relationship graph or a folder tree structure.
[0074] Specifically, after obtaining the serialized information of memory objects from the application under monitoring, in order to display this serialized information, it is necessary to restore it to memory object reference information. At this point, the memory object serialized information can be deserialized to parse it into usable memory object reference information. After obtaining the memory object reference information, to more intuitively display the reference information of the current target memory object to the user, memory object reference analysis information corresponding to the memory object query request can be generated based on the memory object reference information. This analysis information then displays the reference relationships involved by the target memory object during the operation of the application under monitoring.
[0075] As described above, a pre-loaded memory monitoring object and a pre-loaded editor tool application can run simultaneously on the terminal. If the memory monitoring object is a mobile game, the mobile game can be run on a computer terminal using an emulator, while the editor tool application is loaded on the computer terminal. Then, a socket connection is established between the pre-loaded editor tool application and the pre-loaded memory monitoring object, and communication between the two applications is based on this socket connection. In another embodiment, the solution of this application can also be implemented through interaction between terminals. For example, the editor tool application can run on the computer terminal, while the application to be monitored can run on the mobile phone terminal, and then communication between the two terminals can be achieved through a socket connection. In this case, the method of this application can be applied to the computer terminal, such as... Figure 2 As shown, the method includes the following steps:
[0076] Step 201: Obtain the memory object query request and find the memory object address information corresponding to the memory object query request.
[0077] Step 203: Access the memory monitoring object using a socket connection method based on the memory object address information.
[0078] Step 205: Obtain the memory object serialization information fed back by the memory monitoring object.
[0079] Step 207: Deserialize the serialized information of the memory object to obtain the memory object reference information corresponding to the memory object query request.
[0080] Step 209: Generate memory object reference analysis information based on memory object reference information.
[0081] Specifically, the above method is implemented on the computer through an editor tool application. Once the application to be monitored is running on the mobile terminal, the user can query the target object within the pre-loaded editor tool application, or directly click on the target application in the editor tool application's list of all objects. Upon clicking, the editor tool application receives the memory object query request and then locates the memory object address information corresponding to the query request. Based on the memory object address information, it generates a query request, accesses the memory monitoring object (i.e., the application to be monitored) via a socket connection, and sends the generated query request to the memory monitoring object to obtain the memory object serialization information. The serialized memory object information is then deserialized to obtain the memory object reference information corresponding to the memory object query request. Finally, based on the memory object reference information, it generates memory object reference analysis information corresponding to the memory object query request, loads this memory object reference analysis information, and provides the user with the memory object reference analysis related to the target content object during the running of the application to be monitored.
[0082] The aforementioned memory object reference analysis method involves, after obtaining a memory object query request, finding the memory object address information corresponding to the query request; accessing the memory monitoring object using a socket connection based on the memory object address information; obtaining the memory object serialization information returned by the memory monitoring object; deserializing the memory object serialization information to obtain the memory object reference information corresponding to the query request; and generating memory object reference analysis information based on the memory object reference information. This application's memory object reference analysis method can obtain memory object serialization information from the memory monitoring object via a socket connection, thereby deserializing it to obtain the corresponding memory object reference relationship. This enables the identification and display of memory object reference relationships during the operation of the memory monitoring object, thus allowing for more in-depth memory object reference analysis.
[0083] In one embodiment, prior to step 103, the method further includes: establishing a data forwarding relationship between the preloaded editor tool application and the preloaded application to be monitored; establishing a socket client based on the data forwarding relationship; and establishing a socket connection between the preloaded editor tool application and the preloaded application to be monitored based on the socket client.
[0084] In order to establish a socket connection between the preloaded editor tool application and the preloaded application to be monitored, a socket client needs to be built in advance. This socket client is used to implement the data forwarding relationship between the editor tool application and the application to be monitored. Therefore, before obtaining memory object serialization information from the preloaded application to be monitored via the socket connection, the socket client needs to be built in advance. Furthermore, to build the socket client, the application to be monitored also needs to monitor the socket connection.
[0085] Specifically, after the application to be monitored runs, local port connections can be monitored to determine whether a socket connection exists. Once the application to be monitored is running, to establish a socket connection between the editor tool application and the application to be monitored, a data forwarding relationship can first be established between the pre-loaded editor tool application and the pre-loaded application to be monitored. This data forwarding relationship specifically refers to the data forwarding relationship between the terminals where the applications reside. For example, if the application to be monitored runs on mobile terminal A, and the editor tool application runs on computer terminal B, when the application to be monitored runs on mobile terminal A and socket connection monitoring is initiated, the terminal can establish a data forwarding relationship between the port of mobile terminal A and the port of computer terminal B on the editor tool application. In one embodiment, the data forwarding relationship can be established via adb (Android Debug Bridge) forward. Then, a socket client can be built based on the data forwarding relationship, thereby establishing a socket connection between the pre-loaded editor tool application and the pre-loaded application to be monitored. In a specific embodiment, the editor tool application of this application is integrated into Unreal Engine for game development. Unreal Engine runs on a computer, and the application to be monitored can be a mobile game. When game developers need to determine the memory object reference relationships in a mobile game, they can connect the computer and mobile phone via a USB (Universal Serial Bus) cable. Once the mobile game is launched, the phone will monitor the local port connection. After the phone enables Socket monitoring, the editor tool application establishes a data forwarding relationship between the computer port and the mobile phone port using adb forward. Then, it establishes a Socket client through Unreal Engine's Socket system ISocketSubsystem and connects to the application to be monitored on the mobile phone. In this embodiment, by pre-building the data forwarding relationship and then constructing the socket client, the socket connection between the pre-loaded editor tool application and the pre-loaded application to be monitored can be effectively realized, which helps ensure the efficiency of memory object serialization information forwarding.
[0086] In one embodiment, such as Figure 3 As shown, step 203 includes:
[0087] Step 302: Generate a memory reference information retrieval request based on the memory object address information.
[0088] Step 304: Send a memory reference information retrieval request to the memory monitoring object using a socket connection.
[0089] The memory reference information retrieval request is generated on the editor tool application side and is used to request memory reference information from the memory monitoring object.
[0090] Specifically, after establishing a socket client, a connection can be established between the running memory monitoring object and the editor tool application. When the memory monitoring object receives a memory reference information retrieval request through the socket connection, it can extract the memory object address information from the request. Then, based on the memory object address information, it can locate the corresponding memory object reference information. After serializing this information, the obtained memory object serialization information is fed back to the editor tool application through the socket connection, allowing the editor tool application to perform subsequent memory object reference analysis based on the memory object serialization information. In this embodiment, by generating a memory reference information retrieval request, information exchange between the pre-loaded editor tool application and the pre-loaded memory monitoring object can be achieved, effectively obtaining memory object serialization information from the pre-loaded memory monitoring object, thereby displaying the memory object reference relationship.
[0091] In one embodiment, such as Figure 4 As shown, the memory object serialization information is obtained by the memory monitoring object in the following way:
[0092] Step 401: Obtain memory reference information. Obtain the memory object address information in the request.
[0093] Step 403: Locate the target memory object pointed to by the memory object address data.
[0094] Step 405: Obtain the memory object reference information corresponding to the target memory object.
[0095] Step 407: Serialize the memory object reference information to obtain the memory object serialization information.
[0096] Specifically, on the target memory object side, a socket connection can be used to obtain a memory reference information retrieval request. Then, the memory object address information is extracted from the memory reference information retrieval request. Based on this memory object address information, the memory object pointed to by that address is located within the running memory monitoring object. Based on this memory object, the corresponding memory object reference information is found. This memory object reference information specifically includes references between memory objects and references between scripts and memory objects. Once this data is obtained, it can be serialized, for example, into JSON data. The resulting JSON data mainly includes the memory object name, type, address, path, and reference information. Then, the serialized memory object information is sent to an editor application via a socket connection for further processing. The terminal can then directly receive the processed serialized memory object information. In this embodiment, the memory monitoring object can receive a memory reference information acquisition request, thereby finding the memory object pointed to by the memory object address data and obtaining the corresponding memory object reference information. This can effectively ensure the smooth progress of the memory object reference analysis process and guarantee the effectiveness of the memory object reference analysis.
[0097] In one embodiment, the memory object reference information includes first reference relationship information between memory objects and second reference relationship information of the script to the memory object. The memory object reference information corresponding to the target memory object is obtained in the following way: by using a preset query interface in a multi-threaded manner, the first reference relationship information corresponding to the target memory object is collected; the table in the script environment is searched and the table in the script environment is recursively traversed to obtain the second reference relationship information corresponding to the target memory object.
[0098] The preset query interface specifically refers to the query interface provided by the development tool of the memory monitoring object, used for content querying. For example, in one embodiment, the memory monitoring object is a mobile game developed based on Unreal Engine, and the preset query interface is specifically the FReferencerFinder::GetAllReferencers interface. It can collect reference relationship information between memory objects in a multi-threaded manner. Recursive traversal specifically refers to iterating through objects recursively. Recursion is when a program calls itself during runtime. Traversal refers to visiting each node in a tree (or graph) sequentially along a search path. The operations performed on the nodes depend on the specific application problem; specific access operations may include checking the value of a node, updating the value of a node, etc. Different traversal methods result in different node access orders. Traversal is one of the most important operations on a binary tree and is the foundation for other operations on a binary tree. Recursive traversal can effectively query the reference relationship information of the script to memory objects in the table within the script environment. The table in the script is a data structure that can be used as an array or a dictionary.
[0099] Specifically, when collecting memory object reference information from memory monitoring objects, the reference information can be divided into two types: reference relationships between memory objects and reference relationships between scripts and memory objects. Reference relationships between memory objects can be obtained through a query interface, such as the FReferencerFinder::GetAllReferencers interface provided by Unreal Engine, which allows for multi-threaded collection of this information. Reference relationships between scripts and memory objects are typically stored in tables within the scripts. Therefore, by recursively traversing the tables in the scripts corresponding to the preloaded memory monitoring objects, the reference relationships between the scripts and memory objects pointed to by the memory object's address data can be obtained. For example, in a Lua scripting environment, recursively traversing the tables in the Lua environment can retrieve all tables holding the target memory object, thus obtaining Lua's reference information to the memory object. In the embodiments of this application, querying through a query interface efficiently obtains reference relationships between memory objects, while recursively traversing to find tables in the scripts efficiently obtains reference relationships between scripts and memory objects. Combining both methods yields the memory object reference information.
[0100] In one embodiment, the memory object reference analysis information includes a memory reference graph.
[0101] like Figure 5 As shown, step 209 specifically includes:
[0102] Step 502: Based on the memory object reference information, obtain the target memory object corresponding to the memory object query request, determine the referenced memory objects involved in the target memory object, the reference relationships between memory objects, and the reference relationship graph construction class.
[0103] Step 504: Take the target memory object as the root node and identify the node type of the referenced memory object based on the reference relationship between memory objects.
[0104] Step 506: Generate the memory reference graph corresponding to the memory object query request based on the node type and the reference relationship graph.
[0105] In a memory reference graph, nodes represent memory objects, with each node representing a memory object. Connections between nodes indicate the reference relationships between these objects. Memory reference graph constructors are the main classes used to construct the memory reference graph. These classes handle tasks such as drawing nodes, creating connections between nodes, and configuring the graph's display depth. In a specific implementation where the memory monitoring object is located in a mobile game developed using Unreal Engine, the memory reference graph constructors include the following classes: `UEdGraph_MemoryReferenceViewer`: Inherited from `UEdGraph`, responsible for constructing the graph's nodes and their reference relationships, as well as the layout of the graph nodes. `UEdGraphNode_MemoryReference`: Inherited from `UEdGraphNode`, responsible for describing the data structure of the graph nodes, which can be used to display information about memory objects. `UEMemoryReferenceViewerSchema`: Inherited from `UEdGraphSchema`, responsible for describing the drawing method of connections between graph nodes, the operation behavior of connections, and the context menus of nodes. UMemoryReferenceSearchConfig: Responsible for storing search configuration information, such as the type of search to ignore and search depth, which can be used to construct the reference graph. SMemoryReferenceNode: Inherited from the UE class SGraphNode, responsible for describing the display layout of individual node information. SMemoryReferenceViewer: Responsible for describing the overall UI layout of the entire memory reference relationship analysis tool window, including search configuration, search list, and reference relationship graph.
[0106] Specifically, after obtaining memory object reference information through deserialization, a memory reference graph can be constructed based on this information. When a user identifies a target memory object within the memory monitoring object, the method described in this application can obtain the corresponding memory object reference information. This allows the acquisition of the referenced memory objects, the reference relationships between memory objects, and the reference graph constructor. Then, the user-selected target memory object can be used as the root node, and the memory reference graph can be constructed starting from the root node. Based on the reference relationships between memory objects, the node types of these referenced memory objects are identified to determine if they are leaf nodes. During the layout calculation of the memory reference graph, the height coefficient of each node is recursively calculated starting from the selected root node. If the node is a leaf node, the height coefficient is 1; otherwise, the height coefficient of the node is the sum of the height coefficients of its child nodes. Simultaneously, starting from the selected root node, the node structure of the memory reference relationship is recursively constructed. The width position of a node is offset by a certain coefficient based on its depth, and the height offset position of a node is calculated based on the cumulative value of the height coefficients of its parent node and sibling nodes. The height offset is calculated as: (cumulative height coefficient of currently calculated sibling nodes – (height coefficient of parent node / 2)). In this embodiment, a memory reference graph is used to display the reference relationships based on the target memory object, which can effectively help users perform memory monitoring and object memory analysis during object execution, ensuring the effectiveness of memory analysis.
[0107] In one embodiment, such as Figure 6 As shown, after step 108, the following steps are also included:
[0108] Step 601: Obtain the object unloading information fed back from the memory object reference analysis information.
[0109] Step 603: Generate an object uninstallation request based on the object uninstallation information;
[0110] Step 605: Send an object unloading request to the memory monitoring object.
[0111] Specifically, during application operation, some memory objects that consume a large amount of memory and should be unloaded may not be unloaded because it is impossible to determine which memory object references are causing them to remain unloaded. This makes it difficult to pinpoint the cause of these reference relationships and thus hinders efforts to reduce application runtime memory consumption. However, the memory object reference analysis method of this application can generate reference information corresponding to memory objects. Therefore, users can more easily locate the reason why memory objects that should be unloaded are still in memory based on this information, facilitating the unloading of unnecessary memory objects and improving the operating efficiency of the memory monitoring object. The terminal can obtain object unloading information based on the memory object reference analysis information. Then, it generates an object unloading request based on the object unloading information and sends the object unloading request to the memory monitoring object, completing the object unloading process within the memory monitoring object. In this embodiment, unloading the corresponding memory objects in the pre-loaded memory monitoring object using object unloading information can effectively improve the operating efficiency of the pre-loaded memory monitoring object.
[0112] This application also provides an application scenario in which the above-described memory object reference analysis method is applied. Specifically, the application of the memory object reference analysis method in this scenario is as follows:
[0113] When users develop mobile games using Unreal Engine, to ensure smooth game operation, the memory object reference analysis method described in this application can be used to analyze the relationships between memory objects during game execution. The mobile game is set up on a mobile terminal and integrates a data collection module. The mobile terminal connects to a computer via a USB cable, and an editor tool module runs on the computer. This editor tool module is integrated into the game development engine. The memory object reference analysis method described in this application can be implemented through the data collection module and the editor tool module. The overall usage flow can be found in [reference needed]. Figure 7 As shown, first, connect the computer and mobile terminal using a USB cable. Then, launch the game on the mobile terminal and simultaneously launch the editor tool module on the computer. The memory objects generated during game execution will be displayed on the editor tool module's interface. Users can input a memory object to query on the editor tool module's page, and the interface will then redirect to that memory object. Users can click on this memory object to initiate the memory object reference analysis method. This application can then search for the corresponding memory object reference information based on the user-selected memory object and display the object-related reference relationships through a reference relationship graph. For objects referenced by Lua scripts, users can right-click the object node and select "Show LuaReferences" to display the Lua table's references to the memory object. The complete process of memory object reference analysis can be found in [reference needed]. Figure 8As shown, firstly, after the mobile game runs, the data collection module enables server monitoring of socket connections: (1) Connect the computer and mobile terminal via USB cable. After the mobile terminal starts the game, enable the data collection module to monitor the local port connection. Socket creation uses UE's Socket system ISocketSubsystem. (2) The editor tool module initiates a socket connection request: After the data collection module enables socket monitoring, the editor tool module establishes a data forwarding relationship between the computer port and the mobile port through adb forward, and then establishes a socket client through UE's ISocketSubsystem and connects to the data collection module on the mobile terminal. (3) The editor tool module requests memory reference information: When it is necessary to query the memory reference information of an object, the editor tool module is responsible for initiating a data request and including the object's memory address information. (4) The data collection module accepts the memory reference request: Through the socket connection, the data collection module can receive the memory reference information lookup request initiated by the editor tool module, and then perform the collection of memory reference information. (5) The data collection module serializes the memory reference information into JSON data: After collecting the memory reference information, the data collection module needs to send the data to the editor tool module. For this purpose, the collected memory reference information needs to be serialized into JSON data format. The JSON data mainly includes the memory object name, type, address, path, and reference information. (6) The data collection module sends the JSON data to the editor tool module: The data collection module sends the serialized memory reference JSON data to the editor tool module through a socket connection. (7) The editor tool module receives the JSON data: Through the socket connection, the editor tool module can receive the JSON data sent by the data collection module. (8) The editor tool module deserializes the JSON data into memory reference information: After receiving the JSON data, the editor tool needs to parse the JSON data and deserialize the data into usable memory data, which can be used to construct the memory reference relationship graph in the editor tool module.
[0114] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0115] Based on the same inventive concept, this application also provides a memory object reference analysis apparatus for implementing the memory object reference analysis method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more memory object reference analysis apparatus embodiments provided below can be found in the limitations of the memory object reference analysis method described above, and will not be repeated here.
[0116] In one embodiment, such as Figure 9 As shown, a memory object reference analysis apparatus is provided, comprising:
[0117] The request retrieval module 902 is used to retrieve memory object query requests and find the memory object address information corresponding to the memory object query request.
[0118] The object access module 904 is used to access the memory monitoring object using a socket connection method based on the memory object address information.
[0119] The serialization information acquisition module 906 is used to acquire the memory object serialization information fed back by the memory monitoring object.
[0120] The deserialization processing module 908 is used to deserialize the serialized information of memory objects and obtain the memory object reference information corresponding to the memory object query request.
[0121] The information display module 910 is used to generate memory object reference analysis information based on memory object reference information.
[0122] The aforementioned memory object reference analysis device can, after obtaining a memory object query request, locate the memory object address information corresponding to the query request; access the memory monitoring object using a socket connection based on the memory object address information; obtain the memory object serialization information returned by the memory monitoring object; deserialize the memory object serialization information to obtain the memory object reference information corresponding to the query request; and generate memory object reference analysis information based on the memory object reference information. The memory object reference analysis method of this application can obtain memory object serialization information from the memory monitoring object through a socket connection, thereby deserializing the corresponding memory object reference relationship. This enables the identification and display of memory object reference relationships during the operation of the memory monitoring object, thus allowing for more in-depth memory object reference analysis.
[0123] In one embodiment, the object access module 904 is specifically used to: generate a memory reference information acquisition request based on the memory object address information; and send the memory reference information acquisition request to the memory monitoring object using a socket connection method.
[0124] In one embodiment, the memory object serialization information is obtained by the memory monitoring object in the following way: obtaining memory reference information, obtaining memory object address information in the request, finding the target memory object pointed to by the memory object address data, obtaining memory object reference information corresponding to the target memory object, performing serialization processing on the memory object reference information, and obtaining memory object serialization information.
[0125] In one embodiment, the memory object reference information includes first reference relationship information between memory objects and second reference relationship information of the script to the memory object; the memory object reference information corresponding to the target memory object is obtained by: collecting the first reference relationship information corresponding to the target memory object in a multi-threaded manner through a preset query interface; searching the table in the script environment and recursively traversing the table in the script environment to obtain the second reference relationship information corresponding to the target memory object.
[0126] In one embodiment, the memory object reference analysis information includes a memory reference relationship graph; the information display module 1110 is specifically used to: obtain the target memory object corresponding to the memory object query request based on the memory object reference information, determine the referenced memory objects involved in the target memory object, the reference relationships between memory objects, and the reference relationship graph construction class; take the target memory object as the root node, identify the node type of the referenced memory object based on the reference relationships between memory objects; and generate the memory reference relationship graph corresponding to the memory object query request based on the node type and the reference relationship graph construction class.
[0127] In one embodiment, an object unloading module is also included, which is used to: generate an object unloading request based on object unloading information; and send the object unloading request to the memory monitoring object.
[0128] The modules in the aforementioned memory object reference analysis device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.
[0129] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a memory object reference analysis method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0130] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0131] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0132] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0133] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.
[0134] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0135] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0136] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0137] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A memory analysis method, characterized in that, The method includes: Obtain a memory object query request, and find the memory object address information corresponding to the memory object query request. The memory object query request is generated based on the memory objects determined by the user in the object list during the operation of the application to be tested. Establish a data forwarding relationship between the preloaded editor tool application and the preloaded application to be monitored; build a socket client based on the data forwarding relationship; build a socket connection between the preloaded editor tool application and the preloaded application to be monitored based on the socket client; Activate the preloaded editor tool application to generate corresponding query information based on the memory object address information. Input the query information into the preloaded application to be monitored by using a socket connection method, and obtain the memory object serialization information from the preloaded application to be monitored. The serialized information of the memory object is deserialized to obtain the memory object reference information corresponding to the memory object query request. The memory object reference information includes first reference relationship information between memory objects and second reference relationship information of scripts to memory objects. The first reference relationship information is collected in a multi-threaded manner through a query interface. The second reference relationship information is obtained by recursively traversing the table in the script corresponding to the preloaded application to be monitored to obtain the reference relationship information of the script to the memory object pointed to by the memory object address information. Memory object reference analysis information is generated based on the memory object reference information. The memory object reference analysis information includes a memory reference relationship graph. The memory reference relationship graph displays memory objects through nodes and the reference relationship between memory objects is displayed through the connections between the nodes. Each node represents a memory object.
2. A memory analysis method, characterized in that, The method includes: Obtain a memory object query request, and find the memory object address information corresponding to the memory object query request. The memory object query request is generated based on the memory objects determined by the user in the object list during the operation of the application to be tested. Establish a data forwarding relationship between the preloaded editor tool application and the running memory monitoring object; build a socket client based on the data forwarding relationship; and build a socket connection between the preloaded editor tool application and the running memory monitoring object based on the socket client. Based on the memory object address information, a memory reference information retrieval request is generated; the memory reference information retrieval request is sent to the memory monitoring object using a socket connection. Obtain the memory object serialization information fed back by the memory monitoring object; The serialized information of the memory object is deserialized to obtain the memory object reference information corresponding to the memory object query request. The memory object reference information includes first reference relationship information between memory objects and second reference relationship information of the script to the memory object. The first reference relationship information is collected in a multi-threaded manner through a query interface. The second reference relationship information is obtained by recursively traversing the table in the script corresponding to the memory monitoring object to obtain the reference relationship information of the script to the memory object pointed to by the memory object address information. Memory object reference analysis information is generated based on the memory object reference information. The memory object reference analysis information includes a memory reference relationship graph. The memory reference relationship graph displays memory objects through nodes and the reference relationship between memory objects is displayed through the connections between the nodes. Each node represents a memory object.
3. The method according to claim 2, characterized in that: The memory object serialization information is obtained by the memory monitoring object in the following way: obtaining the memory object address information in the memory reference information acquisition request, finding the target memory object pointed to by the memory object address data, obtaining the memory object reference information corresponding to the target memory object, performing serialization processing on the memory object reference information, and obtaining the memory object serialization information.
4. The method according to claim 2, characterized in that, The memory object reference analysis information includes a memory reference relationship graph; The step of generating memory object reference analysis information based on the memory object reference information includes: Based on the memory object reference information, obtain the target memory object corresponding to the memory object query request, and determine the referenced memory objects involved in the target memory object, the reference relationships between the memory objects, and the reference relationship graph construction class; The target memory object is used as the root node, and the node type of the referenced memory object is identified according to the reference relationship between the memory objects. Based on the node type and the reference relationship graph, a class is constructed to generate the memory reference relationship graph corresponding to the memory object query request.
5. A memory object reference analysis device, characterized in that, The device includes: The request acquisition module is used to acquire memory object query requests and find the memory object address information corresponding to the memory object query requests. The memory object query requests are generated based on the memory objects determined by the user in the object list during the operation of the application to be tested. The object access module is used to establish a data forwarding relationship between a preloaded editor tool application and a running memory monitoring object; build a socket client based on the data forwarding relationship; build a socket connection between the preloaded editor tool application and the running memory monitoring object based on the socket client; generate a memory reference information retrieval request based on the memory object address information; and send the memory reference information retrieval request to the memory monitoring object using a socket connection. The serialization information acquisition module is used to acquire the memory object serialization information fed back by the memory monitoring object; The deserialization processing module is used to deserialize the serialized information of the memory object and obtain the memory object reference information corresponding to the memory object query request. The memory object reference information includes first reference relationship information between memory objects and second reference relationship information of the script to the memory object. The first reference relationship information is collected in a multi-threaded manner through a query interface. The second reference relationship information is obtained by recursively traversing the table in the script corresponding to the memory monitoring object to obtain the reference relationship information of the script to the memory object pointed to by the memory object address information. The information display module is used to generate memory object reference analysis information based on the memory object reference information. The memory object reference analysis information includes a memory reference relationship graph. The memory reference relationship graph displays memory objects through nodes and displays the reference relationship between memory objects through the connections between the nodes. Each node represents a memory object.
6. The apparatus according to claim 5, characterized in that: The memory object serialization information is obtained by the memory monitoring object in the following way: obtaining the memory object address information in the memory reference information acquisition request, finding the target memory object pointed to by the memory object address data, obtaining the memory object reference information corresponding to the target memory object, performing serialization processing on the memory object reference information, and obtaining the memory object serialization information.
7. The apparatus according to claim 5, characterized in that, The memory object reference analysis information includes a memory reference relationship graph; The information display module is specifically used for: obtaining the target memory object corresponding to the memory object query request based on the memory object reference information; determining the referenced memory objects involved in the target memory object, the reference relationships between the memory objects, and the reference relationship graph construction class; using the target memory object as the root node, and identifying the node type of the referenced memory object based on the reference relationships between the memory objects; Based on the node type and the reference relationship graph, a class is constructed to generate the memory reference relationship graph corresponding to the memory object query request.
8. The apparatus according to claim 5, characterized in that, It also includes an object unloading module, used to: obtain object unloading information fed back based on the memory object reference analysis information; generate an object unloading request based on the object unloading information; and send the object unloading request to the memory monitoring object.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.