Memory positioning analysis method and device, computer equipment and storage medium

By constructing and comparing the call tree structure, the memory growth function is determined, which solves the problem of memory location analysis accuracy and improves the efficiency and accuracy of memory optimization.

CN118779178APending Publication Date: 2024-10-15TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310401694.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-10
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

In the existing technology, the accuracy of memory location analysis is affected by the estimated value of the physical memory of the operating system, causing the memory problem analysis results to deviate from the real cause, affecting computing performance.

Method used

By constructing the first and second call tree structures, comparing the memory call information of each function node, the memory growth function is determined to locate the memory problem and ensure the accuracy of the analysis.

Benefits of technology

It improves the accuracy of memory location analysis, provides an accurate data basis for subsequent memory optimization, and improves the efficiency and accuracy of memory usage optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779178A_ABST
    Figure CN118779178A_ABST
Patent Text Reader

Abstract

The invention relates to a memory positioning analysis method and device, computer equipment, a storage medium and a computer program product. The method comprises the steps that a plurality of first call function sequences in a first time period and a plurality of second call function sequences in a second time period are obtained, and the end time of the second time period is later than that of the first time period; constructing a first call tree structure according to a first call sequence among the first call functions in each first call function sequence; constructing a second call tree structure according to a second call sequence between second call functions in each second call function sequence; the node attributes of the function nodes in the first call tree structure and the second call tree structure are compared, a memory growth function and second memory call information of the function nodes corresponding to the memory growth function are determined to be larger than the first memory call information, and the memory growth function is used for memory analysis and positioning. By adopting the method, the accuracy of memory positioning analysis can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a memory location analysis method, device, computer equipment and storage medium. Background Art

[0002] With the development of computer technology and the increase in the amount of information data, the requirements for information data processing capabilities are getting higher and higher, and computing speed is particularly important for high-performance computing. However, in practical applications, various memory problems often affect computing performance, such as excessive memory or memory leakage. Therefore, it is necessary to analyze the memory problems that arise, and optimize the subsequent memory allocation based on the memory analysis results obtained after analysis, so as to ensure computing performance.

[0003] Currently, for the problem of excessive memory, memory allocation can be split to determine which component has excessive memory allocation, causing a memory bottleneck. For the problem of memory leak, snapshot comparison can be used to determine which objects allocate memory but do not release it, causing memory leaks. However, the problem of excessive memory or memory leak is usually based on the actual physical memory used by the operating system, while memory data statistics are based on the engine's estimated value. Therefore, the memory problem analysis results obtained by memory data statistics may deviate from the actual cause of the memory problem, reducing the accuracy of memory location analysis. Therefore, how to ensure the accuracy of memory location analysis is an urgent problem to be solved. Summary of the invention

[0004] Based on this, it is necessary to provide a memory location analysis method, device, computer equipment and storage medium that can ensure the accuracy of memory location analysis in response to the above technical problems.

[0005] In a first aspect, the present application provides a memory location analysis method. The method comprises:

[0006] Obtaining a first call tree structure corresponding to the first time period, the first call tree structure being constructed according to a first call sequence between first call functions in a plurality of first call function sequences within the first time period, the first call tree structure comprising at least: first function nodes corresponding to the first call functions;

[0007] Obtaining a second call tree structure corresponding to the second time period, the second call tree structure being constructed according to a second call sequence between the second call functions in a plurality of second call function sequences within the second time period, the second call tree structure comprising at least: second function nodes corresponding to the second call functions, respectively, and an end time of the second time period being later than an end time of the first time period;

[0008] The node attributes of each function node in the first call tree structure and the second call tree structure are compared to determine the memory growth function. The second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes in the first call tree structure. The memory growth function is used for memory analysis and positioning.

[0009] In a second aspect, the present application also provides a memory location analysis device. The device comprises:

[0010] A call tree structure acquisition module is used to acquire a first call tree structure corresponding to a first time period, wherein the first call tree structure is constructed according to a first call sequence between first call functions in a plurality of first call function sequences within the first time period, and the first call tree structure at least includes: first function nodes corresponding to the first call functions;

[0011] The call tree structure acquisition module is further used to acquire a second call tree structure corresponding to the second time period, the second call tree structure is constructed according to a second call sequence between the second call functions in a plurality of second call function sequences within the second time period, the second call tree structure at least includes: second function nodes corresponding to the second call functions, and the end time of the second time period is later than the end time of the first time period;

[0012] A memory growth function determination module is used to compare the node attributes of each function node in the first call tree structure and the second call tree structure to determine the memory growth function. The second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes in the first call tree structure. The memory growth function is used for memory analysis and positioning.

[0013] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0014] Obtaining a first call tree structure corresponding to the first time period, the first call tree structure being constructed according to a first call sequence between first call functions in a plurality of first call function sequences within the first time period, the first call tree structure comprising at least: first function nodes corresponding to the first call functions;

[0015] Obtaining a second call tree structure corresponding to the second time period, the second call tree structure being constructed according to a second call sequence between the second call functions in a plurality of second call function sequences within the second time period, the second call tree structure comprising at least: second function nodes corresponding to the second call functions, respectively, and an end time of the second time period being later than an end time of the first time period;

[0016] The node attributes of each function node in the first call tree structure and the second call tree structure are compared to determine the memory growth function. The second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes in the first call tree structure. The memory growth function is used for memory analysis and positioning.

[0017] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0018] Obtaining a first call tree structure corresponding to the first time period, the first call tree structure being constructed according to a first call sequence between first call functions in a plurality of first call function sequences within the first time period, the first call tree structure comprising at least: first function nodes corresponding to the first call functions;

[0019] Obtaining a second call tree structure corresponding to the second time period, the second call tree structure being constructed according to a second call sequence between the second call functions in a plurality of second call function sequences within the second time period, the second call tree structure comprising at least: second function nodes corresponding to the second call functions, respectively, and an end time of the second time period being later than an end time of the first time period;

[0020] The node attributes of each function node in the first call tree structure and the second call tree structure are compared to determine the memory growth function. The second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes in the first call tree structure. The memory growth function is used for memory analysis and positioning.

[0021] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0022] Obtaining a first call tree structure corresponding to the first time period, the first call tree structure being constructed according to a first call sequence between first call functions in a plurality of first call function sequences within the first time period, the first call tree structure comprising at least: first function nodes corresponding to the first call functions;

[0023] Obtaining a second call tree structure corresponding to the second time period, the second call tree structure being constructed according to a second call sequence between the second call functions in a plurality of second call function sequences within the second time period, the second call tree structure comprising at least: second function nodes corresponding to the second call functions, respectively, and an end time of the second time period being later than an end time of the first time period;

[0024] The node attributes of each function node in the first call tree structure and the second call tree structure are compared to determine the memory growth function. The second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes in the first call tree structure. The memory growth function is used for memory analysis and positioning.

[0025] The above-mentioned memory positioning analysis method, device, computer equipment, storage medium and computer program product obtain a first call tree structure corresponding to a first time period, the first call tree structure is constructed according to the first call sequence between each first call function in a plurality of first call function sequences within the first time period, the first call tree structure at least includes: a first function node corresponding to each first call function, and then obtain a second call tree structure corresponding to a second time period, the second call tree structure is constructed according to the second call sequence between each second call function in a plurality of second call function sequences within the second time period, the second call tree structure at least includes: a second function node corresponding to each second call function, the end time of the second time period is later than the end time of the first time period, and the node attributes of each function node in the first call tree structure and the second call tree structure are compared to determine a memory growth function, the second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes of the first call tree structure, and the memory growth function is used for memory analysis and positioning.

[0026] Through the aforementioned memory location analysis method, the first call tree structure can accurately reflect the calling order between each calling function and the memory calling information of each calling function when memory allocation is performed in the first time period. Similarly, the second call tree structure can accurately reflect the calling order between each calling function and the memory calling information of each calling function when memory allocation is performed in the second time period. Therefore, by comparing the node attributes of each function node in the first call tree structure and the second call tree structure, the memory growth function corresponding to the function node with the growth of memory call information between the end time of the first time period and the end time of the second time period can be accurately located. Since memory problems are usually caused by memory growth, memory location analysis through the memory growth function can ensure the accuracy of the memory location analysis, thereby providing an accurate data basis for the optimization of memory occupancy, which can improve the efficiency and accuracy of memory occupancy optimization in practice. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 A schematic diagram of a process for optimizing game memory acceptance in one embodiment;

[0028] Figure 2 An application environment diagram of a memory location analysis method in one embodiment;

[0029] Figure 3 A schematic diagram of memory allocation statistics configuration in one embodiment;

[0030] Figure 4 A schematic diagram of memory allocation collection configuration in one embodiment;

[0031] Figure 5 A schematic diagram of memory overall statistical allocation configuration in one embodiment;

[0032] Figure 6 is a schematic diagram of a memory growth function in one embodiment;

[0033] Figure 7 A schematic diagram of a memory leak reference point in one embodiment;

[0034] Figure 8 A schematic diagram of a flow chart of memory allocation statistics in one embodiment;

[0035] Fig. 9 A schematic diagram of an engine configuration in one embodiment;

[0036] Fig.10 A schematic diagram of game configuration modification in one embodiment;

[0037] Fig.11 A schematic diagram of a flow chart of a memory location analysis method in one embodiment;

[0038] Fig.12 A partial flow chart of obtaining a first call tree structure in one embodiment;

[0039] Fig.13 A schematic diagram of a portion of the process of constructing a first call tree structure in one embodiment;

[0040] Fig.14 A schematic diagram of a partial flow chart of sequentially sorting to obtain a first call tree structure in one embodiment;

[0041] Fig.15 A partial flow chart of sequentially sorting to obtain a first call tree structure in another embodiment;

[0042] Fig.16 A partial flow chart of obtaining multiple first calling function sequences in one embodiment;

[0043] Fig.17 A schematic diagram of a stack structure of a register stack frame in one embodiment;

[0044] Fig.18 A schematic diagram of the structure of a dl_info structure in an embodiment;

[0045] Fig.19 A partial flow chart of determining a memory growth function in one embodiment;

[0046] Fig. 20 is a flow chart of a memory location analysis method according to another embodiment;

[0047] Fig.21 A partial flow chart of obtaining a second call tree structure in one embodiment;

[0048] Fig. 22 A schematic diagram of a portion of the process of constructing a second call tree structure in one embodiment;

[0049] Fig.23 A partial flow chart of obtaining multiple second calling function sequences in one embodiment;

[0050] Fig.24 A complete flowchart of a memory location analysis method in one embodiment;

[0051] Fig.25 is a structural block diagram of a memory location analysis device in one embodiment;

[0052] Fig.26 is a structural block diagram of a memory location analysis device in another embodiment;

[0053] Fig. 27FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0055] With the development of computer technology and the increase in the amount of information data, the requirements for information data processing capabilities are getting higher and higher, and computing speed is particularly important for high-performance computing. However, in practical applications, various memory problems often affect computing performance, such as excessive memory or memory leakage. Therefore, it is necessary to analyze the memory problems that arise, and optimize the subsequent memory allocation based on the memory analysis results obtained after analysis, so as to ensure computing performance.

[0056] Take the game performance acceptance scenario as an example. In the game performance acceptance scenario, memory problems such as excessive memory or memory leaks often occur. In this case, you can Figure 1 The flowchart of game memory acceptance optimization shown in the figure shows that after the game performance acceptance starts, data analysis is performed on memory problems such as excessive memory or memory leakage. For the problem of excessive memory, memory allocation can be split to determine which component has excessive memory allocation, causing a memory bottleneck. For the problem of memory leakage, snapshot comparison can be used to determine which objects allocate memory but do not release it, causing memory leakage. This completes the memory problem point analysis and obtains the memory problem analysis results. Then, based on the memory problem analysis results, R&D optimization is implemented, and based on the optimized memory allocation strategy, the next round of game performance acceptance is entered until the game performance meets the standards.

[0057] However, the problem of excessive memory or memory leakage is usually based on the actual physical memory (Proportional Set Size, PPS) used by the operating system, and the memory data statistics are based on the estimated value of the engine. Therefore, the memory problem analysis results obtained by the memory data statistics may deviate from the actual cause of the memory problem, thereby reducing the accuracy of the memory location analysis. Therefore, how to ensure the accuracy of the memory location analysis is an urgent problem to be solved. Based on this, the embodiment of the present application provides a memory location analysis method that can ensure the accuracy of the memory location analysis.

[0058] The memory location analysis method provided in the embodiment of the present application can be applied to Figure 2In the application environment shown, the terminal 202 communicates with the server 204 through a network. The data storage system can store data that the server 204 needs to process. The data storage system can be integrated on the server 204, or placed on the cloud or other servers.

[0059] Specifically, the memory location analysis method provided in the embodiment of the present application is applied to the server 204 as an example for explanation. The server 204 obtains the first call tree structure corresponding to the first time period. The first call tree structure is constructed according to the first call sequence between each first call function in the multiple first call function sequences in the first time period. The first call tree structure at least includes: the first function node corresponding to each first call function. Then obtain the second call tree structure corresponding to the second time period. The second call tree structure is constructed according to the second call sequence between each second call function in the multiple second call function sequences in the second time period. The second call tree structure at least includes: the second function node corresponding to each second call function, and the end time of the second time period is later than the end time of the first time period. Thus, the node attributes of each function node in the first call tree structure and the second call tree structure are compared to determine the memory growth function. The second memory call information in the node attribute of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attribute of the first call tree structure. The memory growth function is used for memory analysis and location.

[0060] The terminal 202 may be, but is not limited to, various desktop computers, laptop computers, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart vehicle-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 204 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0061] Before introducing the memory location analysis method, we first introduce the product configuration used in memory location analysis in actual applications. First, we introduce the memory allocation statistics configuration, such as Figure 3 As shown, the configurator can display a configuration setting interface 304 on the terminal by operating Configure 302. The main settings on the configuration setting interface 304 include:

[0062] 1. Android SDK path and NDK path.

[0063] 2. Compiler code compiler type. Compiler code compiler types include llvm and gcc.

[0064] 3. Mode allocates statistics. Mode allocates statistics in two modes: strict and loose.

[0065] 4. Build mode. Build mode has framepointer and instrument options.

[0066] Secondly, the configuration setting interface 304 also configures the Threshold corresponding mode, Type mode and libraries. The Threshold corresponding mode can capture all memory allocated higher than 256 bytes. The Type mode is divided into white mode and black mode. The Type mode is mainly used in conjunction with libraries. The white mode in the Type mode will only collect the target library in the libraries, while the black mode in the Type mode will collect all libraries outside the libraries.

[0067] Therefore, in actual application, the configuration package name is entered in the setting box in the configuration setting interface 304, such as Figure 3 The configuration package shown is: com.tencent.tmgp.pubgmhd 306. When the configurator operates Load symblos 308, the symbol table will be loaded, and when the configurator operates Launch 310, the memory allocation collection can be started.

[0068] Furthermore, after completing the memory allocation statistics, you need to configure the memory allocation collection, such as Figure 4 As shown, Figure 4 The figure (A) shows the time (Time), size (Size), memory address (Address), the collected library name, and Function when the memory is allocated. Function refers to the offset address of the called function. Figure 4 The figure (B) shows the memory allocation stack, that is, the memory allocation stack can describe the calling order between each calling function in a memory allocation.

[0069] In actual applications, after completing the memory allocation collection, the overall memory statistical allocation can be counted in real time. The specific configuration is as follows Figure 5 As shown, Figure 5 It shows in detail how 500.08MB of memory is allocated in actual application, such as Figure 5The FAsyncLoadingThread::Run() calling function 502 allocates 384.24MB, and the FPakMountThread::Run() calling function 504 allocates 74.05MB, etc. It can be understood that in actual applications, you can also continue to click to view the specific memory allocation of each calling sub-function under the FAsyncLoadingThread::Run() calling function 502 until you get a complete panoramic view of the memory allocation data.

[0070] Based on this, after completing the overall memory statistics and obtaining the panoramic view of memory allocation data, you can select the memory allocation data of two comparison time nodes to analyze and view the specific memory growth function (that is, memory growth point or memory leakage point), as shown below: Figure 6 As shown, Figure 6 Figure (A) shows the memory snapshot comparison analysis between the memory allocation data at the 5th second and the memory allocation data at the 25th second. Figure 6 The panoramic view of memory allocation data shown in Figure (B) shows that the memory at the 25th second position has increased by 4.88MB compared to the 5th second position, and based on Figure 6 From the panoramic view of memory allocation data shown in FIG. (B), it can be determined that the main memory growth function that causes memory growth from the 5th second to the 25th second is specifically the FEengineLoop:PreInit calling function 602.

[0071] After determining the memory growth function, memory leak reference analysis can be further performed. When a memory growth point or memory leak point (i.e., memory growth function) is found, the singleref instruction can be entered in the relevant program to perform reference insertion analysis on the leak point to obtain which resource or configuration caused the introduction of the leak point. Figure 7 The memory leak reference analysis shown in the figure shows that the bottom-level Ingame_DragonBoat_Atlas call function 702 is the memory growth point or memory leak point (i.e., memory growth function). Through the reference analysis, it can be seen that the memory growth function resource is introduced by the Vehicl Control Panel UI component 704 in the UI component.

[0072] Understandably, Figures 3 to 7 The figure shows a schematic diagram of the relevant configuration in the actual application. To facilitate the understanding of the overall process of memory allocation statistics, the game performance acceptance scenario is used as an example for explanation. Figure 8 As shown, the process of memory allocation statistics at least includes: engine configuration 802, game configuration 804, memory stack acquisition 806, call value sequence acquisition 808 and call function sequence storage 810.

[0073] exist Figure 8 In the displayed memory allocation statistics flow diagram, in order to facilitate memory statistics without source code, the engine configuration 802 will be performed first, so that the engine's memory allocation can be captured and obtained by the relevant tools in this solution. Based on this, the game configuration 804 will also be modified to facilitate the game's stack frame to not be optimized by the compiler and to achieve hardware-supported stack backtracing. Therefore, in actual applications, after pulling the game, as long as there is memory allocation, the memory stack will be acquired 806, and the acquired memory stack will be recorded and saved, and then the acquired memory stack will be symbolically restored according to the symbol table, and each function address will be restored to a code name to obtain the call value sequence 808, and the call value sequence will be parsed to complete the acquisition of the call function sequence, and after acquiring the call function sequence, the call function sequence will be compressed and saved to facilitate subsequent memory location analysis and snapshot comparison.

[0074] For engine configuration 802, specifically Fig. 9 The engine configuration diagram shown is Fig. 9 The middle (A) figure shows that the engine's memory pool allocation method is changed to Binned2 mode 902, avoiding Ansi mode and Binned mode to take into account the adaptability of the memory allocation method and the collection performance. Fig. 9 The middle (B) figure shows the memory allocation record function lq_alloc_ptr required by this application inserted into the Malloc memory allocation function of the engine. And Fig. 9 The middle (C) figure shows the memory allocation record function lq_alloc_ptr 904 required by this application inserted into the Realloc memory allocation function of the engine. Fig. 9 The middle (D) figure shows the memory release record function inserted on the memory release interface.

[0075] For game configuration 804, specifically Fig.10 What is shown is a schematic diagram of game configuration modification. Fig.10 The middle (A) figure shows the global configuration of using UselqProfiler in the game compilation, and Fig.10 The middle (B) figure shows that after starting lqProfiler, the compile setting option -fno-omit-frame-pointer will be added. By turning on this setting option, the stack function pointer can be stored in the hardware register to improve the stack backtracking performance. Based on the above configuration, the memory stack acquisition 806, the call value sequence acquisition 808 and the call function sequence storage 810 are related.

[0076] Based on the above process overview and configuration introduction, the following will introduce in detail how to perform memory location analysis:

[0077] In one embodiment, Fig.11 As shown, a memory location analysis method is provided, which is applied to Figure 2 The method is described by taking the server 204 in the example as an example. It is understandable that the method can also be applied to the terminal 202, and can also be applied to a system including the terminal 202 and the server 204, and is implemented through the interaction between the terminal 202 and the server 204. In this embodiment, the method includes the following steps:

[0078] Step 1102, obtain a first call tree structure corresponding to the first time period, the first call tree structure is constructed according to a first call sequence between first call functions in a plurality of first call function sequences within the first time period, and the first call tree structure includes at least: first function nodes corresponding to each first call function.

[0079] Among them, the time period is specifically the time interval between two time points, for example, the first time period is the time interval between time point T1 and time point T2. Secondly, the calling function sequence specifically includes multiple calling functions, and there is a calling order between multiple calling functions belonging to the same calling function sequence. For example, the first calling function sequence A1 includes the first calling function B1, the first calling function B2, the first calling function B3 and the first calling function B4, and the calling order between the first calling function B1 and the first calling function B4 in the first calling function sequence A1 is: the first calling function B1 calls the first calling function B2, the first calling function B2 calls the first calling function B3, and the first calling function B3 calls the first calling function B4, that is, the first calling function sequence A1 can be specifically expressed as: [first calling function B1, first calling function B2, first calling function B3, first calling function B4]. It can be seen that the first calling function sequence specifically includes multiple first calling functions, and there is a first calling order between multiple first calling functions belonging to the same first calling function sequence.

[0080] Based on this, the first call tree structure at least includes: first function nodes corresponding to each first call function, and each function node has corresponding node attributes, and the aforementioned node attributes at least include: the node level of each function node in the call tree structure, memory call information in the corresponding time period, the function name of the corresponding call function, etc. And the aforementioned memory call information at least includes: the cumulative number of calls and the cumulative allocated memory, which is not limited here.

[0081] For example, the first calling function sequence A1 is specifically [first calling function B1, first calling function B2, first calling function B3, first calling function B4], and the first calling function sequence A2 is specifically [first calling function B1, first calling function B2, first calling function B3, first calling function B5], then the first calling tree structure at least includes: the first function node C1 corresponding to the first calling function B1, the first function node C2 corresponding to the first calling function B2, the first function node C3 corresponding to the first calling function B3, the first function node C4 corresponding to the first calling function B4, and the first function node C5 corresponding to the first calling function B5. The node level of the aforementioned first function node C1 is 1, the node level of the first function node C2 is 2, the node level of the first function node C3 is 3, the node level of the first function node C4 is 4, and the node level of the first function node C5 is the same as that of the first function node C4, both of which are 4.

[0082] Specifically, the server obtains a first call tree structure corresponding to the first time period. Since the first call tree structure is specifically constructed according to multiple first call function sequences within the first time period, the server can obtain the first call function sequence within the first time period, construct the first call tree structure in real time through the first call function sequence, and save the first call tree structure to local storage, such as: saving the first call tree structure to a data storage system connected to the server, and obtaining the first call tree structure corresponding to the first time period from the local storage when memory location analysis is required.

[0083] Alternatively, after obtaining the first calling function sequence within the first time period, the server may store the first calling function sequence in a local storage, such as saving it in a data storage system connected to the server, and obtain the first calling function sequence from the local storage when memory location analysis is required, and construct a first calling tree structure according to the first calling function sequence. Therefore, the method of obtaining the first calling tree structure is not specifically limited here.

[0084] Step 1104, obtain a second call tree structure corresponding to the second time period, the second call tree structure is constructed according to the second call order between the second call functions in the multiple second call function sequences within the second time period, the second call tree structure includes at least: second function nodes corresponding to the second call functions, and the end time of the second time period is later than the end time of the first time period.

[0085] Among them, the end time of the second time period is later than the end time of the first time period. And similar to the above-mentioned embodiment, the time period is specifically the time interval between two time points, for example, the first time period is the time interval between time point T1 and time point T2, the second time period is the time interval between time point T1 and time point T3, and time point T3 is later than time point T2. It can be understood that the start time of the first time period and the start time of the second time period can be the same or different, but there is an overlapping time interval between the first time period and the second time period, for example, the first time period is the time interval between time point T1 and time point T2, the second time period is the time interval between time point T4 and time point T3, time point T2 is earlier than time point T3, and time point T4 is later than time point T1 but earlier than time point T2.

[0086] Secondly, the calling function sequence specifically includes multiple calling functions, and there is a calling order between the multiple calling functions belonging to the same calling function sequence. Similar to the above embodiment, the second calling function sequence specifically includes multiple second calling functions, and there is a second calling order between the multiple second calling functions belonging to the same second calling function sequence.

[0087] Based on this, the second call tree structure at least includes: second function nodes corresponding to each second call function, and each function node has corresponding node attributes, and the aforementioned node attributes at least include: the node level of each function node in the call tree structure, the memory call information in the corresponding time period, the function name of the corresponding call function, etc. And the aforementioned memory call information at least includes: the cumulative number of calls and the cumulative allocated memory, which is not limited here.

[0088] For example, the second calling function sequence D1 is specifically [second calling function E1, second calling function E2, second calling function E3, second calling function E4], and the second calling function sequence D2 is specifically [second calling function E1, second calling function E2, second calling function E3, second calling function E5], then the second calling tree structure at least includes: the second function node F1 corresponding to the second calling function E1, the second function node F2 corresponding to the second calling function E2, the second function node F3 corresponding to the second calling function E3, the second function node F4 corresponding to the second calling function E4, and the second function node F5 corresponding to the second calling function E5. The node level of the aforementioned second function node F1 is 1, the node level of the second function node F2 is 2, the node level of the second function node F3 is 3, the node level of the second function node F4 is 4, and the node level of the second function node F5 is the same as that of the second function node F4, both of which are 4.

[0089] Specifically, the server obtains the second call tree structure corresponding to the second time period. Since the second call tree structure is specifically constructed according to multiple second call function sequences within the second time period, the server can construct the second call tree structure in real time through the second call function sequence after obtaining the second call function sequence within the second time period, and save the second call tree structure to local storage, such as: saving the second call tree structure to a data storage system connected to the server, and obtaining the second call tree structure corresponding to the second time period from the local storage when memory location analysis is required.

[0090] Alternatively, after obtaining the second calling function sequence within the second time period, the server may store the second calling function sequence in local storage, such as saving it in a data storage system connected to the server, such as: saving the second calling function sequence in a data storage system connected to the server, obtaining the second calling function sequence from the local storage when memory location analysis is required, and constructing a second calling tree structure according to the second calling function sequence. Therefore, the method for obtaining the second calling tree structure is not specifically limited here.

[0091] Step 1106, compare the node attributes of each function node in the first call tree structure and the second call tree structure to determine the memory growth function, the second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes in the first call tree structure, and the memory growth function is used for memory analysis and positioning.

[0092] Among them, since the node attributes at least include: the node level of each function node in the call tree structure and the memory call information in the corresponding time period, the node attribute comparison is specifically: comparing the memory call information between function nodes belonging to the same node level in the call tree structure. Therefore, the memory growth function is specifically a function of memory call information growth, that is, the second memory call information in the node attribute of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attribute in the first call tree structure, and the aforementioned memory growth function is used for memory analysis and positioning.

[0093] Specifically, the server compares the memory call information between the function nodes at the same node level in the first call tree structure and the second call tree structure, and determines the call function corresponding to the function node with increased memory call information as the memory growth function. Since the aforementioned memory call information includes at least: the cumulative number of calls and the cumulative allocated memory, the server determines the function nodes at the same node level whose cumulative number of calls is positive and whose cumulative allocated memory is positive as the memory growth function.

[0094] For example, based on the above example, it can be known that the first call tree structure at least includes: the first function node C1 corresponding to the first call function B1, the first function node C2 corresponding to the first call function B2, the first function node C3 corresponding to the first call function B3, the first function node C4 corresponding to the first call function B4, and the first function node C5 corresponding to the first call function B5. The node level of the above first function node C1 is 1, the node level of the first function node C2 is 2, the node level of the first function node C3 is 3, the node level of the first function node C4 is 4, and the node level of the first function node C5 is the same as that of the first function node C4, both of which are 4.

[0095] If the second call tree structure at least includes: a second function node F1 corresponding to the second call function E1, a second function node F2 corresponding to the second call function E2, a second function node F3 corresponding to the second call function E3, a second function node F4 corresponding to the second call function E4, and a second function node F5 corresponding to the second call function E5. The node level of the second function node F1 is 1, the node level of the second function node F2 is 2, the node level of the second function node F3 is 3, the node level of the second function node F4 is 4, and the node level of the second function node F5 is the same as that of the second function node F4, both being 4.

[0096] Based on this, if the function names of the second calling function E1 and the first calling function B1 are the same, the second calling function E1 and the first calling function B1 can be determined as the same calling function, that is, the first function node C1 and the second function node F1 can be function nodes corresponding to the same calling function, but the node attributes of the second function node F1 corresponding to the second calling function E1 mainly describe the calling information within the second time period, while the node attributes of the first function node C1 corresponding to the first calling function B1 mainly describe the calling information within the first time period. Therefore, the node attributes of the first function node C1 and the second function node F1 may be different.

[0097] For example, if the node attribute of the first function node C1 is: the cumulative number of calls is 2 times and the cumulative allocated memory is 50M, then it can be determined that the first calling function B1 corresponding to the first function node C1 was called 2 times in the first time period and 50M of memory was allocated. If the node attribute of the second calling function E1 is: the cumulative number of calls is 3 times and the cumulative allocated memory is 60M, then it can be determined that the second function node F1 corresponding to the second calling function E1 was called 3 times in the second time period and 60M of memory was allocated. It can be known that between the end time of the first time period and the end time of the second time period, the calling function (i.e., the first calling function B1, the second calling function E1) was called once and 10M (60M-50M) of memory was allocated, that is, the cumulative number of calls is a positive value, and the cumulative allocated memory is also a positive value, thus it can be determined that the calling function (i.e., the first calling function B1, the second calling function E1) is a memory growth function. It can be understood that the above examples are only used to understand this solution and should not be understood as specific limitations.

[0098] In the above-mentioned memory location analysis method, the first call tree structure can accurately reflect the calling order between each calling function and the memory calling information of each calling function when memory allocation is performed in the first time period. Similarly, the second call tree structure can accurately reflect the calling order between each calling function and the memory calling information of each calling function when memory allocation is performed in the second time period. Therefore, by comparing the node attributes of each function node in the first call tree structure and the second call tree structure, the memory growth function corresponding to the function node with the growth of memory call information between the end time of the first time period and the end time of the second time period can be accurately located. Since memory problems are usually caused by memory growth, memory location analysis through the memory growth function can ensure the accuracy of memory location analysis, thereby providing an accurate data basis for the optimization of memory occupancy, which can improve the efficiency and accuracy of memory occupancy optimization in practice.

[0099] The following will introduce in detail how to construct the first call tree structure, and it can be understood that the first call tree structure can be constructed in real time and stored locally after the server obtains multiple first call function sequences corresponding to the first time period in real time. It can also be constructed after the server obtains multiple first call function sequences from the local, which is not specifically limited here:

[0100] In one embodiment, Fig.12 As shown, obtaining a first call tree structure corresponding to a first time period includes:

[0101] Step 1202: Acquire multiple first calling function sequences, where the first calling function sequences include first calling functions, and a first calling order exists between the first calling functions belonging to the same first calling function sequence.

[0102] The first calling function sequence includes the first calling function, and there is a first calling order between the first calling functions belonging to the same first calling function sequence. The specific introduction of the first calling function is similar to the above embodiment and will not be repeated here.

[0103] Specifically, the server obtains multiple first call function sequences within the first time period. That is, the server can obtain, at the end time of the first time period, the first call function sequence corresponding to each memory allocation during the first time period, so the first call function sequence specifically includes all the first call functions called during the corresponding memory allocation.

[0104] Alternatively, the server may also obtain, at the end time of the first time period, the first call function sequence corresponding to each memory allocation during the first time period, and then store the first call function sequence in a local storage, such as a data storage system connected to the server, and obtain the first call function sequence from the local storage when memory location analysis is required. Therefore, the method of obtaining multiple first call function sequences is not specifically limited here.

[0105] Step 1204: determine the first calling function whose first calling sequence is the starting sequence in each first calling function sequence as the parent function node corresponding to the first calling function sequence.

[0106] The parent function node is a function node corresponding to the first calling function whose first calling sequence is the starting sequence in the first calling function sequence. Specifically, the server determines the first calling function whose first calling sequence is the starting sequence in each first calling function sequence as the parent function node corresponding to the first calling function sequence.

[0107] For example, the first calling function sequence A1 is: [first calling function B1, first calling function B2, first calling function B3, first calling function B4], and based on the aforementioned embodiment, it can be known that the calling order between the first calling function B1 to the first calling function B4 in the first calling function sequence A1 is: the first calling function B1 calls the first calling function B2, the first calling function B2 calls the first calling function B3, and the first calling function B3 calls the first calling function B4. At this time, it can be determined that the first calling function B1 in the first calling function sequence A1 is the starting order, and therefore the first calling function B1 is determined as the parent function node corresponding to the first calling function sequence A1.

[0108] Step 1206: construct a first call tree structure based on each parent function node and the first call sequence between each first call function.

[0109] Specifically, based on each parent function node and the first calling sequence between each first calling function, a first calling tree structure is constructed. That is, the server arranges the parent function nodes corresponding to each first calling function sequence and the first function nodes corresponding to the first calling functions in each first calling function sequence in sequence according to the first calling sequence to obtain the first calling tree structure.

[0110] In this embodiment, the first calling function in the starting order is determined as the parent function node, which can ensure that the subsequent function nodes sorted based on the parent function node can be accurately sorted and distributed based on the calling order, so that the obtained first call tree structure can accurately reflect the calling order between multiple calling functions when multiple memory allocations occur, so as to ensure the reliability and accuracy of the first call tree structure.

[0111] In one embodiment, Fig.13 As shown, based on each parent function node and the first calling sequence between each first calling function, a first calling tree structure is constructed, including:

[0112] Step 1302: sort the first function nodes corresponding to the first calling functions in sequence based on the first calling sequence between the first function nodes and the parent function nodes to obtain a first calling tree structure.

[0113] Specifically, the server sequentially sorts the first function nodes corresponding to each first calling function based on the first calling sequence between each parent function node to obtain a first calling tree structure.

[0114] Optionally, the ordering method may be to insert the first function nodes corresponding to the first calling functions into the call tree structure to be updated based on the calling relationship between the first function nodes and the parent function nodes of the first calling function sequence to which they belong. The call tree structure to be updated may be a call tree structure constructed by the calling function sequence in the third time period prior to the first time period. The end time of the third time period is prior to the end time of the first time period, and there is an overlapping time interval between the third time period and the first time period. Therefore, the server may first insert the parent function node corresponding to the first calling function sequence newly added in the first time period compared with the third time period into the call tree structure to be updated. If there is a function node with the same function name as the node attribute of the parent function node in the call tree structure to be updated, the parent function node and the function node with the same function name may be merged, but at this time, the number of calls for memory allocation of the function node and the total amount of memory allocated are updated. Then, based on the first function nodes corresponding to the first calling functions having the first calling sequence with the parent function nodes, the first function nodes are sequentially inserted into the call tree structure to be updated based on the parent function nodes, thereby obtaining the first call tree structure.

[0115] For ease of understanding, Fig.14 As shown, Fig.14 (A) The figure shows a call tree structure to be updated including function nodes 1401 to 1404, and function node 1401 corresponds to the first call function 1, function node 1402 corresponds to the first call function 2, function node 1403 corresponds to the first call function 3, and function node 1404 corresponds to the first call function 4. If there is a first calling function sequence: [first calling function 1, first calling function 2, first calling function 5], it can be determined that the first calling function 1 and the first calling function 2 can correspond to function node 1401 and function node 1402. Based on the first calling sequence in [first calling function 1, first calling function 2, first calling function 5]: first calling function 1 calls first calling function 2, and first calling function 2 calls first calling function 5, there is still a calling connection relationship between function node 1401 and function node 1402, and it is necessary to create function node 1405 having a calling connection relationship with function node 1402, and update the memory calling information in the node attributes of function node 1401 and function node 1402, and determine the memory calling information in the node attributes of function node 1405, thereby obtaining the following: Fig.14 The first call tree structure is shown in Figure (B).

[0116] Optionally, the sequential sorting method may also be: first construct the first function nodes corresponding to the first calling functions respectively, then compare the node attributes of each first function node, merge the parent function nodes with the same function name, and then sort the first function nodes corresponding to each first calling function having a first calling order with each parent function node based on the parent function nodes to obtain a first call tree structure.

[0117] For example, there is a first calling function sequence 1: [first calling function 1, first calling function 2, first calling function 3], and a first calling function sequence 2: [first calling function 1, first calling function 2, first calling function 4]. The first calling order in the first calling function sequence 1 is: the first calling function 1 calls the first calling function 2, and the first calling function 2 calls the first calling function 3. Similarly, the first calling order in the first calling function sequence 2 is: the first calling function 1 calls the first calling function 2, and the first calling function 2 calls the first calling function 4. Based on this, Fig.15 As shown, it can be determined that the first calling function 1 in the first calling function sequence 1 is the parent function node, and the first calling function 1 in the first calling function sequence 2 is the parent function node. At this time, the function names of the parent function nodes are consistent, so the first function node 1501 corresponding to the first calling function 1 can be directly created.

[0118] Based on this, based on the calling relationship between the first calling function 1 and the first calling function 2, a function node 1502 having a calling connection relationship with the function node 1501 can be created, and based on the calling relationship between the first calling function 2 and the first calling function 3 in the first calling function sequence 1, a function node 1503 having a calling connection relationship with the function node 1502 can be created, and based on the calling relationship between the first calling function 2 and the first calling function 4 in the first calling function sequence 2, a function node 1504 having a calling connection relationship with the function node 1502 can be created, thereby obtaining the following: Fig.15 A first call tree structure is shown.

[0119] It is understandable that the above examples are used to understand the present solution and should not be understood as specific limitations. When the server obtains the first call tree structure, it also needs to synchronously determine the node attributes of each first function node. The function name in the node attribute will not change, while the memory call information will be updated with each memory allocation. The following will explain in detail:

[0120] Step 1304: summing up the number of times each first calling function performs memory allocation in the first time period to determine a first cumulative number of times each first calling function performs memory allocation.

[0121] Specifically, when obtaining the first call tree structure, the server also needs to sum the number of calls for memory allocation of each first call function within the first time period to determine the first cumulative number of calls of each first call function.

[0122] For example, if there exists in the first time period the first calling function sequence 1: [first calling function 1, first calling function 2, first calling function 3], and the first calling function sequence 2: [first calling function 1, first calling function 2, first calling function 4], it can be known that the first calling function 1 exists in the first calling function sequence 1 and the first calling function sequence 2, that is, the first calling function 1 is called 2 times in total in the first time period, that is, the first cumulative calling number of the first calling function 1 is 2. Similarly, the first calling function 2 exists in the first calling function sequence 1 and the first calling function sequence 2, that is, the first calling function 2 is called 2 times in total in the first time period, that is, the first cumulative calling number of the first calling function 2 is 2. And the first calling function 3 is called once in total in the first time period, that is, the first cumulative calling number of the first calling function 3 is 1. The first calling function 3 is called once in total in the first time period, that is, the first cumulative calling number of the first calling function 3 is 1.

[0123] Step 1306: summing up the memory allocated by each first calling function during the first time period to determine a first cumulative allocated memory for each first calling function.

[0124] Specifically, when the server obtains the first call tree structure, it is also necessary to sum up the memory allocated by each first call function for memory allocation in the first time period to determine the first cumulative allocated memory of each first call function. Further introduction is given based on the above example. For example, if there are first call function sequence 1 and first call function sequence 2 in the first time period, the memory allocated by the first call function 1 for memory allocation in the first call function sequence 1 is 10M, the memory allocated by the first call function 2 for memory allocation is 8M, and the memory allocated by the first call function 3 for memory allocation is 5M. And in the first call function sequence 2, the memory allocated by the first call function 1 for memory allocation is 8M, the memory allocated by the first call function 2 for memory allocation is 5M, and the memory allocated by the first call function 4 for memory allocation is 2M.

[0125] By summing up, we can get the first cumulative allocated memory of the first calling function 1 is 18M (10M+8M), the first cumulative allocated memory of the first calling function 2 is 13M (8M+5M), the first cumulative allocated memory of the first calling function 3 is 5M, and the first cumulative allocated memory of the first calling function 4 is 2M.

[0126] Step 1308: determine each first accumulated call count and each first accumulated allocated memory as first memory call information in a node attribute of a first function node corresponding to the first calling function.

[0127] Specifically, the server determines the first cumulative number of calls of each first calling function and the first cumulative allocated memory of each first calling function as the first memory call information in the node attribute of the first function node corresponding to the first calling function. Based on the above example, it can be known that the first cumulative number of calls of the first calling function 1 is 2, and the first cumulative allocated memory of the first calling function 1 is 18M, so it can be determined that the first memory call information in the node attribute of the first function node corresponding to the first calling function 1 is specifically: the first cumulative number of calls is 2, and the first cumulative allocated memory is 18M.

[0128] By analogy, the first memory call information in the node attributes of the first function node corresponding to the first calling function 2 is specifically: the first cumulative number of calls is 2, and the first cumulative allocated memory is 13M. The first memory call information in the node attributes of the first function node corresponding to the first calling function 3 is specifically: the first cumulative number of calls is 1, and the first cumulative allocated memory is 5M. The first memory call information in the node attributes of the first function node corresponding to the first calling function 4 is specifically: the first cumulative number of calls is 1, and the first cumulative allocated memory is 2M. It can be understood that the examples in this embodiment are used to understand the scheme and should not be understood as limitations on the specific implementation of the scheme.

[0129] In this embodiment, the parent function node corresponding to the first calling function sequence of each memory allocation can be determined by the calling sequence between calling functions. The first calling tree structure obtained by sequentially arranging different parent function nodes can accurately reflect the calling sequence between multiple calling functions when multiple memory allocations are made, so as to ensure the reliability and accuracy of the first calling tree structure. Secondly, the node attributes of each function node are determined by summing the relevant memory information of memory allocation in the first time period, so as to ensure the comprehensiveness and reliability of the stored memory call information.

[0130] The following describes in detail how to obtain the first calling function sequence: In one embodiment, Fig.16 As shown, multiple first calling function sequences are obtained, including:

[0131] Step 1602, obtaining the first stack frame start address and the first stack frame end address of each memory allocation within the first time period.

[0132] The stack frame first address is the first address of the register stack frame for each memory allocation, and the stack frame end address is the end address of the register frame stack for each memory allocation. Specifically, the server records the first address of the register stack frame for each memory allocation in the first time period, and the end address of the register frame stack for each memory allocation, and determines the first address of the register stack frame for each memory allocation as the first stack frame first address corresponding to each memory allocation, and determines the end address of the register frame stack for each memory allocation as the first stack frame end address corresponding to each memory allocation.

[0133] In actual applications, the server can obtain the first address of the register stack frame at each memory allocation through the built-in function builtin_frame_address, and the end address of the register frame stack at each memory allocation through pthread_attr_getstack.

[0134] Step 1604: Obtain a first call value sequence corresponding to each memory allocation through each first stack frame start address and each first stack frame end address, wherein the first call value sequence includes a plurality of first call function address values.

[0135] Among them, the first call value sequence is composed of the call function address value called at the end of the corresponding memory allocation. Specifically, the server can obtain the first call value sequence corresponding to each memory allocation by performing a loop calculation through the first address of each first stack frame and the end address of each first stack frame. That is, for a memory allocation, the next stack address can be obtained by continuously subtracting 4 bytes (32-bit machine) or 8 bytes (64-bit machine) from the starting position, and the function address data in all stack frames are obtained in this loop, and then the first stack frame first address and the first stack frame end address of this memory allocation are used to obtain the function address data in all stack frames, and then the first call value sequence of this memory allocation can be obtained.

[0136] For ease of understanding, Fig.17 The stack structure of the register stack frame shown has a starting position of high address 702. At this time, the next stack address can be obtained by continuously subtracting 4 bytes (32-bit machine) or 8 bytes (64-bit machine) from the high address 702, and the function address data in all stack frames are obtained in this way. If it is necessary to determine the first call value sequence of the current frame 1704 (one memory allocation), the first stack frame start address 1706 of the current frame 1704 and the first stack frame end address 1708 of the current frame 1704 can be used to obtain the function address data in all stack frames to obtain the first call value sequence of the current frame 1704.

[0137] Step 1606: parse each first call value sequence to obtain a first call function sequence corresponding to each first call value sequence.

[0138] Among them, the first calling function sequence includes: the first calling functions corresponding to the first calling function address values. That is, the first calling function value sequence G1 includes: the first calling function address value H1, the first calling function address value H2, the first calling function address value H3, and the first calling function address value H4. If the first calling function sequence A1 corresponds to the first calling function value sequence, it can be determined that the first calling function sequence A1 specifically includes: the first calling function B1 corresponding to the first calling function address value H1, the first calling function B2 corresponding to the first calling function address value H2, the first calling function B3 corresponding to the first calling function address value H3, and the first calling function B4 corresponding to the first calling function address value H4.

[0139] Specifically, the server parses each first call value sequence to obtain the first call function sequence corresponding to each first call value sequence. That is, the server parses each first call value sequence once in the order from the first address to the end address to obtain the first call function sequence corresponding to each first call value sequence. At this time, the first call order between each first call function in the first call function sequence is consistent with the order from the first address to the end address.

[0140] And in actual application, the server specifically relies on the symbol table to realize the recovery of the function name of the non-source code function. After the memory allocation call is completed, the server can establish the corresponding relationship between the calling function address value and the function name, and the aforementioned corresponding relationship can be carried out in the form of a corresponding dictionary or a corresponding table. Based on this, since the first calling function sequence stores the calling function address value, it is necessary to parse and restore each calling function address value into a name string. Since there may be repeated function addresses in multiple first calling function sequences, using a dictionary for comparison will greatly reuse the data results of the existing query. Therefore, in this embodiment, the dladdr function is used to obtain the calling function name. dladdr will return the dl_info structure according to the function address value, and the corresponding function name can be determined through the dl_info structure.

[0141] Specific as Fig.18In the dl_info structure shown, dli_sname 1802 is specifically a pointer, and dli_sname 1802 points to the function name closest to the specified function address value. The function name can carry the same function address value, or the closest function name with a low-order address. The function name obtained at this time is still a relatively low-level function name. Based on this, the function name output by the dl_info structure is decoded into a user-level name through abi::__cxa_demangle, so that the C++ type name is readable, thereby completing the source code level analysis to determine the calling function pointed to by the function name corresponding to the function address value 1804. It can be understood that the examples in this embodiment are all used to understand the solution, and should not be understood as a specific implementation limitation of the solution.

[0142] In this embodiment, all first calling function address values ​​occupied when memory is allocated within the first time period can be accurately obtained through the first stack frame start address and the first stack frame end address, and each calling function address value is parsed and located to determine the calling function that each calling function address value actually corresponds to, so as to ensure the accuracy and reliability of each calling function in the first calling function sequence, and the calling order between each calling function can be accurately determined through the relationship between the calling function address values, thereby ensuring the reliability and accuracy of the obtained first calling function sequence.

[0143] In one embodiment, Fig.19 As shown, the node attributes of the function node include at least: node level and memory call information.

[0144] The node level is used to describe the level of the function node in the call tree structure. Please refer to Fig.14 , Fig.14 In the figure (B), the function node 1401 has a level 1 in the call tree structure, the function node 1402 has a level 2 in the call tree structure, and the function nodes 1403, 1404, and 1405 have a level 3 in the call tree structure. Secondly, the memory call information includes at least: the cumulative number of calls and the cumulative allocated memory, which are not limited here.

[0145] Based on this, the node attributes of each function node in the first call tree structure and the second call tree structure are compared to determine the memory growth function, including:

[0146] Step 1902 , comparing the difference between the memory call information between the function nodes at the same node level in the first call tree structure and the second call tree structure.

[0147] Specifically, the server compares the difference between the memory call information of the function nodes with the same node level in the first call tree structure and the second call tree structure. Since the memory call information includes at least: the cumulative number of calls and the cumulative allocated memory, the server specifically compares the difference between the cumulative number of calls and the cumulative allocated memory of the function nodes with the same node level in the first call tree structure and the second call tree structure.

[0148] For example, the memory call information of the first function node C1 in the first call tree structure is specifically: the cumulative number of calls is 2 times and the cumulative allocated memory is 50M. The memory call information of the second function node F1 in the second call tree structure is specifically: the cumulative number of calls is 3 times and the cumulative allocated memory is 60M, and the first function node C1 and the second function node F1 belong to the same node level, and the function names of the first function node C1 and the second function node F1 are the same, then it can be determined that the difference between the first function node C1 and the second function node F1 is: the difference in the cumulative number of calls is 1 (3-2), and the difference in the cumulative allocated memory is 10M (60M-50M).

[0149] Step 1904: determine the function node whose difference is a positive value as a memory growth node, and determine the calling function corresponding to the memory growth node as the memory growth function.

[0150] Among them, the memory growth node can be single or multiple, and the memory growth node must exist in the second call tree structure, that is, the memory growth node can be a function node newly added in the second call tree structure compared with the first call tree structure, and can be a function node with the same function name in the first call tree structure and the first call tree structure (that is, the same function node). Secondly, the memory growth function can also be single or multiple, and the memory growth function must also exist in the second call function sequence.

[0151] Specifically, the server determines the function node whose difference is positive as the memory growth node, and determines the call function corresponding to the memory growth node as the memory growth function. Since the memory call information includes at least: the cumulative number of calls and the cumulative allocated memory, the server specifically determines the function node whose difference is positive for the cumulative number of calls and the cumulative allocated memory as the memory growth node.

[0152] For example, based on the above example, since the difference between the first function node C1 and the second function node F1 is: the difference in the cumulative number of calls is 1 (3-2), and the difference in the cumulative allocated memory is 10M (60M-50M), it can be determined that the difference in the cumulative number of calls and the difference in the cumulative allocated memory are both positive values, and the function names of the first function node C1 and the second function node F1 are consistent, so the calling function indicated by the function names corresponding to the first function node C1 and the second function node F1 can be determined as a memory growth function. It can be understood that the examples in this embodiment are used to understand the solution, and should not be understood as a specific implementation limitation of the solution.

[0153] In this embodiment, by calculating the difference between the memory call information between function nodes of the same node level, the node level indicates that some attributes in the function nodes are similar. At this time, the difference calculation of the memory call information can reflect the correlation of memory calls in functions of similar attributes, so that the memory growth function where the memory call information grows can be determined more accurately, thereby ensuring the reliability and accuracy of the memory growth function.

[0154] In practical applications, after determining the memory growth function, it is necessary to further perform memory location analysis on the memory problem (i.e., memory growth or memory leak problem). The following describes in detail how to perform memory location analysis using the memory growth function: In one embodiment, Fig. 20 As shown, after determining the memory growth function, the memory location analysis method further includes:

[0155] Step 2002, determining the memory growth call relationship through the call sequence recorded in the call function sequence including the memory growth node.

[0156] Specifically, after determining the memory growth function, the calling order recorded in the calling function sequence to which the memory growth function belongs is used to determine the memory growth calling relationship. The aforementioned memory growth calling relationship is specifically used to describe the calling relationship between memory growth functions, that is, the calling function whose difference between the memory calling information is not a positive value is not described into the memory growth calling relationship. For example, the original calling function sequence is [first calling function B1, first calling function B2, first calling function B3, first calling function B4], and the first calling function B1 and the first calling function B2 are determined as memory growth functions by the aforementioned method. Then, at this time, the memory growth calling relationship at least includes: the first calling function B1 calls the first calling function B2.

[0157] Step 2004: construct a memory growth tree structure based on the memory growth nodes and the memory growth call relationship.

[0158] The memory growth tree structure at least includes: memory increase nodes corresponding to each memory growth function, and the node attributes of the memory increase node at least include: the memory call information difference between the end time of the first time period and the end time of the second time period, the function name of the corresponding memory growth function, and the node level, etc. The aforementioned memory call information difference is the difference between the memory call information determined in the aforementioned embodiment, and the node level is used to describe the level of the memory increase node in the memory growth tree structure.

[0159] Specifically, the server constructs a memory growth tree structure based on the memory increase node and the memory growth call relationship. The way the server constructs the memory growth tree structure is similar to the way of constructing the first call tree structure introduced in the aforementioned embodiment, which will not be repeated here.

[0160] Step 2006, determine the complete call path through the memory growth tree structure, and parse the complete call path to determine the target reference relationship chain.

[0161] The complete calling path at least includes: the calling path for each memory growth function. Secondly, the target reference relationship chain is used to describe: the reference relationship for referencing each memory growth function.

[0162] Specifically, the complete call path is determined through the memory growth tree structure, and the complete call path is parsed to determine the target reference relationship chain. That is, the server searches the memory growth tree structure in the memory, and each memory increase node corresponds to the complete path name to which the function name of the memory increase function belongs. Based on this, the server can obtain the reference relationship chain of the complete path name through the singleref instruction.

[0163] For example, the function name of the memory growth function is: Baltic_Town_Residential_01_01_Orange, then the full path name of the function name is:

[0164] / Game / Maps / PUBG_Baltic / Baltic_Building / Baltic_Building_x3y4.Baltic_Build ing_x3y4:PersistentLevel.Baltic_Town_Residential_01_01_Orange. Then the server can obtain the reference relationship chain of the full path name through the singleref instruction. The specific operation method of the singleref instruction is not limited here.

[0165] Step 2008, performing memory location analysis through the target reference relationship chain.

[0166] Specifically, the server can obtain the reference relationship for each memory growth function through the target reference relationship chain, so as to analyze the functional module or functional control that specifically introduces the memory growth function, thereby preventing memory leaks or memory growth problems. The memory growth function is often referenced multiple times, so the target reference relationship chain can be multiple reference chains including the memory growth function, and the aforementioned multiple reference chains are all referenced by the same functional module or functional control. Therefore, it can be determined that the functional module or functional control that introduces the memory growth function is the cause of the memory, so the functional module or functional control that introduces the memory growth function is analyzed and optimized to avoid memory problems in subsequent operations.

[0167] In this embodiment, memory location analysis is performed through the memory growth function to determine the functional module or functional control that introduces the memory growth function, thereby ensuring the accuracy of the memory location analysis, and analyzing and optimizing the functional module or functional control that introduces the memory growth function to avoid memory problems in subsequent operations, thereby improving the efficiency and reliability of memory optimization.

[0168] The above describes how to obtain the first call tree structure. Based on the above description, the following describes how to obtain the second call tree structure. Fig.21 As shown, obtaining a second call tree structure corresponding to the second time period includes:

[0169] Step 2102: Acquire multiple second calling function sequences, where the second calling function sequences include second calling functions, and a second calling order exists between the second calling functions belonging to the same second calling function sequence.

[0170] The second calling function sequence includes the second calling function, and there is a second calling order between the second calling functions belonging to the same second calling function sequence. The specific second calling function is similar to the first calling function in the above embodiment, and will not be described again here.

[0171] Specifically, the server obtains multiple second calling function sequences within the second time period. That is, the server can obtain, at the end time of the second time period, the second calling function sequences corresponding to each memory allocation during the second time period, so the second calling function sequence specifically includes all the second calling functions called during the corresponding memory allocation.

[0172] Alternatively, the server may also obtain, at the end of the second time period, the second calling function sequence corresponding to each memory allocation during the second time period, and then store the second calling function sequence in a local storage, such as a data storage system connected to the server, and obtain the second calling function sequence from the local storage when memory location analysis is required. Therefore, the method of obtaining multiple second calling function sequences is not specifically limited here.

[0173] Step 2104: determine the second calling function whose second calling order is the starting order in each second calling function sequence as the parent function node corresponding to the second calling function sequence.

[0174] The parent function node is a function node corresponding to the second calling function whose second calling order is the starting order in the second calling function sequence. Specifically, the server determines the second calling function whose second calling order is the starting order in each second calling function sequence as the parent function node corresponding to the second calling function sequence. The specific confirmation method of the parent function node is similar to the aforementioned step 1204 and will not be repeated here.

[0175] Step 2106: construct a second call tree structure based on each parent function node and the second calling sequence between each second calling function.

[0176] Specifically, based on each parent function node and the second calling sequence between each second calling function, a second calling tree structure is constructed. That is, the server arranges the parent function nodes corresponding to each second calling function sequence and the second function nodes corresponding to the second calling functions in each second calling function sequence in sequence according to the second calling sequence to obtain the second calling tree structure.

[0177] In this embodiment, the second calling function in the starting order is determined as the parent function node, which can ensure that the subsequent function nodes sorted based on the parent function node can be accurately sorted and distributed based on the calling order, so that the obtained second call tree structure can accurately reflect the calling order between multiple calling functions when multiple memory allocations occur, so as to ensure the reliability and accuracy of the second call tree structure.

[0178] In one embodiment, Fig. 22 As shown, based on each parent function node and the second calling sequence between each second calling function, a second calling tree structure is constructed, including:

[0179] Step 2202: sort the second function nodes corresponding to the second calling functions in sequence based on the second calling sequence between the second function nodes and the parent function nodes to obtain a second calling tree structure.

[0180] Specifically, the server sequentially sorts the second function nodes corresponding to each second calling function based on the second calling sequence between each parent function node to obtain a second calling tree structure.

[0181] Optionally, the sequential sorting method can be to insert the second function nodes corresponding to the second calling functions into the first calling tree structure based on the calling relationship between the second function nodes and the parent function nodes of the second calling function sequence to which they belong. Therefore, the server can first insert the parent function nodes corresponding to the second calling function sequence newly added in the second time period compared to the first time period into the first calling tree structure. If there is a function node with the same function name as the node attribute of the parent function node in the first calling tree structure, the parent function node and the function node with the same function name can be merged, but at this time, the number of calls for memory allocation of the function node and the total amount of allocated memory are updated. Then, based on the second function nodes corresponding to each second calling function having the second calling sequence with each parent function node, the second function nodes are sequentially inserted into the first calling tree structure based on the parent function nodes, thereby obtaining the second calling tree structure.

[0182] Optionally, the sequential sorting method can also be: first construct the second function nodes corresponding to the second calling functions, then compare the node attributes of each second function node, merge the parent function nodes with the same function name, and then sort the second function nodes corresponding to each second calling function having a second calling order with each parent function node based on the parent function nodes to obtain the second call tree structure. The specific sequential sorting method is similar to that described in the aforementioned step 1302 and will not be repeated here.

[0183] It is understandable that the above examples are used to understand the present solution and should not be understood as specific limitations. When the server obtains the second call tree structure, it also needs to synchronously determine the node attributes of each second function node. The function name in the node attribute will not change, while the memory call information will be updated with each memory allocation. The following will explain in detail:

[0184] Step 2204: summing the number of times each second calling function performs memory allocation in the second time period to determine a second cumulative number of times each second calling function performs memory allocation.

[0185] Specifically, when the server obtains the second call tree structure, it is also necessary to sum the number of calls for each second call function to perform memory allocation in the second time period to determine the second cumulative number of calls for each second call function. The specific method for determining the second memory call information is similar to that described in step 1306 and will not be repeated here.

[0186] Step 2206: summing up the memory allocated by each second calling function during the second time period to determine a second cumulative allocated memory for each second calling function.

[0187] Specifically, when the server obtains the second call tree structure, it is also necessary to sum the memory allocated by each second call function during the second time period to determine the second cumulative allocated memory of each second call function. The specific determination method of the second cumulative allocated memory is similar to that introduced in step 1304, and will not be repeated here.

[0188] Step 2208: Determine each second accumulated call number and each second accumulated allocated memory as second memory call information in the node attribute of the second function node corresponding to the second calling function.

[0189] Specifically, the server determines the second cumulative call count of each second calling function and the second cumulative allocated memory of each second calling function as the second memory calling information in the node attribute of the second function node corresponding to the second calling function. The specific determination method is similar to that described in step 1308 and will not be repeated here.

[0190] In this embodiment, the parent function node corresponding to the second calling function sequence of each memory allocation can be determined by the calling sequence between the calling functions. The second calling tree structure obtained by sequentially arranging different parent function nodes can accurately reflect the calling sequence between multiple calling functions when multiple memory allocations are made, so as to ensure the reliability and accuracy of the second calling tree structure. Secondly, the node attributes of each function node are determined by summing the relevant memory information of the memory allocation in the second time period, so as to ensure the comprehensiveness and reliability of the stored memory calling information.

[0191] In one embodiment, Fig.23 As shown, multiple second calling function sequences are obtained, including:

[0192] Step 2302, obtaining the first address of the second stack frame and the end address of the second stack frame for each memory allocation in the second time period.

[0193] The stack frame first address is the first address of the register stack frame for each memory allocation, and the stack frame end address is the end address of the register frame stack for each memory allocation. Specifically, the server records the first address of the register stack frame for each memory allocation in the second time period, and the end address of the register frame stack for each memory allocation, and determines the first address of the register stack frame for each memory allocation as the first address of the second stack frame corresponding to each memory allocation, and determines the end address of the register frame stack for each memory allocation as the end address of the second stack frame corresponding to each memory allocation.

[0194] Step 2304: Obtain a second call value sequence corresponding to each memory allocation through the first address of each second stack frame and the end address of each second stack frame, wherein the second call value sequence includes a plurality of second call function address values.

[0195] Among them, the second call value sequence is composed of the call function address value called at the end of the corresponding memory allocation. Specifically, the server can obtain the second call value sequence corresponding to each memory allocation by performing a loop calculation through the first address of each second stack frame and the end address of each second stack frame. That is, for a memory allocation, the next stack address can be obtained by continuously subtracting 4 bytes (32-bit machine) or 8 bytes (64-bit machine) from the starting position, and the function address data in all stack frames are obtained in this loop, and then the second stack frame first address and the second stack frame end address of the memory allocation are used to obtain the function address data in all stack frames, and the second call value sequence of the memory allocation can be obtained.

[0196] Step 2306: parse each second call value sequence to obtain a second call function sequence corresponding to each second call value sequence.

[0197] Among them, the second calling function sequence includes: the second calling functions corresponding to the second calling function address values. Specifically, the server parses each second calling value sequence to obtain the second calling function sequence corresponding to each second calling value sequence. That is, the server parses each second calling value sequence once in the order from the first address to the end address to obtain the second calling function sequence corresponding to each second calling value sequence. At this time, the second calling order between each second calling function in the second calling function sequence is consistent with the order from the first address to the end address.

[0198] The specific implementation of step 2302 to step 2306 is similar to that of step 1602 to step 1606 in the aforementioned embodiment, and will not be repeated here.

[0199] In this embodiment, all second calling function address values ​​occupied when memory is allocated within the second time period can be accurately obtained through the first address of each second stack frame and the end address of each second stack frame, and the calling function to which each calling function address value actually corresponds is determined by parsing and locating each calling function address value, so as to ensure the accuracy and reliability of each calling function in the second calling function sequence, and the calling order between each calling function can be accurately determined through the relationship between the calling function address values, thereby ensuring the reliability and accuracy of the obtained second calling function sequence.

[0200] Based on the detailed description of the above embodiments, the complete process of the memory location analysis method in the embodiments of the present application will be described below. In one embodiment, Fig.24 As shown, a memory location analysis method is provided, which is applied to Figure 2 The method is described using the example of the server 204 in FIG. 1 . It is understandable that the method can also be applied to the terminal 202, and can also be applied to a system including the terminal 202 and the server 204, and is implemented through the interaction between the terminal 202 and the server 204. In this embodiment, the method includes the following steps:

[0201] Step 2401, obtaining the first stack frame start address and the first stack frame end address of each memory allocation within a first time period.

[0202] The stack frame first address is the first address of the register stack frame for each memory allocation, and the stack frame end address is the end address of the register frame stack for each memory allocation. Specifically, the server records the first address of the register stack frame for each memory allocation in the first time period, and the end address of the register frame stack for each memory allocation, and determines the first address of the register stack frame for each memory allocation as the first stack frame first address corresponding to each memory allocation, and determines the end address of the register frame stack for each memory allocation as the first stack frame end address corresponding to each memory allocation.

[0203] Step 2402: Obtain the first call value sequence corresponding to each memory allocation through the first address of each first stack frame and the end address of each first stack frame.

[0204] Among them, the first call value sequence is composed of the call function address value called at the end of the corresponding memory allocation. Specifically, the server can obtain the first call value sequence corresponding to each memory allocation by performing a loop calculation through the first address of each first stack frame and the end address of each first stack frame. That is, for a memory allocation, the next stack address can be obtained by continuously subtracting 4 bytes (32-bit machine) or 8 bytes (64-bit machine) from the starting position, and the function address data in all stack frames are obtained in this loop, and then the first stack frame first address and the first stack frame end address of this memory allocation are used to obtain the function address data in all stack frames, and then the first call value sequence of this memory allocation can be obtained.

[0205] Step 2403: parse each first call value sequence to obtain a first call function sequence corresponding to each first call value sequence.

[0206] Among them, the first call function sequence includes: the first call functions corresponding to the first call function address values. Specifically, the server parses each first call value sequence to obtain the first call function sequence corresponding to each first call value sequence. That is, the server parses each first call value sequence once in the order from the first address to the end address to obtain the first call function sequence corresponding to each first call value sequence. At this time, the first call order between each first call function in the first call function sequence is consistent with the order from the first address to the end address.

[0207] Step 2404, obtaining the first address of the second stack frame and the end address of the second stack frame for each memory allocation in the second time period.

[0208] The stack frame first address is the first address of the register stack frame for each memory allocation, and the stack frame end address is the end address of the register frame stack for each memory allocation. Specifically, the server records the first address of the register stack frame for each memory allocation in the second time period, and the end address of the register frame stack for each memory allocation, and determines the first address of the register stack frame for each memory allocation as the first address of the second stack frame corresponding to each memory allocation, and determines the end address of the register frame stack for each memory allocation as the end address of the second stack frame corresponding to each memory allocation.

[0209] Step 2405: Obtain the second call value sequence corresponding to each memory allocation through the first address of each second stack frame and the end address of each second stack frame.

[0210] Among them, the second call value sequence is composed of the call function address value called at the end of the corresponding memory allocation. Specifically, the server can obtain the second call value sequence corresponding to each memory allocation by performing a loop calculation through the first address of each second stack frame and the end address of each second stack frame. That is, for a memory allocation, the next stack address can be obtained by continuously subtracting 4 bytes (32-bit machine) or 8 bytes (64-bit machine) from the starting position, and the function address data in all stack frames are obtained in this loop, and then the second stack frame first address and the second stack frame end address of the memory allocation are used to obtain the function address data in all stack frames, and the second call value sequence of the memory allocation can be obtained.

[0211] Step 2406: parse each second call value sequence to obtain a second call function sequence corresponding to each second call value sequence.

[0212] Among them, the second calling function sequence includes: the second calling functions corresponding to the second calling function address values. Specifically, the server parses each second calling value sequence to obtain the second calling function sequence corresponding to each second calling value sequence. That is, the server parses each second calling value sequence once in the order from the first address to the end address to obtain the second calling function sequence corresponding to each second calling value sequence. At this time, the second calling order between each second calling function in the second calling function sequence is consistent with the order from the first address to the end address.

[0213] Step 2407 , comparing the difference between the memory call information between the function nodes at the same node level in the first call tree structure and the second call tree structure.

[0214] Specifically, the server compares the difference between the memory call information of the function nodes with the same node level in the first call tree structure and the second call tree structure. Since the memory call information includes at least: the cumulative number of calls and the cumulative allocated memory, the server specifically compares the difference between the cumulative number of calls and the cumulative allocated memory of the function nodes with the same node level in the first call tree structure and the second call tree structure.

[0215] Step 2408: determine the function node whose difference is a positive value as a memory growth node, and determine the calling function corresponding to the memory growth node as a memory growth function.

[0216] Among them, the memory growth node can be single or multiple, and the memory growth node must exist in the second call tree structure, that is, the memory growth node can be a function node newly added in the second call tree structure compared with the first call tree structure, and can be a function node with the same function name in the first call tree structure and the first call tree structure (that is, the same function node). Secondly, the memory growth function can also be single or multiple, and the memory growth function must also exist in the second call function sequence.

[0217] Specifically, the server determines the function node whose difference is positive as the memory growth node, and determines the call function corresponding to the memory growth node as the memory growth function. Since the memory call information includes at least: the cumulative number of calls and the cumulative allocated memory, the server specifically determines the function node whose difference is positive for the cumulative number of calls and the cumulative allocated memory as the memory growth node.

[0218] Step 2409, determining the memory growth calling relationship through the calling order recorded in the calling function sequence including the memory growth node.

[0219] Specifically, after determining the memory growth function, the calling order recorded in the calling function sequence to which the memory growth function belongs is used to determine the memory growth calling relationship. The aforementioned memory growth calling relationship is specifically used to describe the calling relationship between memory growth functions, that is, the calling function whose difference between memory calling information is not a positive value is not described in the memory growth calling relationship.

[0220] Step 2410, constructing a memory growth tree structure based on the memory growth nodes and the memory growth call relationship.

[0221] The memory growth tree structure at least includes: memory increase nodes corresponding to each memory growth function, and the node attributes of the memory increase node at least include: the memory call information difference between the end time of the first time period and the end time of the second time period, the function name of the corresponding memory growth function, and the node level, etc. The aforementioned memory call information difference is the difference between the memory call information determined in the aforementioned embodiment, and the node level is used to describe the level of the memory increase node in the memory growth tree structure.

[0222] Specifically, the server constructs a memory growth tree structure based on the memory increase node and the memory growth call relationship. The way the server constructs the memory growth tree structure is similar to the way of constructing the call tree structure introduced in the aforementioned embodiment, which will not be repeated here.

[0223] Step 2411, determine the complete call path through the memory growth tree structure, and parse the complete call path to determine the target reference relationship chain.

[0224] The complete calling path at least includes: the calling path for each memory growth function. Secondly, the target reference relationship chain is used to describe: the reference relationship for referencing each memory growth function.

[0225] Specifically, the complete call path is determined through the memory growth tree structure, and the complete call path is parsed to determine the target reference relationship chain. That is, the server searches the memory growth tree structure in the memory, and each memory increase node corresponds to the complete path name to which the function name of the memory increase function belongs. Based on this, the server can obtain the reference relationship chain of the complete path name through the singleref instruction.

[0226] Step 2412, perform memory location analysis through the target reference relationship chain.

[0227] Specifically, the server can obtain the reference relationship for each memory growth function through the target reference relationship chain, so as to analyze the functional module or functional control that specifically introduces the memory growth function, thereby preventing memory leaks or memory growth problems. The memory growth function is often referenced multiple times, so the target reference relationship chain can be multiple reference chains including the memory growth function, and the aforementioned multiple reference chains are all referenced by the same functional module or functional control. Therefore, it can be determined that the functional module or functional control that introduces the memory growth function is the cause of the memory, so the functional module or functional control that introduces the memory growth function is analyzed and optimized to avoid memory problems in subsequent operations.

[0228] It should be understood that the specific implementations of step 2401 to step 2412 are similar to the aforementioned embodiments and will not be repeated here.

[0229] It should be understood that, although the steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0230] Based on the same inventive concept, the embodiment of the present application also provides a memory location analysis device for implementing the memory location analysis method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more memory location analysis device embodiments provided below can refer to the limitations of the memory location analysis method above, and will not be repeated here.

[0231] In one embodiment, Fig.25 As shown, a memory location analysis device is provided, including: a call tree structure acquisition module 2502 and a memory growth function determination module 2504, wherein:

[0232] The call tree structure acquisition module 2502 is used to acquire a first call tree structure corresponding to the first time period, where the first call tree structure is constructed according to a first call sequence between first call functions in a plurality of first call function sequences within the first time period, and the first call tree structure at least includes: first function nodes corresponding to the first call functions;

[0233] The call tree structure acquisition module 2502 is further used to acquire a second call tree structure corresponding to the second time period, where the second call tree structure is constructed according to a second call sequence between the second call functions in a plurality of second call function sequences within the second time period, and the second call tree structure at least includes: second function nodes corresponding to the second call functions, respectively, and the end time of the second time period is later than the end time of the first time period;

[0234] The memory growth function determination module 2504 is used to compare the node attributes of each function node in the first call tree structure and the second call tree structure to determine the memory growth function. The second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes in the first call tree structure. The memory growth function is used for memory analysis and positioning.

[0235] In one embodiment, the call tree structure acquisition module 2502 is specifically used to obtain multiple first call function sequences, where the first call function sequence includes a first call function, and there is a first call order between each first call function belonging to the same first call function sequence; the first call function whose first call order in each first call function sequence is the starting order is determined as the parent function node corresponding to the first call function sequence; and a first call tree structure is constructed based on each parent function node and the first call order between each first call function.

[0236] In one embodiment, the call tree structure acquisition module 2502 is specifically used to sort the first function nodes corresponding to each first calling function in sequence based on the first calling order between each parent function node to obtain a first call tree structure; sum the number of calls for each first calling function to perform memory allocation within a first time period to determine the first cumulative number of calls for each first calling function; sum the memory allocated for memory allocation by each first calling function within the first time period to determine the first cumulative allocated memory for each first calling function; determine each first cumulative number of calls and each first cumulative allocated memory as the first memory call information in the node attributes of the first function node corresponding to the first calling function.

[0237] In one embodiment, the call tree structure acquisition module 2502 is also used to obtain the first stack frame start address and the first stack frame end address of each memory allocation in the first time period; through each first stack frame start address and each first stack frame end address, the first call value sequence corresponding to each memory allocation is obtained, and the first call value sequence includes multiple first call function address values; each first call value sequence is parsed to obtain the first call function sequence corresponding to each first call value sequence; wherein the first call function sequence includes: the first call function corresponding to each first call function address value.

[0238] In one embodiment, the node attributes of the function node include at least: node level and memory call information;

[0239] The memory growth function determination module 2504 is specifically used to compare the difference between the memory call information between the function nodes with the same node level in the first call tree structure and the second call tree structure; determine the function node with a positive difference as the memory growth node, and determine the call function corresponding to the memory growth node as the memory growth function.

[0240] In one embodiment, Fig.26 As shown, the memory location analysis device also includes a determination module 2602, a memory growth tree structure construction module 2604, and a memory location analysis module 2606;

[0241] A determination module 2602, configured to determine a memory growth call relationship by using a call sequence recorded in a call function sequence including a memory growth node;

[0242] A memory growth tree structure construction module 2604 is used to construct a memory growth tree structure based on memory growth nodes and memory growth call relationships;

[0243] The determination module 2602 is further used to determine the complete call path through the memory growth tree structure, and parse the complete call path to determine the target reference relationship chain;

[0244] The memory location analysis module 2606 is used to perform memory location analysis through the target reference relationship chain.

[0245] In one embodiment, the call tree structure acquisition module 2502 is specifically used to obtain multiple second calling function sequences, where the second calling function sequences include second calling functions, and there is a second calling order between the second calling functions belonging to the same second calling function sequence; the second calling function whose second calling order is the starting order in each second calling function sequence is determined as the parent function node corresponding to the second calling function sequence; and a second call tree structure is constructed based on each parent function node and the second calling order between each second calling function.

[0246] In one embodiment, the call tree structure acquisition module 2502 is specifically used to sort the second function nodes corresponding to each second calling function in sequence based on the second calling order between each parent function node to obtain a second call tree structure; sum the number of calls for each second calling function to perform memory allocation within the second time period to determine the second cumulative number of calls for each second calling function; sum the memory allocated for memory allocation by each second calling function within the second time period to determine the second cumulative allocated memory for each second calling function; determine each second cumulative number of calls and each second cumulative allocated memory as the second memory call information in the node attributes of the second function node corresponding to the second calling function.

[0247] In one embodiment, the call tree structure acquisition module 2502 is also used to obtain the second stack frame start address and the second stack frame end address of each memory allocation in the second time period; obtain the second call value sequence corresponding to each memory allocation through each second stack frame start address and each second stack frame end address, and the second call value sequence includes multiple second call function address values; parse each second call value sequence to obtain the second call function sequence corresponding to each second call value sequence; wherein the second call function sequence includes: the second call function corresponding to each second call function address value.

[0248] Each module in the above-mentioned memory location analysis device can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.

[0249] In one embodiment, a computer device is provided. The computer device may be a terminal or a server. The computer device is a server as an example for explanation. The internal structure diagram thereof may be as follows: Fig. 27As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as call function sequences and various tree structures. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a memory location analysis method is implemented.

[0250] Those skilled in the art will understand that Fig. 27 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0251] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0252] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0253] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0254] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0255] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0256] The technical feature information of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical feature information in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical feature information, they should be considered to be within the scope of this specification.

[0257] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A memory location analysis method, characterized in that: include: Obtaining a first call tree structure corresponding to a first time period, wherein the first call tree structure is constructed according to a first call sequence between first call functions in a plurality of first call function sequences within the first time period, and the first call tree structure at least includes: first function nodes corresponding to the first call functions; Obtaining a second call tree structure corresponding to a second time period, where the second call tree structure is constructed according to a second call sequence between second call functions in a plurality of second call function sequences within the second time period, where the second call tree structure at least includes: second function nodes corresponding to the second call functions, respectively, and an end time of the second time period is later than an end time of the first time period; The node attributes of each function node in the first call tree structure and the second call tree structure are compared to determine a memory growth function, wherein the second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes in the first call tree structure, and the memory growth function is used for memory analysis and positioning.

2. The method according to claim 1, characterized in that The obtaining of a first call tree structure corresponding to the first time period includes: Acquire the plurality of first calling function sequences, where the first calling function sequences include the first calling function, and the first calling order exists between the first calling functions belonging to the same first calling function sequence; Determine the first calling function whose first calling order is the starting order in each of the first calling function sequences as the parent function node corresponding to the first calling function sequence; The first call tree structure is constructed based on each of the parent function nodes and a first calling sequence between each of the first calling functions.

3. The method according to claim 2, characterized in that The constructing the first call tree structure based on each of the parent function nodes and a first calling sequence between each of the first calling functions includes: The first function nodes corresponding to the first calling functions are sequentially sorted based on the first calling sequence between the first function nodes and the parent function nodes to obtain the first calling tree structure; Summing up the number of times each of the first calling functions performs memory allocation within a first time period to determine a first cumulative number of times each of the first calling functions performs memory allocation; Summing up the memory allocated by each of the first calling functions during memory allocation in a first time period to determine a first cumulative allocated memory for each of the first calling functions; Each of the first accumulated call times and each of the first accumulated allocated memory is determined as first memory call information in a node attribute of a first function node corresponding to the first calling function.

4. The method according to claim 2, characterized in that: The obtaining of the plurality of first calling function sequences comprises: Obtaining the first stack frame start address and the first stack frame end address of each memory allocation within the first time period; Obtaining a first call value sequence corresponding to each memory allocation through the first stack frame start address and the first stack frame end address, wherein the first call value sequence includes a plurality of first call function address values; Parsing each of the first call value sequences to obtain the first call function sequences corresponding to each of the first call value sequences; The first calling function sequence includes: first calling functions corresponding to the first calling function address values.

5. The method according to claim 1, characterized in that The node attributes of a function node include at least: node level and memory call information; The comparing the node attributes of each function node in the first call tree structure and the second call tree structure to determine the memory growth function includes: Comparing the difference between the memory call information of the function nodes at the same node level in the first call tree structure and the second call tree structure; A function node whose difference is a positive value is determined as a memory growth node, and a calling function corresponding to the memory growth node is determined as the memory growth function.

6. The method according to claim 1, characterized in that After determining the memory growth function, the method further includes: Determine the memory growth call relationship by including the calling sequence recorded in the calling function sequence of the memory growth node; Based on the memory increase node and the memory growth call relationship, construct a memory growth tree structure; Determine a complete call path through the memory growth tree structure, and parse the complete call path to determine a target reference relationship chain; Memory location analysis is performed through the target reference relationship chain.

7. The method according to claim 1, characterized in that The obtaining of a second call tree structure corresponding to the second time period includes: Acquire the plurality of second calling function sequences, where the second calling function sequences include the second calling functions, and the second calling order exists between the second calling functions belonging to the same second calling function sequence; Determine the second calling function whose second calling order is the starting order in each of the second calling function sequences as the parent function node corresponding to the second calling function sequence; The second call tree structure is constructed based on each of the parent function nodes and a second calling sequence between each of the second calling functions.

8. The method according to claim 7, characterized in that The constructing the second call tree structure based on each of the parent function nodes and the second call sequence between each of the second call functions includes: The second function nodes corresponding to the second calling functions are sequentially sorted based on the second calling order between the second function nodes and the parent function nodes to obtain the second calling tree structure; Summing up the number of times each of the second calling functions performs memory allocation within a second time period to determine a second cumulative number of times each of the second calling functions performs memory allocation; Summing up the memory allocated by each of the second calling functions during memory allocation in the second time period to determine a second cumulative allocated memory for each of the second calling functions; Each of the second accumulated call times and each of the second accumulated allocated memory is determined as second memory call information in a node attribute of a second function node corresponding to the second calling function.

9. The method according to claim 7, characterized in that: The obtaining of the plurality of second calling function sequences comprises: Obtaining a second stack frame start address and a second stack frame end address for each memory allocation within a second time period; Obtaining a second call value sequence corresponding to each memory allocation through each second stack frame start address and each second stack frame end address, wherein the second call value sequence includes a plurality of second call function address values; Parsing each of the second call value sequences to obtain the second call function sequences corresponding to each of the second call value sequences; The second calling function sequence includes: second calling functions corresponding to respective second calling function address values.

10. A memory location analysis device, characterized in that: The device comprises: A call tree structure acquisition module is used to acquire a first call tree structure corresponding to a first time period, wherein the first call tree structure is constructed according to a first call sequence between first call functions in a plurality of first call function sequences within the first time period, and the first call tree structure at least includes: first function nodes corresponding to the first call functions; The call tree structure acquisition module is further used to acquire a second call tree structure corresponding to a second time period, wherein the second call tree structure is constructed according to a second call sequence between second call functions in a plurality of second call function sequences within the second time period, wherein the second call tree structure at least includes: second function nodes corresponding to the second call functions, respectively, and an end time of the second time period is later than an end time of the first time period; A memory growth function determination module is used to compare the node attributes of each function node in the first call tree structure and the second call tree structure to determine the memory growth function. The second memory call information in the node attributes of the function node corresponding to the memory growth function in the second call tree structure is greater than the first memory call information in the node attributes in the first call tree structure. The memory growth function is used for memory analysis and positioning.

11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.