Memory analysis method and related device
The multi-level memory footprint information of game applications is obtained through low-level memory trackers, which solves the problem of excessive granularity of memory footprint detection in the existing technology, achieves more accurate and rich memory footprint analysis, and supports targeted optimization.
Patent Information
- Application Number
- CN202311214894.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-19
- Publication Date
- 2025-03-21
AI Technical Summary
When the prior art detects the memory usage of game applications, the granularity is too coarse and it is difficult to make targeted optimization and adjustments.
The memory usage information of game applications at the operating system level and game engine level is obtained through a low-level memory tracker, and the memory usage information of game applications is combined with local heap memory and video memory usage information to comprehensively determine the memory usage of game applications.
It realizes a more fine-grained memory-occupying information acquisition, ensures the reliability and richness of information, and supports targeted optimization and adjustment.
Smart Images

Figure CN119668966A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a memory parsing method and related devices. Background Art
[0002] Nowadays, when testing and accepting the performance of a game application, it is usually necessary to detect the memory usage of the game application during runtime to determine whether the game application's memory usage is too high, whether there is an abnormal memory growth compared to historical versions, and optimize and adjust the game application accordingly.
[0003] In the related art, the performance testing tools of the operating system (such as perfdog) are usually used to collect the overall memory of the game application, and then the actual physical memory used (Proportional set size, PSS) indicator is used to measure the overall memory usage of the game application. The memory usage determined in this way is too coarse and the information reflected is too single. It is difficult to optimize and adjust the game application in a targeted manner based on the memory usage. Summary of the invention
[0004] The embodiments of the present application provide a memory analysis method and related devices, which can determine the memory usage of a game application at a finer granularity when it is running, ensure that the determined memory usage reflects rich information, and facilitate targeted optimization and adjustment of the game application based on this.
[0005] In view of this, the first aspect of the present application provides a memory parsing method, the method comprising:
[0006] Control the target game application to run in the target device;
[0007] During the running of the target game application, obtaining, by means of a low-level memory tracker, first memory occupancy information of the target game application at an operating system level and second memory occupancy information of the target game application at a game engine level;
[0008] During the running of the target game application, obtaining local heap memory occupancy information of the target game application and obtaining video memory occupancy information of the target game application;
[0009] The comprehensive memory occupancy of the target game application is determined according to the first memory occupancy information, the second memory occupancy information, the local heap memory occupancy information and the video memory occupancy information.
[0010] A second aspect of the present application provides a memory parsing device, the device comprising:
[0011] An application running module, used to control the target game application to run in the target device;
[0012] A memory acquisition module, used for acquiring, during the operation of the target game application, first memory occupancy information of the target game application at the operating system level and second memory occupancy information of the target game application at the game engine level through a low-level memory tracker;
[0013] The memory acquisition module is further used to acquire local heap memory occupancy information of the target game application and video memory occupancy information of the target game application during the operation of the target game application;
[0014] A memory analysis module is used to determine the comprehensive memory occupancy of the target game application according to the first memory occupancy information, the second memory occupancy information, the local heap memory occupancy information and the video memory occupancy information.
[0015] A third aspect of the present application provides a computer device, the device comprising a processor and a memory:
[0016] The memory is used to store computer programs;
[0017] The processor is used to execute the steps of the memory parsing method as described in the first aspect according to the computer program.
[0018] A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the steps of the memory parsing method described in the first aspect above.
[0019] In a fifth aspect, the present application provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a 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 steps of the memory parsing method described in the first aspect above.
[0020] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0021] An embodiment of the present application provides a memory parsing method, in which a target game application is first controlled to run in a target device; then, during the running of the target game application, first memory occupancy information of the target game application at the operating system level and second memory occupancy information of the target game application at the game engine level are obtained through a low-level memory tracker; and local heap memory occupancy information of the target game application and video memory occupancy information of the target game application are also obtained; and then, based on the above-mentioned first memory occupancy information, second memory occupancy information, local heap memory occupancy information and video memory occupancy information, the comprehensive memory occupancy of the target game application is determined. Compared with the related art that only uses the PSS indicator to reflect the overall memory usage of the game application, the method provided in the embodiment of the present application, on the one hand, obtains the memory usage information of the target game application at the operating system level and the game engine level through a low-level memory tracker, thereby achieving the acquisition of more fine-grained memory usage information, and ensuring that the obtained memory usage information has high reliability and can accurately reflect the memory usage of the relevant parts of the target game application when it is running; on the other hand, the local heap memory usage information of the target game application is obtained to determine the memory usage of the game engine and the called third-party library components when the target game application is running; on the other hand, the video memory usage information of the target game application is obtained to determine the video memory usage related to the graphics processor when the target game application is running; finally, the comprehensive memory usage of the target game application is determined by comprehensively considering the memory usage information at the operating system level and the game engine level, the local heap memory usage information and the video memory usage information, which can ensure that the comprehensive memory usage can reflect the rich storage resource usage of the target game application in multiple dimensions, and accordingly, it is conducive to the subsequent targeted optimization and adjustment of the target game application based on this. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A schematic diagram of an application scenario of the memory parsing method provided in an embodiment of the present application;
[0023] Figure 2 A flowchart of a memory parsing method provided in an embodiment of the present application;
[0024] Figure 3 A statistical schematic diagram of first memory information provided in an embodiment of the present application;
[0025] Figure 4 A statistical schematic diagram of second memory information provided in an embodiment of the present application;
[0026] Figure 5 A statistical diagram of NativeHeap occupancy information provided in an embodiment of the present application;
[0027] Figure 6A statistical diagram of video memory occupancy information provided in an embodiment of the present application;
[0028] Figure 7 A schematic diagram of the configuration process of the game engine provided in the embodiment of the present application;
[0029] Figure 8 A schematic diagram of a Tag macro definition provided in an embodiment of the present application;
[0030] Fig. 9 A schematic diagram of adding Tag statistics provided in an embodiment of the present application;
[0031] Fig.10 A schematic diagram of inserting a tag range label into a code provided in an embodiment of the present application;
[0032] Fig.11 A memory acquisition schematic diagram of a low-level memory tracker provided in an embodiment of the present application;
[0033] Fig.12 A schematic diagram of a NativeHeap collection range provided in an embodiment of the present application;
[0034] Fig.13 A schematic diagram of obtaining NativeHeap occupancy information provided in an embodiment of the present application;
[0035] Fig.14 A schematic diagram of obtaining video memory occupancy information provided in an embodiment of the present application;
[0036] Fig.15 A schematic diagram of obtaining Memreport memory data provided in an embodiment of the present application;
[0037] Fig.16 A schematic diagram of obtaining memory usage information provided in an embodiment of the present application;
[0038] Fig.17 A statistical diagram of a comprehensive memory usage provided in an embodiment of the present application;
[0039] Fig.18 A schematic diagram of the comprehensive memory usage of the target game application provided in an embodiment of the present application;
[0040] Fig.19 A schematic diagram of the structure of a memory parsing device provided in an embodiment of the present application;
[0041] Fig. 20 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;
[0042] Fig.21A schematic diagram of the structure of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0044] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, 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 "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0045] It should be noted that the memory parsing method provided in the embodiment of the present application can be executed by a computer device, which can be a terminal device or a server. Among them, the terminal device includes but is not limited to a mobile phone, a computer, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server.
[0046] It should be noted that the information (including but not limited to memory usage information, etc.), data, and signals involved in the embodiments of the present application are authorized by the relevant objects or fully authorized by all parties, and the collection, use and processing of relevant data comply with the relevant laws, regulations and standards of relevant countries and regions.
[0047] To facilitate understanding of the memory parsing method provided in the embodiment of the present application, the following uses the execution subject of the memory parsing method as a terminal device as an example to exemplarily introduce the application scenario of the memory parsing method.
[0048] See also Figure 1 , Figure 1 Schematic diagram of application scenarios of the memory parsing method provided in the embodiment of the present application. Figure 1As shown, the application scenario includes a terminal device 110 and a terminal device 120, and the terminal device 110 and the terminal device 120 can communicate with each other in a wired or wireless manner. Among them, the terminal device 110 is a target device for supporting the operation of the target game application, and the terminal device 110 can execute the memory parsing method provided in the embodiment of the present application; the terminal device 120 is used to display the comprehensive memory occupancy of the target game application obtained by the terminal device 110 executing the memory parsing method provided in the embodiment of the present application.
[0049] In actual applications, the target game application to be tested can be controlled to run on the terminal device 110. During the running of the target game application, the terminal device 110 can obtain the first memory occupancy information of the target game application at the operating system level and the second memory occupancy information of the target game application at the game engine level through the low-level memory tracker (LLM) therein; in this way, the acquisition of more fine-grained memory occupancy information is achieved, and the obtained memory occupancy information is ensured to have high reliability and accurately reflect the memory occupancy of the relevant parts of the target game application when it is running.
[0050] In addition, during the operation of the target game application, the terminal device 110 can also obtain the native heap memory (NativeHeap) occupancy information of the target game application. The NativeHeap occupancy information can reflect the memory occupancy of the game engine and the called third-party library components when the target game application is running.
[0051] In addition, during the operation of the target game application, the terminal device 110 can also obtain the video memory occupancy information of the target game application, and the video memory occupancy information can reflect the video memory occupancy related to the graphics processing unit (GPU) when the target game application is running.
[0052] Ultimately, the terminal device 110 can determine the comprehensive memory occupancy of the target game application based on the first memory occupancy information of the target game application at the operating system level, the second memory occupancy information at the game engine level, the NativeHeap occupancy information and the video memory occupancy information; in this way, the comprehensive memory occupancy of the target game application is determined by comprehensively considering the memory occupancy information, NativeHeap occupancy information and the video memory occupancy information of the target game application at the operating system level and the game engine level, thereby ensuring that the comprehensive memory occupancy can reflect the rich storage resource occupancy of the target game application in multiple dimensions, and accordingly, it is conducive to the subsequent targeted optimization and adjustment of the target game application accordingly.
[0053] It should be understood that during the operation of the above-mentioned target game application, the terminal device 110 can transmit the comprehensive memory occupancy of the target game application determined by it to the terminal device 120 in real time, so that the terminal device 120 can display the comprehensive memory occupancy of the target game application in real time. Accordingly, relevant technical personnel can understand the memory occupancy of the target game application during its operation through the display content of the terminal device 120, and determine the adjustment and optimization direction of the target game application.
[0054] It should be understood that Figure 1 The application scenarios shown are only examples. In actual applications, the memory parsing method provided in the embodiments of the present application can also be applied to other scenarios. No limitation is made to the application scenarios of the memory parsing method provided in the embodiments of the present application.
[0055] The memory parsing method provided by the present application is described in detail below through a method embodiment.
[0056] See also Figure 2 , Figure 2 The following is a flow chart of the memory parsing method provided in the embodiment of the present application. Figure 2 As shown, the memory parsing method includes the following steps:
[0057] Step 201: Control the target game application to run in the target device.
[0058] In the embodiment of the present application, the target game application can be controlled to run in the target device first. For example, an automatic control program for the target game application can be started, and the target game application can be controlled to run in the target device through the automatic control program. Of course, in practical applications, the target game application can also be controlled to run in the target device by other means, such as manually controlling the target game application to run, and the embodiment of the present application does not make any limitation on the way of controlling the target game application to run.
[0059] It should be noted that the target game application is the memory parsing object in the embodiment of the present application, that is, in the embodiment of the present application, it is necessary to parse the memory usage of the target game application when it is running. The target game application can be any game application, such as a multiplayer online tactical competitive (Multiplayer Online Battle Arena, MOBA) game, a third-person shooter (Third-person Shooter, TPS) game, a first-person shooter (First-person Shooter, FPS) game, etc., and the embodiment of the present application does not make any limitation on the target game application. The target game application usually runs based on a game engine, and the game engine can specifically be Unreal Engine (Unreal Engine, UE).
[0060] It should be noted that the target device is an electronic device used to support the operation of the target game application. The target device may be, for example, a smart phone, tablet computer, computer, vehicle terminal, smart home, etc., on which the target game application is installed. The present embodiment of the application does not limit the target device in any way. In the present embodiment of the application, the target device may also be the execution subject of the memory parsing method provided in the present embodiment of the application, that is, the target device supporting the operation of the target game application parses the memory usage of the target device when the target game application is running.
[0061] Step 202: During the operation of the target game application, first memory occupancy information of the target game application at the operating system level and second memory occupancy information of the target game application at the game engine level are obtained through a low-level memory tracker.
[0062] During the operation of the target game application, the target device can obtain the first memory occupancy information of the target game application running therein at the operating system level and the second memory occupancy information of the target game application at the game engine level through the low-level memory tracker LLM therein.
[0063] Specifically, in actual applications, the code of the low-level memory tracker LLM and the target game application can be configured in advance to determine the memory data collection object of the low-level memory tracker LLM and the level to which the memory data collection object belongs (such as the operating system level or the game engine level). Accordingly, during the operation of the target game application, the low-level memory tracker LLM can obtain the memory occupancy information of the corresponding memory data collection object during the operation of the target game application according to the pre-configuration, and count it to the level to which it belongs to obtain the memory occupancy information of the level. For example, for a memory data collection object belonging to the operating system level, the low-level memory tracker LLM can count the memory occupancy information of the memory data collection object collected by it into the first memory occupancy information at the operating system level; for a memory data collection object belonging to the game engine level, the low-level memory tracker LLM can count the memory occupancy information of the memory data collection object collected by it into the second memory occupancy information at the game engine level.
[0064] It should be noted that the Low-Level Memory Tracker LLM is a tool that tracks memory usage in game engine (such as Unreal Engine) projects. The Low-Level Memory Tracker LLM uses a range tag system to record all memory allocated by the game engine and the operating system, and the Low-Level Memory Tracker LLM can support all platforms used by game engines. In actual applications, the Low-Level Memory Tracker LLM classifies memory by tagging memory applications to clearly understand the memory usage of each part of the project, and supports custom and independent tagging; compared with the memory detection tools provided by the game engine (such as Memreport), the memory usage information obtained by the Low-Level Memory Tracker LLM is more detailed and accurate, and the Low-Level Memory Tracker LLM is easier to expand.
[0065] It should be noted that the first memory occupancy information at the operating system level in the embodiment of the present application is the memory occupancy information of the target game application from the operating system dimension. The low-level memory tracker LLM can specifically count the first memory occupancy information at the operating system level through LLMPlatform therein; exemplarily, the statistical items at the operating system level may include Fmalloc, LLM Overhead, LLM total, the program code part counted by the game engine, and the program code part not counted by the game engine. Figure 3 An exemplary statistical diagram of first memory information provided in an embodiment of the present application, including memory usage information corresponding to statistical items of multiple operating system dimensions.
[0066] It should be noted that the second memory usage information at the game engine level in the embodiment of the present application is the memory usage information of the target game application counted from the game engine dimension. The low-level memory tracker LLM can specifically count the second memory usage information at the game engine level through LLMFull; illustratively, the statistical items at the game engine level may include UObject, Phyx, Malloc unused, Lua code, UI (User Interface), Filesystem&Fname&Assetregsitry, Shader, Wwise, Staticmesh, Animation, Engineprint, and StatsOverhead. Figure 4 A statistical diagram of an exemplary second memory information provided in an embodiment of the present application, including memory usage information corresponding to statistical items of multiple game engine dimensions, such as Figure 4 As shown, Lua code occupies 73.63MB of memory and ShaderMaps occupies 56.26MB of memory.
[0067] Step 203: During the running of the target game application, local heap memory occupancy information of the target game application and video memory occupancy information of the target game application are obtained.
[0068] During the running of the target game application, the target device will also obtain the NativeHeap occupancy information of the target game application. Specifically, in actual applications, the game engine of the target game application can be configured in advance to determine the NativeHeap collection range; accordingly, during the running of the target game application, the target device can obtain the NativeHeap occupancy information of the collection object within the NativeHeap collection range based on the relevant memory function.
[0069] It should be noted that the NativeHeap occupancy information in the embodiment of the present application refers to the occupancy of the local heap memory of the target device during the operation of the target game application. Generally, the NativeHeap occupancy information may include the memory occupancy of the third-party library components called by the target game application and the memory occupancy of the game engine itself. Figure 5 An exemplary statistical diagram of NativeHeap occupancy information provided in the embodiment of the present application is shown in FIG. Figure 5 As shown in the figure, the third-party library component gcloud called by the target game application occupies 10232272 bytes, and the game engine itself occupies 1741798 bytes.
[0070] During the running of the target game application, the target device will also obtain the video memory occupancy information of the target game application. Specifically, the target device can obtain the video memory occupancy information of the target game application with the help of the memory acquisition instruction in the operating system.
[0071] It should be noted that the video memory occupancy information in the embodiment of the present application is used to reflect the memory occupancy of GPU-related graphics resources during the operation of the target game application, which includes three parts: GFX Dev, EGL Mtrack, and GLMtrack. Figure 6 An exemplary statistical diagram of video memory occupancy information provided in an embodiment of the present application is as follows: Figure 6 As shown, the video memory usage information includes three parts: GFX Dev, EGL Mtrack, and GLMtrack. Among them, Gfx dev occupies 154860 bytes, EGLmtrack occupies 47640 bytes, and GLmtrack occupies 286992 bytes.
[0072] It should be understood that in the embodiment of the present application, the acquisition of the first memory occupancy information, the second memory occupancy information, the NativeHeap occupancy information and the video memory occupancy information are all executed following the operation of the relevant parts of the target game application, and the acquisition of the four occupancy information does not have a fixed execution order.
[0073] Step 204: Determine the comprehensive memory occupancy of the target game application according to the first memory occupancy information, the second memory occupancy information, the local heap memory occupancy information and the video memory occupancy information.
[0074] After the target device obtains the above-mentioned first memory occupancy information, second memory occupancy information, NativeHeap occupancy information and video memory occupancy information, it can integrate and count the several types of information to finally obtain the comprehensive memory occupancy of the target game application. Specifically, the first memory occupancy information, the second memory occupancy information, NativeHeap occupancy information and video memory occupancy information can be integrated into a specific data structure (such as a chart structure, etc.) to clearly display the comprehensive memory occupancy of the target game application through the specific data structure.
[0075] The memory parsing method provided in the embodiment of the present application, compared with the related art that only uses the PSS indicator to reflect the overall memory occupancy of the game application, obtains the memory occupancy information of the target game application at the operating system level and the game engine level through the low-level memory tracker LLM, realizes the acquisition of more fine-grained memory occupancy information, and ensures that the obtained memory occupancy information has high reliability, and can accurately reflect the memory occupancy of the relevant parts of the target game application when it is running. On the other hand, the NativeHeap occupancy information of the target game application is obtained to determine the memory occupancy of the game engine and the called third-party library components when the target game application is running. On the other hand, the graphics memory occupancy information of the target game application is obtained to determine the graphics memory occupancy related to the GPU when the target game application is running. Finally, the comprehensive memory occupancy of the target game application is determined by comprehensively considering the memory occupancy information at the operating system level and the game engine level, the NativeHeap occupancy information, and the graphics memory occupancy information, which can ensure that the comprehensive memory occupancy can reflect the rich storage resource occupancy of the target game application in multiple dimensions, and accordingly, it is conducive to the subsequent targeted optimization and adjustment of the target game application based on this.
[0076] In a possible implementation, in order to collect the first memory occupancy information at the operating system level and the second memory occupancy information at the game engine level, the low-level memory tracker LLM and the code corresponding to the target game application may have the following configuration:
[0077] The low-level memory tracker LLM has a first macro definition of the operating system statistics item and a second macro definition of the game engine statistics item added thereto, and the low-level memory tracker LLM has an operating system statistics tag corresponding to the first macro definition and a game engine statistics tag corresponding to the second macro definition added thereto. The code corresponding to the target game application has a first range tag corresponding to the operating system statistics item and a second range tag corresponding to the game engine statistics item inserted therein; the first range tag is used to indicate the statistical position of the first memory occupancy information at the operating system level, and the second range tag is used to indicate the statistical position of the second memory occupancy information at the game engine level.
[0078] For example, Figure 7 A schematic diagram of the configuration flow of the game engine provided in the embodiment of the present application. Figure 2 Before obtaining the comprehensive memory usage of the target game application, you need to first Figure 7 The process shown configures the game engine to provide a basis for obtaining the first memory occupancy information at the operating system level, the second memory occupancy information at the game engine level, and the NativeHeap occupancy information.
[0079] Specifically, several operating system statistics items and several game engine statistics items can be set according to actual needs first; the operating system statistics items are the items that need to be counted when counting the first memory usage information at the operating system level, and the operating system statistics items can include but are not limited to Fmalloc, LLM Overhead, LLM total, the program code part counted by the game engine, the program code part that cannot be counted by the game engine, etc.; the game engine statistics items are the items that need to be counted when counting the second memory usage information at the game engine level, and the game engine statistics items can include but are not limited to UObject, Phyx, Malloc unused, Lua code, UI (User Interface), Filesystem&Fname&Assetregsitry, Shader, Wwise, Staticmesh, Animation, Engineprint, Stats Overhead, etc.
[0080] For each operating system statistic item, a corresponding first macro definition may be added in the low-level memory tracker LLM; for each game engine statistic item, a corresponding second macro definition may be added in the low-level memory tracker LLM. Figure 8 A schematic diagram of an exemplary Tag macro definition provided in an embodiment of the present application, including Tag macro definitions of several statistical items; Figure 8 801 shows a UI statistic item, and the Tag attribute of the UI statistic item belongs to STAT_UILLM.
[0081] Furthermore, statistical tags corresponding to the above-mentioned macro definitions may be added in the low-level memory tracker LLM, that is, operating system statistical tags corresponding to the first macro definitions of each operating system statistical item may be added in the low-level memory tracker LLM, and game engine statistical tags corresponding to the second macro definitions of each game engine statistical item may be added in the low-level memory tracker LLM. Fig. 9 A schematic diagram of an exemplary adding Tag statistics provided in an embodiment of the present application is as follows: Fig. 9 As shown in 901, a statistical tag corresponding to the UI statistical item is added in the low-level memory tracker LLM, and the statistical tag is divided into LLMFull, so as to count the memory usage information corresponding to the UI statistical item at the game engine level, that is, the game engine statistical tag corresponding to the UI item is added in the LLM.
[0082] In addition, it is also necessary to insert the first range tag corresponding to the above operating system statistics item into the code corresponding to the target game application, indicating the statistical position of the first memory occupancy information corresponding to the operating system statistics item; for example, assuming that the first range tag corresponding to the operating system statistics item A is inserted into the code segment a included in the code corresponding to the target game application, then, during the operation of the target game application, the memory occupancy information of the code segment a during operation can be obtained, and the first memory occupancy information of the operating system statistics item A can be determined accordingly. It is also necessary to insert the second range tag corresponding to the above game engine statistics item into the code corresponding to the target game application, indicating the statistical position of the second memory occupancy information corresponding to the game engine statistics item; for example, assuming that the second range tag corresponding to the game engine statistics item B is inserted into the code segment b included in the code corresponding to the target game application, then, during the operation of the target game application, the memory occupancy information of the code segment b during operation can be obtained, and the second memory occupancy information of the game engine statistics item B can be determined accordingly. Fig.10 An exemplary schematic diagram of inserting a tag range tag into a code is provided in an embodiment of the present application. Fig.10 The 1001 in the figure is the range label corresponding to the UI statistic item. Since the UI statistic item is configured to belong to LLMFull in the configuration of the low-level memory tracker LLM, Fig.10 1001 is a second range tag; accordingly, the memory occupancy information of the code segment TakeWidget inserted with the second range tag will be used to count the second memory occupancy information corresponding to the UI item at the game engine level.
[0083] In this way, by pre-configuring the low-level memory tracker LLM and the code of the target game application in the above manner, the operating system statistics and game engine statistics items that need to be collected can be flexibly configured according to actual needs, and any code segments in the target game application can be flexibly included in the operating system statistics or game engine statistics, which is conducive to the flexible collection of memory usage information at the operating system level and the game engine level.
[0084] Based on the above configuration, the target device can obtain the first memory usage information of the target game application at the operating system level and the second memory usage information of the target game application at the game engine level through the low-level memory tracker LLM in the following manner:
[0085] When the first code segment with the first range tag inserted in the target game application is running, the first sub-memory occupancy information of the first code segment when running is obtained through the low-level memory tracker LLM; the first memory occupancy information is counted according to the first sub-memory occupancy information. When the second code segment with the second range tag inserted in the target game application is running, the second sub-memory occupancy information of the second code segment when running is obtained through the low-level memory tracker LLM; the second memory occupancy information is counted according to the second sub-memory occupancy information.
[0086] Specifically, in an embodiment of the present application, a code segment with a first range tag corresponding to a certain operating system statistical item inserted into the target game application is regarded as a first code segment, and a code segment with a second range tag corresponding to a certain game engine statistical item inserted into the target game application is regarded as a second code segment. During the operation of the target game application, if a first code segment is called to run, the memory occupancy information of the first code segment during operation can be obtained through the low-level memory tracker LLM as the first sub-memory occupancy information, and the first memory occupancy information at the operating system level is counted based on the first sub-memory occupancy information. Similarly, during the operation of the target game application, if a second code segment is called to run, the memory occupancy information of the second code segment during operation can be obtained through the low-level memory tracker LLM as the second sub-memory occupancy information, and the second memory occupancy information at the game engine level is counted based on the second sub-memory occupancy information.
[0087] Fig.11 A memory acquisition diagram of an exemplary low-level memory tracker LLM provided in an embodiment of the present application is shown in FIG. Fig.11 As shown in the figure, a scope tag LLM_SCOPE{ELLMTag:xxx} is inserted into a code segment of the target game application. Fig.11When the FMemory::Malloc function in the code snippet shown in the figure is called, the low-level memory tracker LLM will allocate the memory usage information of the function to the corresponding statistical item based on the Tag macro definition and statistical tag of the statistical item corresponding to the range tag. The low-level memory tracker LLM will monitor and capture the memory usage information of each statistical item within the statistical range in real time. Even if some memory allocations are not marked with the corresponding range tag, they can be aggregated to LLMPlatform by relying on OnLowLevelAlloc in the low-level memory tracker LLM, that is, aggregated to the operating system level.
[0088] In this way, by obtaining the first memory occupancy information at the operating system level and the second memory occupancy information at the game engine level in the above manner, it can be ensured that the obtained first memory occupancy information and the second memory occupancy information meet the actual statistical testing requirements and accurately reflect the occupancy of the memory resources of the target device by the relevant parts of the target game application.
[0089] In actual applications, the operating system statistics items may include multiple items, and at least one first range tag corresponding to each operating system statistics item may be inserted into the code corresponding to the target game application. Accordingly, when the first memory occupancy information at the operating system level is counted based on the first sub-memory occupancy information, the first memory occupancy information corresponding to the target operating system statistics item may be counted based on the first sub-memory occupancy information; the target operating system statistics item is the operating system statistics item corresponding to the first range tag inserted in the first code segment.
[0090] Specifically, for each operating system statistical item, the first range tag corresponding to the operating system statistical item can be inserted into one or more code segments in the target game application according to actual needs; for example, for operating system statistical item A, the first range tag corresponding to the operating system statistical item A can be inserted into code segments a1, a2, and a3 of the target game application. Accordingly, when a first code segment in the target game application with the first range tag inserted is running, the low-level memory tracker LLM can obtain the first sub-memory occupancy information when the first code segment is running, and count the first sub-memory occupancy information under the operating system statistical item corresponding to the first range tag inserted in the first code segment; for example, for operating system statistical item A, its corresponding first memory occupancy information can be composed of the first sub-memory occupancy information when the code segments a1, a2, and a3 are each running.
[0091] In this way, one or more different statistical locations can be set for each operating system statistical item according to actual needs, and the total memory occupancy information (i.e., the first memory occupancy information) of the operating system statistical item can be determined based on the sub-memory occupancy information of each statistical location (i.e., each code segment) during its execution, thereby ensuring accurate statistics of memory occupancy at the operating system level.
[0092] In actual applications, the game engine statistics items may include multiple items, and at least one second range tag corresponding to each game engine statistics item may be inserted into the code corresponding to the target game application. Accordingly, when the second memory occupancy information at the game engine level is counted based on the second sub-memory occupancy information, the second memory occupancy information corresponding to the target game engine statistics item may be counted based on the second sub-memory occupancy information; the target game engine statistics item is the game engine statistics item corresponding to the second range tag inserted in the second code segment.
[0093] Specifically, for each game engine statistic item, the second range tag corresponding to the game engine statistic item can be inserted into one or more code segments in the target game application according to actual needs; for example, for game engine statistic item B, the second range tag corresponding to the game engine statistic item B can be inserted into code segments b1, b2, and b3 of the target game application. Accordingly, when a second code segment in the target game application into which the second range tag is inserted is running, the low-level memory tracker LLM can obtain the second sub-memory occupancy information when the second code segment is running, and count the second sub-memory occupancy information under the game engine statistic item corresponding to the second range tag inserted in the second code segment; for example, for game engine statistic item B, its corresponding second memory occupancy information can be composed of the second sub-memory occupancy information when the code segments b1, b2, and b3 are each running.
[0094] In this way, one or more different statistical locations can be set for each game engine statistical item according to actual needs, and the total memory occupancy information (i.e., the second memory occupancy information) of the game engine statistical item can be determined according to the sub-memory occupancy information of each statistical location (i.e., each code segment) during its execution, thereby ensuring accurate statistics of the memory occupancy at the game engine level.
[0095] In a possible implementation, in order to collect the NativeHeap occupancy information, the game engine corresponding to the target game application may have the following configuration:
[0096] A NativeHeap collection range is configured in the game engine of the target game application. The NativeHeap collection range is used to indicate a collection object corresponding to the NativeHeap occupancy information. The collection object includes a third-party library component and a game engine called by a game process of the target game application.
[0097] like Figure 7 As shown, based on Figure 2 Before obtaining the comprehensive memory usage of the target game application, you need to first Figure 7 The process shown configures the game engine to provide a basis for obtaining the first memory occupancy information at the operating system level, the second memory occupancy information at the game engine level, and the NativeHeap occupancy information.
[0098] Specifically, the NativeHeap collection scope may be set according to actual needs, and the NativeHeap collection scope may specifically include various collection objects of NativeHeap occupancy information. Fig.12 A schematic diagram of an exemplary NativeHeap collection range provided in an embodiment of the present application is shown as follows: Fig.12 As shown, various collection objects of NativeHeap occupancy information can be defined within the NativeHeap collection scope. The collection objects can be various third-party library components (such as Bugly-msdk, gcloud, etc.) called by the game process of the target game application, and can also be the game engine itself.
[0099] It should be understood that third-party library components can be provided by shared libraries (shared object, so), which are binary codes that can be run directly by the machine and are dynamic link libraries on operating systems (such as Android). The ABI (Application Binary Interface) supported by each application is determined by the .so files provided by the APK (Application package). These .so files are packaged in the lib / <abi>The third-party library component can be understood as a component that is not integrated into the game engine, which supports calling it when the target game application is running. Accordingly, the memory usage generated by calling the third-party library component is counted in the NativeHeap usage information.
[0100] In this way, by pre-configuring the game engine of the target game application in the above manner, the collection object of the NativeHeap occupancy information can be flexibly configured according to actual needs, which is conducive to realizing the flexible collection of the NativeHeap occupancy information.
[0101] Based on the above configuration, the target device can obtain the NativeHeap occupancy information of the target game application in the following ways:
[0102] Obtain a third-party library component called when the target game application is running; parse the file of the third-party library component to obtain a corresponding memory function and a corresponding index of the memory function; and determine the base address offset of the memory function according to the corresponding index of the memory function; replace the base address offset with a custom memory function, and obtain the NativeHeap occupancy information of the third-party library component through the custom memory function.
[0103] Fig.13 The following is a schematic diagram of obtaining an exemplary NativeHeap occupancy information provided in the embodiment of the present application. Fig.13 As shown, when obtaining the NativeHeap occupancy information of the third-party library component, the cat maps instruction can be used to obtain the so dynamic library list of the game process of the target game application, including the third-party library components called by the game process. Then, the ELF (Executable and Linkable Format) file of the third-party library component (i.e., so file) is parsed to obtain fields such as dynsym, dynstr, and relplt; the function names of various related memory functions, such as malloc, calloc, realloc, and free, can be obtained through the dynstr field; the corresponding indexes of various memory functions can be obtained through the dynsym field; the base address offset of the memory function can be found according to the corresponding index of the obtained memory function through the relplt field. Then, the found base address offset can be replaced with a custom memory function (i.e., a custom hook function), such as my_malloc, my_calloc, my_realloc, and my_free. Based on the custom memory function, the bottom layer on all NativeHeaps can be captured, that is, the NativeHeap occupancy information of the third-party library component can be obtained.
[0104] In this way, by obtaining the NativeHeap occupancy information of the target game application in the above manner and replacing the base address offset of the memory function with the custom memory function in this application, the accuracy and reliability of the NativeHeap occupancy information of the third-party library component obtained can be guaranteed, that is, the NativeHeap occupancy information of the third-party library component can be guaranteed to accurately reflect the actual memory occupancy of the third-party library component.
[0105] In a possible implementation, the target device may specifically obtain the video memory usage information of the target game application in the following manner:
[0106] The memory acquisition instruction provided by the operating system of the target device is used to obtain the memory overview information corresponding to the target game application, and the memory information corresponding to the graphics processor GPU is obtained from the memory overview information as the video memory occupancy information.
[0107] Fig.14 An exemplary schematic diagram of obtaining video memory occupancy information provided in an embodiment of the present application. In actual applications, the target device can obtain memory overview information during the operation of the target game application with the help of memory acquisition instructions such as dumpsys meminfo provided by its operating system; then, the GPU-related memory information can be extracted from the memory overview information, specifically, the three parts of Gfx dev, EGL mtrack, and GLmtrack can be extracted, and these three parts are used to form the video memory occupancy information of the target game application.
[0108] In this way, by obtaining the video memory occupancy information of the target game application in the above manner, the accuracy and reliability of the obtained video memory occupancy information can be guaranteed, that is, the obtained video memory occupancy information can be guaranteed to accurately and reliably reflect the occupancy of the GPU by the target game application.
[0109] In a possible implementation, in addition to obtaining the first memory occupancy information of the target game application at the operating system level, the second memory occupancy information at the game engine level, the NativeHeap occupancy information, and the video memory occupancy information, the target device can also obtain the texture memory information and model memory information related to the target game application through the performance analysis tool in the game engine of the target game application. Then, the comprehensive memory occupancy of the target game application is determined according to the first memory occupancy information of the target game application at the operating system level, the second memory occupancy information at the game engine level, the NativeHeap occupancy information, and the video memory occupancy information, as well as the texture memory information and the model memory information.
[0110] In the related art, when it is determined that the memory usage of a game application is too high or there is an abnormal memory growth compared with historical versions based on the PSS indicator used to measure the overall memory usage of a game application, a performance analysis tool (such as Memreport) in the game engine is usually used for analysis, and the memory anomalies found through analysis are tentatively optimized. However, the memory data collected by the performance analysis tool in the game engine usually reflects the usage of hard disk resources by the game application, which cannot accurately correspond to the PSS indicator. Accordingly, it is not reliable to determine the optimization direction of the game application based on the analysis results of the performance analysis tool, that is, it is difficult to accurately determine the items to be optimized in the game application, and it is difficult to optimize and adjust the game application in a targeted and reliable manner.
[0111] In an embodiment of the present application, the first memory occupancy information of the target game application at the operating system level and the second memory occupancy information at the game engine level determined by the low-level memory tracker LLM, as well as the NativeHeap occupancy information and the video memory occupancy information of the target game application are innovatively utilized to reflect the comprehensive memory occupancy of the target game application. Compared with the memory occupancy of the game application determined by the performance analysis tool in the game engine, the embodiment of the present application utilizes the above-mentioned first memory occupancy information, second memory occupancy information, NativeHeap occupancy information and video memory occupancy information to reflect the comprehensive memory occupancy of the target game application, which can more accurately and reliably reflect the occupancy of memory resources during the operation of the target game application, rather than the occupancy of hard disk resources.
[0112] In addition, considering that some indicators determined by the performance analysis tools (such as Memreport) in the game engine can accurately reflect the memory usage, therefore, in the embodiment of the present application, these indicators can be included in the comprehensive memory usage of the target game application. Specifically, under normal circumstances, since the textures and models in the target game application are loaded in real time during operation, the texture memory information and model memory information collected by Memreport in the game engine can accurately reflect the memory usage of the relevant texture resources and model resources, rather than the usage of the hard disk; based on this, in the embodiment of the present application, the texture memory information and model memory information related to the target game application can be obtained through Memreport in the game engine, and it can also be included in the statistics of the comprehensive memory usage of the target game application.
[0113] Fig.15 The following is a schematic diagram of obtaining an exemplary Memreport memory data provided in the embodiment of the present application. Fig.15 As shown, the target device can acquire data through Memreport-full in Memreport; then, extract all Texture items (including Texture memory 3D, Texture memory cube, Texture memory 2D, and Render Target memory) from the RHI resource data in the acquired data and accumulate them to obtain the texture memory information; and extract all buffer items (including Uniform buffer, Pixel buffer, Vertex buffer, and Index buffer) from the RHI resource data and accumulate them to obtain the model memory information.
[0114] Fig.16 A schematic diagram of obtaining memory usage information provided in an embodiment of the present application. Fig.16 As shown, the target device can first configure the game engine for the target game application; then, obtain LLM memory data (i.e., obtain the first memory occupancy information at the operating system level and the second memory occupancy information at the game engine level through the low-level memory tracker LLM), NativeHeap memory data (i.e., NativeHeap occupancy information), video memory data (i.e., video memory occupancy information), and Memreport memory data (i.e., texture memory information and model memory information), and then summarize the acquired memory data to obtain the comprehensive memory occupancy of the target game application. It should be understood that Fig.16 The order of obtaining the various memory data shown is only an example. In actual applications, the order of obtaining the above-mentioned memory data can be set according to actual needs, and the embodiments of the present application do not impose any limitation on this.
[0115] In this way, through the above method, using Memreport in the game engine, accurate texture memory information and model memory information can be obtained, and incorporated into the statistics of the comprehensive memory usage of the target game application. Under the premise of ensuring that the comprehensive memory usage has high accuracy and reliability, the richness of the information reflected by the comprehensive memory usage can be further improved, which is more conducive to providing targeted optimization directions for the target game application.
[0116] In a possible implementation, the historical version of the target game application and the test version of the target game application can be respectively run on two identical target devices, and then the comprehensive memory occupancy of the historical version of the target game application is determined by the method described above as the first comprehensive memory occupancy, and the comprehensive memory occupancy of the test version of the target game application is determined by the method described above as the second comprehensive memory occupancy. Furthermore, the items to be optimized corresponding to the test version of the target game application can be determined based on the first comprehensive memory occupancy and the second comprehensive memory occupancy.
[0117] Specifically, for the historical version of the target game application, the target device can use the memory parsing method provided in the embodiment of the present application to determine the first memory usage information at the operating system level, the second memory usage information at the game engine level, the NativeHeap usage information, the video memory usage information, the texture memory information and the model memory information of the historical version of the target game application during the running of the historical version of the target game application, and then determine the first comprehensive memory usage corresponding to the historical version of the target game application based on these memory usage information.
[0118] Similarly, for the test version of the target game application, the target device can use the memory parsing method provided in the embodiments of the present application to determine the first memory usage information of the test version at the operating system level, the second memory usage information at the game engine level, the NativeHeap usage information, the video memory usage information, the texture memory information and the model memory information during the running of the test version of the target game application, and then determine the second comprehensive memory usage corresponding to the test version of the target game application based on these memory usage information.
[0119] Fig.17 A statistical diagram of a comprehensive memory usage provided in an embodiment of the present application. Fig.17 As shown, for the historical version and test version of the target game application, LLM memory data can be extracted from key items, NativeHeap memory data can be summarized and accumulated, video memory can be summarized and displayed, and Memreport can be summarized and displayed to achieve a summary display of the full data of memory usage. Furthermore, the full data between versions can be compared.
[0120] Fig.18 This is a schematic diagram of the comprehensive memory usage of a target game application provided in an embodiment of the present application. Fig.18 As shown, the data obtained through LLM_Platform is the first memory occupancy information at the operating system level, the data obtained through LLM_FULL is the second memory occupancy information at the game engine level, the data obtained through the hook method is NativeHeap occupancy information, the data obtained through dumpsys meminfo is video memory occupancy information, and the data obtained through Memreport includes texture memory information and model memory information. Fig.18 The fourth column of data is the second comprehensive memory usage of the test version of the target game application. Fig.18 The fifth column of data shows the first comprehensive memory usage of historical versions of the target game application.
[0121] By comparison Fig.18 From the fourth and fifth columns of data, we can find that in the Texture statistics, Mallocunused statistics, and GLES statistics, the test version of the target game application has abnormal growth compared with the historical version. Accordingly, we can determine the items to be optimized in the test version of the target game application based on these statistics with abnormal memory growth.
[0122] In this way, through the above-mentioned method, based on the memory analysis method provided in the embodiment of the present application, the comprehensive memory occupancy of the historical version and the test version of the target game application are determined respectively. By comparing the comprehensive memory occupancy of these two versions, the items to be optimized in the test version can be accurately and reliably determined. Based on this, targeted optimization of the test version of the target game application can be achieved, thereby improving the research and development efficiency of the target game application.
[0123] With respect to the memory parsing method described above, the present application also provides a corresponding memory parsing device so that the above memory parsing method can be applied and implemented in practice.
[0124] See also Fig.19 , Fig.19 It is the same as above Figure 2 The schematic diagram of the structure of the memory parsing device 1900 corresponding to the memory parsing method shown in FIG. Fig.19 As shown, the memory parsing device 1900 includes:
[0125] The application running module 1901 is used to control the target game application to run in the target device;
[0126] The memory acquisition module 1902 is used to acquire, during the operation of the target game application, first memory occupancy information of the target game application at the operating system level and second memory occupancy information of the target game application at the game engine level through a low-level memory tracker;
[0127] The memory acquisition module 1902 is further used to acquire local heap memory occupancy information of the target game application and video memory occupancy information of the target game application during the running of the target game application;
[0128] The memory analysis module 1903 is used to determine the comprehensive memory occupancy of the target game application according to the first memory occupancy information, the second memory occupancy information, the local heap memory occupancy information and the video memory occupancy information.
[0129] Optionally, a first macro definition of an operating system statistic item and a second macro definition of a game engine statistic item are added to the low-level memory tracker, and an operating system statistic tag corresponding to the first macro definition and a game engine statistic tag corresponding to the second macro definition are added to the low-level memory tracker;
[0130] A first range tag corresponding to the operating system statistical item and a second range tag corresponding to the game engine statistical item are inserted into the code corresponding to the target game application; the first range tag is used to indicate the statistical position of the first memory occupancy information at the operating system level, and the second range tag is used to indicate the statistical position of the second memory occupancy information at the game engine level.
[0131] Optionally, the memory acquisition module 1902 is specifically used for:
[0132] When the first code segment with the first scope tag inserted in the target game application is running, obtaining first sub-memory occupancy information of the first code segment when the first code segment is running through the low-level memory tracker; and collecting statistics of the first memory occupancy information according to the first sub-memory occupancy information;
[0133] When the second code segment with the second range tag inserted in the target game application is running, the second sub-memory occupancy information of the second code segment during the running is obtained through the low-level memory tracker; and the second memory occupancy information is counted according to the second sub-memory occupancy information.
[0134] Optionally, the operating system statistics item includes a plurality of items, and at least one first range tag corresponding to each of the operating system statistics items is inserted into the code corresponding to the target game application; the memory acquisition module 1902 is specifically used to:
[0135] According to the first sub-memory occupancy information, first memory occupancy information corresponding to a target operating system statistic item is counted; the target operating system statistic item is an operating system statistic item corresponding to the first range tag inserted in the first code segment.
[0136] Optionally, the game engine statistics item includes a plurality of items, and at least one second range tag corresponding to each of the game engine statistics items is inserted into the code corresponding to the target game application; the memory acquisition module 1902 is specifically used to:
[0137] According to the second sub-memory occupancy information, second memory occupancy information corresponding to a target game engine statistic item is counted; the target game engine statistic item is a game engine statistic item corresponding to the second range tag inserted in the second code segment.
[0138] Optionally, a local heap memory collection range is configured in the game engine of the target game application, and the local heap memory collection range is used to indicate a collection object corresponding to the local heap memory occupancy information, and the collection object includes a third-party library component called by the game process of the target game application and the game engine.
[0139] Optionally, the memory acquisition module 1902 is specifically used for:
[0140] Obtain the third-party library component called when the target game application is running;
[0141] Parsing the file of the third-party library component to obtain a corresponding memory function and a corresponding index of the memory function; and determining a base address offset of the memory function according to the corresponding index of the memory function;
[0142] The base address offset is replaced with a custom memory function, and the local heap memory occupancy information of the third-party library component is obtained through the custom memory function.
[0143] Optionally, the memory acquisition module 1902 is specifically used for:
[0144] The memory overview information corresponding to the target game application is obtained through the memory acquisition instruction provided by the operating system of the target device; and the memory information corresponding to the graphics processor is obtained from the memory overview information as the video memory occupancy information.
[0145] Optionally, the memory acquisition module 1902 is further used for:
[0146] Acquire texture memory information and model memory information related to the target game application through a performance analysis tool in the game engine of the target game application;
[0147] The memory parsing module 1903 is specifically used for:
[0148] The comprehensive memory occupancy of the target game application is determined according to the first memory occupancy information, the second memory occupancy information, the local heap memory occupancy information, the video memory occupancy information, the texture memory information and the model memory information.
[0149] Optionally, the device further includes: a version comparison module; the version comparison module is used to:
[0150] Obtaining the comprehensive memory occupancy of the historical version of the target game application as the first comprehensive memory occupancy; obtaining the comprehensive memory occupancy of the test version of the target game application as the second comprehensive memory occupancy;
[0151] According to the first comprehensive memory usage and the second comprehensive memory usage, the items to be optimized corresponding to the test version of the target game application are determined.
[0152] The memory parsing device provided in the embodiment of the present application, on the one hand, obtains the memory occupancy information of the target game application at the operating system level and the game engine level through the low-level memory tracker LLM, realizes the acquisition of more fine-grained memory occupancy information, and ensures that the obtained memory occupancy information has high reliability, and can accurately reflect the memory occupancy of the relevant parts of the target game application when it is running. On the other hand, the NativeHeap occupancy information of the target game application is obtained to determine the memory occupancy of the game engine and the called third-party library components when the target game application is running. On the other hand, the graphics memory occupancy information of the target game application is obtained to determine the graphics memory occupancy related to the GPU when the target game application is running. Finally, the comprehensive memory occupancy of the target game application is determined by comprehensively considering the memory occupancy information at the operating system level and the game engine level, the NativeHeap occupancy information, and the graphics memory occupancy information, which can ensure that the comprehensive memory occupancy can reflect the rich storage resource occupancy of the target game application in multiple dimensions, and accordingly, it is conducive to the subsequent targeted optimization and adjustment of the target game application based on this.
[0153] The embodiment of the present application also provides a computer device for parsing memory, which may specifically be a terminal device or a server. The terminal device and server provided in the embodiment of the present application will be introduced below from the perspective of hardware instantiation.
[0154] See also Fig. 20 , Fig. 20 Schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Fig. 20 For the sake of convenience, only the parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. The terminal can be any terminal device including a mobile phone, a tablet computer, a personal digital assistant (PDA), a point of sales (POS), a car computer, etc., taking the terminal as a computer as an example:
[0155] Fig. 20 FIG. 1 is a block diagram showing a partial structure of a computer related to a terminal provided in an embodiment of the present application. Fig. 20 The computer includes: a radio frequency (RF) circuit 2010, a memory 2020, an input unit 2030 (including a touch panel 2031 and other input devices 2032), a display unit 2040 (including a display panel 2041), a sensor 2050, an audio circuit 2060 (which can be connected to a speaker 2061 and a microphone 2062), a wireless fidelity (WiFi) module 2070, a processor 2080, and a power supply 2090. Those skilled in the art can understand that Fig. 20 The computer structure shown in the figure does not constitute a limitation of the computer, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0156] The memory 2020 can be used to store software programs and modules. The processor 2080 executes various functional applications and data processing of the computer by running the software programs and modules stored in the memory 2020. The memory 2020 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer (such as audio data, a phone book, etc.), etc. In addition, the memory 2020 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0157] The processor 2080 is the control center of the computer. It uses various interfaces and lines to connect various parts of the entire computer. It executes various functions of the computer and processes data by running or executing software programs and / or modules stored in the memory 2020 and calling data stored in the memory 2020. Optionally, the processor 2080 may include one or more processing units; preferably, the processor 2080 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 2080.
[0158] In an embodiment of the present application, the processor 2080 included in the terminal is also used to execute the steps of any implementation method of the memory parsing method provided in the embodiment of the present application.
[0159] See also Fig.21 , Fig.21 A schematic diagram of the structure of a server 2100 provided for an embodiment of the present application. The server 2100 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 2122 (for example, one or more processors) and memory 2132, and one or more storage media 2130 (for example, one or more mass storage devices) storing application programs 2142 or data 2144. Among them, the memory 2132 and the storage medium 2130 may be temporary storage or permanent storage. The program stored in the storage medium 2130 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 2122 may be configured to communicate with the storage medium 2130 and execute a series of instruction operations in the storage medium 2130 on the server 2100.
[0160] The server 2100 may also include one or more power supplies 2126, one or more wired or wireless network interfaces 2150, one or more input and output interfaces 2158, and / or one or more operating systems, such as Windows Server 2000. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM etc.
[0161] The steps performed by the server in the above embodiment can be based on the Fig.21 The server structure shown.
[0162] Among them, CPU 2122 can also be used to execute the steps of any implementation method of the memory parsing method provided in the embodiments of the present application.
[0163] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program, wherein the computer program is used to execute any one of the implementation methods of a memory parsing method described in the aforementioned embodiments.
[0164] The embodiment of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes any one of the implementations of the memory parsing method described in the above embodiments.
[0165] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0166] In the 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 only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0167] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0168] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0169] 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 this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store computer programs.
[0170] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.
[0171] As described above, 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 aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.< / abi>
Claims
1. A memory parsing method, characterized in that: The method comprises: Control the target game application to run in the target device; During the running of the target game application, obtaining, by means of a low-level memory tracker, first memory occupancy information of the target game application at an operating system level and second memory occupancy information of the target game application at a game engine level; During the running of the target game application, obtaining local heap memory occupancy information of the target game application and obtaining video memory occupancy information of the target game application; The comprehensive memory occupancy of the target game application is determined according to the first memory occupancy information, the second memory occupancy information, the local heap memory occupancy information and the video memory occupancy information.
2. The method according to claim 1, characterized in that The low-level memory tracker is added with a first macro definition of an operating system statistic item and a second macro definition of a game engine statistic item, and the low-level memory tracker is added with an operating system statistic tag corresponding to the first macro definition and a game engine statistic tag corresponding to the second macro definition; A first range tag corresponding to the operating system statistical item and a second range tag corresponding to the game engine statistical item are inserted into the code corresponding to the target game application; the first range tag is used to indicate the statistical position of the first memory occupancy information at the operating system level, and the second range tag is used to indicate the statistical position of the second memory occupancy information at the game engine level.
3. The method according to claim 2, characterized in that The step of obtaining, by means of a low-level memory tracker, first memory occupancy information of the target game application at an operating system level and second memory occupancy information of the target game application at a game engine level comprises: When the first code segment with the first scope tag inserted in the target game application is running, obtaining first sub-memory occupancy information of the first code segment when the first code segment is running through the low-level memory tracker; and collecting statistics of the first memory occupancy information according to the first sub-memory occupancy information; When the second code segment with the second range tag inserted in the target game application is running, the second sub-memory occupancy information of the second code segment during the running is obtained through the low-level memory tracker; and the second memory occupancy information is counted according to the second sub-memory occupancy information.
4. The method according to claim 3, characterized in that The operating system statistics items include a plurality of items, and at least one first range tag corresponding to each of the operating system statistics items is inserted into the code corresponding to the target game application; The collecting statistics of the first memory occupancy information according to the first sub-memory occupancy information includes: According to the first sub-memory occupancy information, first memory occupancy information corresponding to the statistical item of the target operating system is counted; The target operating system statistic item is an operating system statistic item corresponding to the first range tag inserted in the first code segment.
5. The method according to claim 3, characterized in that: The game engine statistics items include a plurality of items, and at least one second range tag corresponding to each of the game engine statistics items is inserted into the code corresponding to the target game application; The collecting statistics of the second memory occupancy information according to the second sub-memory occupancy information includes: According to the second sub-memory occupancy information, second memory occupancy information corresponding to the target game engine statistical item is counted; The target game engine statistic item is a game engine statistic item corresponding to the second range tag inserted in the second code segment.
6. The method according to claim 1, characterized in that A local heap memory collection range is configured in the game engine of the target game application, and the local heap memory collection range is used to indicate a collection object corresponding to the local heap memory occupancy information, and the collection object includes a third-party library component called by the game process of the target game application and the game engine.
7. The method according to claim 6, characterized in that The obtaining of the local heap memory occupancy information of the target game application includes: Obtain the third-party library component called when the target game application is running; Parsing the file of the third-party library component to obtain a corresponding memory function and a corresponding index of the memory function; and determining a base address offset of the memory function according to the corresponding index of the memory function; The base address offset is replaced with a custom memory function, and the local heap memory occupancy information of the third-party library component is obtained through the custom memory function.
8. The method according to claim 1, characterized in that The obtaining of the video memory occupancy information of the target game application includes: The memory overview information corresponding to the target game application is obtained through the memory acquisition instruction provided by the operating system of the target device; and the memory information corresponding to the graphics processor is obtained from the memory overview information as the video memory occupancy information.
9. The method according to claim 1, characterized in that: The method further comprises: Acquire texture memory information and model memory information related to the target game application through a performance analysis tool in the game engine of the target game application; The determining, according to the first memory occupancy information, the second memory occupancy information, the local heap memory occupancy information, and the video memory occupancy information, of the comprehensive memory occupancy of the target game application includes: The comprehensive memory occupancy of the target game application is determined according to the first memory occupancy information, the second memory occupancy information, the local heap memory occupancy information, the video memory occupancy information, the texture memory information and the model memory information.
10. The method according to claim 1 or 9, characterized in that: The method further comprises: Obtaining the comprehensive memory occupancy of the historical version of the target game application as the first comprehensive memory occupancy; obtaining the comprehensive memory occupancy of the test version of the target game application as the second comprehensive memory occupancy; According to the first comprehensive memory usage and the second comprehensive memory usage, the items to be optimized corresponding to the test version of the target game application are determined.
11. A memory analysis device, characterized in that: The device comprises: An application running module, used to control the target game application to run in the target device; A memory acquisition module, used for acquiring, during the operation of the target game application, first memory occupancy information of the target game application at the operating system level and second memory occupancy information of the target game application at the game engine level through a low-level memory tracker; The memory acquisition module is further used to acquire local heap memory occupancy information of the target game application and video memory occupancy information of the target game application during the operation of the target game application; A memory analysis module is used to determine the comprehensive memory occupancy of the target game application according to the first memory occupancy information, the second memory occupancy information, the local heap memory occupancy information and the video memory occupancy information.
12. A computer device, characterized in that: The device includes a processor and a memory; The memory is used to store computer programs; The processor is used to execute the memory parsing method according to any one of claims 1 to 10 according to the computer program.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the memory parsing method according to any one of claims 1 to 10.
14. A computer program product, comprising a computer program or instructions, characterized in that: When the computer program or the instruction is executed by a processor, the memory parsing method according to any one of claims 1 to 10 is implemented.