Method and system for dumping heap data of application program, electronic equipment and storage medium
By dividing the heap data dump process of the application into two periods, the problem that the application needs to be suspended throughout the process in the existing technology is solved, and effective dumping and performance improvement of the application heap data is achieved.
Patent Information
- Application Number
- CN202311468014.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-06
- Publication Date
- 2025-05-06
AI Technical Summary
In the prior art, during the heap data dumping process of an application, the application needs to be suspended, resulting in performance failure and the heap data cannot be effectively dumped.
By detecting multiple sets of heap data to be dumped in the application, the heap data is written to the initial file within the first period, and the writing is completed when the application is suspended; then, multiple initial files are merged within the second period to generate the final heap dump file, and the application is in the continuous running state.
It realizes that the application's heap data is effectively dumped without the need for the entire heap dump process, shortening the application's pause time and improving the dump performance.
Smart Images

Figure CN119938345A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a method, system, electronic device and storage medium for dumping heap data of an application program. Background Art
[0002] Currently, in the process of performing a heap dump of an application, since the application must be suspended, a heap dump operation is performed through a virtual machine (VM), and the application is controlled to run again after the heap dump operation is completed. Therefore, how to solve the problem of suspending the application in the above process is very important.
[0003] In the related art, the parallel heap iteration feature of the global catalog (GC) can be used to perform a heap dump of the heap data (Java heap) in the application. However, since all the heap data will be competitively written into the same file, this will inevitably lead to strong lock contention and require additional physical memory to maintain related concurrent structures, which may result in the inability to improve the performance of the heap data dump. Therefore, there is still a technical problem that the heap data of the application cannot be effectively dumped.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide a method, system, electronic device and storage medium for dumping heap data of an application program, so as to at least solve the technical problem that the heap data of an application program cannot be effectively dumped.
[0006] According to one aspect of an embodiment of the present application, a method for dumping heap data of an application is provided. The method may include: detecting multiple groups of heap data to be dumped in the application; writing the multiple groups of heap data into corresponding initial files in a first time period to obtain multiple first target files, wherein the application is in a suspended running state in the first time period; merging the multiple first target files in a second time period after the first time period to obtain a second target file, wherein the application is in a continued running state in the second time period.
[0007] According to another aspect of the embodiment of the present application, a method for processing heap data of an application is provided. The method may include: determining an application to be processed in a virtual machine; detecting multiple groups of heap data to be dumped in the application; writing the multiple groups of heap data into corresponding initial files in a first time period to obtain multiple first target files, wherein the application is in a suspended state in the first time period; merging the multiple first target files in a second time period after the first time period to obtain a second target file in the local of the virtual machine, wherein the application is in a continued state in the second time period; and outputting the second target file to a data analysis platform associated with the virtual machine for analysis.
[0008] According to another aspect of the embodiment of the present application, a method for dumping heap data of an application is provided. The method may include: obtaining multiple groups of heap data to be dumped in the application by calling a first interface, wherein the first interface includes a first parameter, and the parameter value of the first parameter is multiple groups of heap data; in a first time period, writing the multiple groups of heap data into corresponding initial files respectively to obtain multiple first target files, wherein the application is in a suspended running state in the first time period; in a second time period after the first time period, merging the multiple first target files to obtain a second target file, wherein the application is in a continued running state in the second time period; outputting the second target file by calling a second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter is the second target file.
[0009] According to another aspect of the embodiment of the present application, a heap data dump system of an application is provided. The system may include: a heap data dump device, used to detect multiple groups of heap data to be dumped in the application of the virtual machine; in a first time period, the multiple groups of heap data are written into the corresponding initial files respectively to obtain multiple first target files, wherein the application is in a suspended operation state in the first time period; in a second time period after the first time period, the multiple first target files are merged to obtain a second target file, wherein the application is in a continued operation state in the second time period; a server, used to receive the second target file, and output the second target file to a data analysis platform associated with the virtual machine for analysis.
[0010] According to another aspect of an embodiment of the present application, an electronic device is also provided. The electronic device may include a memory and a processor: the memory is used to store computer-executable instructions, and the processor is used to execute computer-executable instructions. When the above-mentioned computer-executable instructions are executed by the processor, a heap data dump method of any of the above-mentioned applications is implemented.
[0011] According to another aspect of an embodiment of the present application, a processor is further provided, and the processor is used to run a program, wherein any one of the above-mentioned methods for dumping heap data of an application program is executed when the program is running.
[0012] According to another aspect of an embodiment of the present application, a computer-readable storage medium is further provided, the computer-readable storage medium including a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute any one of the above-mentioned methods for dumping heap data of the application program.
[0013] In an embodiment of the present application, the heap data that needs to be dumped in the application can be detected and divided into multiple groups. In the first period when the application is in a suspended state, the heap data of different groups can be written into the corresponding initial files respectively to obtain the first target file corresponding to each group. After all the heap data to be dumped are written into the initial file, the application can be controlled to continue running, and in the second period when the application is in a continued running state, the first target file of each group is merged to obtain the final complete second target file that needs to be dumped, thereby completing the process of dumping the heap data to be dumped in the application. Considering that the process of dumping the heap data of the entire application can be divided into two different time periods, in the first time period, the application has to suspend running while the heap data is written to the initial file, and in the second time period, the application does not need to suspend running while the first target file is merged to complete the second target file. Therefore, by analyzing whether the application needs to be suspended to divide the time periods, it is possible to avoid the situation where the application needs to be suspended during the entire heap dump process. Instead, the application does not need to be suspended at a certain stage to achieve the purpose of shortening the suspension time of the application, thereby achieving the technical effect of effectively dumping the heap data of the application and solving the technical problem of not being able to effectively dump the heap data of the application.
[0014] It is easy to notice that the above general description and the following detailed description are only for the purpose of exemplifying and explaining the present application, and do not constitute a limitation of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0016] Figure 1 It is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a heap data dump method of an application program according to an embodiment of the present application;
[0017] Figure 2It is a structural block diagram of a computing environment of a heap data dumping method of an application program according to an embodiment of the present application;
[0018] Figure 3 is a flow chart of a method for dumping heap data of an application according to an embodiment of the present application;
[0019] Figure 4 is a flow chart of another method for dumping heap data of an application according to an embodiment of the present application;
[0020] Figure 5 is a flow chart of another method for dumping heap data of an application according to an embodiment of the present application;
[0021] Figure 6 is a schematic diagram of a heap data dump system of an application according to an embodiment of the present application;
[0022] Figure 7 is a schematic diagram of dumping heap data in an application program in a related technology according to an embodiment of the present application;
[0023] Figure 8 is a schematic diagram of a Java two-stage heap dump with a micro-pause according to an embodiment of the present application;
[0024] Fig. 9 is a schematic diagram of a heap data dumping device of an application according to an embodiment of the present application;
[0025] Fig.10 is a schematic diagram of another heap data dumping device of an application according to an embodiment of the present application;
[0026] Fig.11 is a schematic diagram of another heap data dumping device of an application according to an embodiment of the present application;
[0027] Fig.12 is a structural block diagram of a computer terminal according to an embodiment of the present application;
[0028] Fig.13 The present invention is a block diagram of an electronic device for a method for dumping heap data of an application according to an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0032] Java Virtual Machine (JVM) is a virtual machine that can execute Java bytecodes. It is implemented as a stack structure machine. It was first developed and implemented by Sun Microsystems. It is part of the Java platform and can execute software programs written in Java.
[0033] Heap Dump: save the application's heap data to a local file in real time for subsequent analysis;
[0034] Stop the World (STW) means that when a GC event occurs, the application will pause. When the pause occurs, all threads in the entire application will be paused and there will be no response.
[0035] Example 1
[0036] According to an embodiment of the present application, a method for dumping heap data of an application is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0037] The method embodiment provided in Embodiment 1 of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for dumping heap data of an application according to an embodiment of the present application, such as Figure 1As shown, the computer terminal 10 (or mobile device) may include one or more (shown in the figure as 102a, 102b, ..., 102n) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor (Microcontroller Unit, referred to as MCU) or a programmable logic device (Field Programmable Gate Array, referred to as FPGA)), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0038] Figure 1 The hardware structure block diagram shown can be used not only as an exemplary block diagram of the above-mentioned computer terminal 10 (or mobile device), but also as an exemplary block diagram of the above-mentioned server. In an optional embodiment, Figure 2 The block diagram shows the use of the above Figure 1 The computer terminal 10 (or mobile device) shown is an embodiment of a computing node in the computing environment 201. Figure 2 is a structural block diagram of a computing environment of a heap data dumping method of an application according to an embodiment of the present application, such as Figure 2 As shown, computing environment 201 includes multiple computing nodes (such as servers) running on a distributed network (shown as 210-1, 210-2, ..., in the figure). The computing nodes all contain local processing and memory resources, and end users 202 can remotely run applications or store data in computing environment 201. Applications can be provided as multiple services 220-1, 220-2, 220-3 and 220-4 in computing environment 201, representing services "A", "D", "E" and "H" respectively.
[0039] The end user 202 can provide and access services through a web browser or other software application on the client, and in some embodiments, the end user 202's provision and / or request can be provided to the entry gateway 230. The entry gateway 230 can include a corresponding agent to handle the provision and / or request for the service (one or more services provided in the computing environment 201).
[0040] Services are provided or deployed based on various virtualization technologies supported by the computing environment 201. In some embodiments, services can be provided based on virtual machine (VM)-based virtualization, container-based virtualization, and / or similar methods. Virtual machine-based virtualization can be to simulate a real computer by initializing a virtual machine, and execute programs and applications without directly contacting any actual hardware resources. While the virtual machine virtualizes the machine, according to container-based virtualization, a container can be started to virtualize the entire operating system (Operating System, referred to as OS) so that multiple workloads can run on a single operating system instance.
[0041] In an embodiment based on container virtualization, several containers of a service can be assembled into a Pod (e.g., a Kubernetes Pod). Figure 2 As shown, service 220-2 can be equipped with one or more Pods 240-1, 240-2, ..., 240-N (collectively referred to as Pods). Pods can include a proxy 245 and one or more containers 242-1, 242-2, ..., 242-M (collectively referred to as containers). One or more containers in a Pod process requests related to one or more corresponding functions of the service, and the proxy 245 generally controls network functions related to the service, such as routing, load balancing, etc. Other services can also be equipped with Pods similar to Pods.
[0042] During operation, executing a user request from end user 202 may require invoking one or more services in computing environment 201, and executing one or more functions of a service may require invoking one or more functions of another service. Figure 2 As shown, service "A" 220-1 receives a user request from end user 202 from ingress gateway 230, service "A" 220-1 may call service "D" 220-2, and service "D" 220-2 may request service "E" 220-3 to perform one or more functions.
[0043] The computing environment described above can be a cloud computing environment, where the allocation of resources is managed by the cloud service provider, allowing the development of functions without considering the implementation, adjustment or expansion of servers. The computing environment allows developers to execute code in response to events without building or maintaining complex infrastructure. Services can be divided into a set of functions that can be automatically and independently scaled, rather than expanding a single hardware device to handle potential loads.
[0044] Under the above operating environment, this application provides Figure 3It should be noted that the heap data dumping method of the application program of this embodiment can be performed by Figure 1 The illustrated embodiment is executed by a mobile terminal. Figure 3 is a flow chart of a method for dumping heap data of an application according to an embodiment of the present application, such as Figure 3 As shown, the method may include the following steps:
[0045] Step S302: Detect multiple groups of heap data to be dumped in the application.
[0046] In the technical solution provided in the above step S302 of the present application, the heap data to be dumped in the application can be detected to obtain multiple groups of heap data, wherein the application can be a Java application. Different groups of heap data can correspond to different initial files, and different groups of heap data can also correspond to the same initial file. The initial file can be a dump file to be written to the corresponding heap data, and its number can be the same as the number of heap data to be grouped. There are differences in the naming of the initial files corresponding to different groups of heap data. For example, the initial file corresponding to the heap data of the first group is named "dump.p1", the initial file corresponding to the heap data of the second group is named "dump.p2", and the initial file corresponding to the heap data of the third group is named "dump.p3".
[0047] It should be noted that the number of groups into which the pile data is to be divided, the naming method of the initial files corresponding to different groups, and whether the initial files corresponding to different groups of pile data are the same are only examples and are not specifically limited here.
[0048] Optionally, if it is necessary to dump the heap data in the application, the plurality of heap data to be dumped in the application can be grouped in advance to obtain multiple groups of heap data. Therefore, when it is detected that there is a need to dump certain groups of heap data, it is possible to detect which multiple groups of heap data are to be dumped, so as to facilitate processing of the multiple groups of heap data to be dumped and complete the dump operation.
[0049] Optionally, when it is detected that some groups of heap data among the multiple groups of heap data in the application need to be dumped, an initial file corresponding to the group of heap data to be dumped may be determined.
[0050] Step S304, writing multiple groups of heap data into corresponding initial files respectively in a first period of time to obtain multiple first target files, wherein the application is in a suspended state in the first period of time.
[0051] In the technical solution provided in the above step S304 of the present application, after detecting that there are multiple groups of heap data to be dumped in the application and determining the initial files corresponding to the groups of heap data, the application can enter the first time period. During the first time period, the application can be controlled to be in a suspended state, at which time the heap data of different groups can be written (Dump Writer) to the initial files corresponding to the groups to obtain the first target files of different groups, wherein the application can be in a suspended state during the first time period, and during this first time period, the threads in the application will be suspended and there will be no response. Among them, the first time period can also be referred to as the application suspension execution phase or the first phase. The number of first target files can be the same as the number of groups of heap data to be dumped, that is, multiple first target files correspond one-to-one to multiple groups of heap data, and the number of first target files can also be less than the number of groups of heap data to be dumped, that is, multiple heap data and multiple first target files can also be many-to-one. The first target file can also be referred to as a segmented file.
[0052] Optionally, in the first stage (STW) of this embodiment, the multiple groups of heap data to be dumped can be written into segmented files corresponding to different groups through an application thread in the application, that is, the heap data can be written into the initial files corresponding to the respective groups. After the multiple groups of heap data to be dumped are written, the first target file of each group can be obtained, that is, the segmented file into which the heap data is written, wherein the application thread can be referred to as a thread for short.
[0053] Considering that in the whole process of dumping the heap data of the application in the related art, it is necessary to suspend the whole application thread to perform the dumping operation of the heap data, and only after the dumping operation is completed, the whole application thread is started to continue running. Therefore, there is still a technical problem of suspending the operation of the application during the whole heap data dumping process. However, in the embodiment of the present application, the dumping process of the heap data can be analyzed to determine whether the whole dumping process requires the application to suspend operation to execute, and the analysis shows that only part of the process in the whole process requires the application to suspend operation, and the application can continue to run at other times. After the above analysis, the whole dumping process can be divided into two stages, the first stage is the stage of suspending the execution of the application, in which the multithreading in the application can be controlled to write the heap data to be dumped into the file of the corresponding segmentation. In the second stage, the application does not need to suspend execution. Through the above analysis, the embodiment of the present application achieves the purpose of being able to slightly suspend the application, thereby realizing the technical effect of not suspending the application Hengxu during the whole heap data dumping process.
[0054] Step S306: In a second time period after the first time period, the plurality of first target files are merged to obtain a second target file, wherein the application is in a continuous running state in the second time period.
[0055] In the technical solution provided in the above step S306 of the present application, in the first time period, the multiple groups of heap data to be dumped are written into the initial files corresponding to each group respectively, and after obtaining the first target file, the second time period can be entered. In the second time period, the application can be controlled to resume operation so that the application is in a continued operation state. In the second time period, the first target file in which the heap data has been written can be merged to obtain the merged second target file, wherein the application can be in a continued operation state in the second time period. The second time period can also be referred to as the second stage or the application recovery execution (Non-STW) stage. The second target file can be the complete heap dump file obtained after the merger is completed, which can be named dump.hprof, and the heap dump file can be used to be stored locally, thereby forming a local file.
[0056] Optionally, after writing the heap data into the corresponding first target file through the first stage, the second stage can be entered. In the second stage, the first target files corresponding to the groups to be dumped can be merged into a complete second target file, and the second target file can be stored locally as a local file, so that it can be directly analyzed through the local file later.
[0057] Optionally, in the second stage, multiple segment files can be merged into a complete heap dump file, and throughout the second stage, the application can continue to execute without STW.
[0058] In the disclosed embodiment, considering that if the application is in the STW state throughout the entire application heap data dump process, there is still a technical problem that the application is suspended for a long time. The above situation can be solved by dividing the heap data dump process into two stages. In the second stage included in the two stages, it is not necessary to suspend the application, so that the suspension time of the entire application can be shortened from the entire heap data dump process to the first stage, thereby achieving the technical effect of shortening the suspension time of the application.
[0059] Through the above steps S302 to S306 of the present application, the heap data that needs to be dumped in the application can be detected and divided into multiple groups. In the first period when the application is in a suspended state, the heap data of different groups can be written into the corresponding initial files respectively to obtain the first target file corresponding to each group. After all the heap data to be dumped are written into the initial file, the application can be controlled to continue running, and in the second period when the application is in a continued running state, the first target file of each group is merged to obtain the final complete second target file that needs to be dumped, thereby completing the process of dumping the heap data to be dumped in the application. Considering that the process of dumping the heap data of the entire application can be divided into two different time periods, in the first time period, the application has to suspend running while the heap data is written to the initial file, and in the second time period, the application does not need to suspend running while the first target file is merged to complete the second target file. Therefore, by analyzing whether the application needs to be suspended to divide the time periods, it is possible to avoid the situation where the application needs to be suspended during the entire heap dump process. Instead, the application does not need to be suspended at a certain stage to achieve the purpose of shortening the suspension time of the application, thereby achieving the technical effect of effectively dumping the heap data of the application and solving the technical problem of not being able to effectively dump the heap data of the application.
[0060] The above method of this embodiment is further introduced below.
[0061] As an optional implementation, step S304, within the first time period, write multiple groups of heap data into corresponding initial files respectively to obtain multiple first target files, including: within the first time period, write multiple groups of heap data into corresponding initial files in parallel to obtain multiple first target files.
[0062] In this embodiment, in the first time period, multiple groups of heap data can be written into the initial files corresponding to each group in parallel, so as to obtain a first target file after the writing of the heap data is completed.
[0063] Optionally, the heap data in the application can be grouped into different groups, and different groups correspond to different initial files. If it is detected that there is heap data that needs to be dumped, the groups of the heap data to be dumped can be determined, thereby determining the initial files corresponding to the groups of the heap data to be dumped.
[0064] Optionally, by performing multi-thread concurrent processing on application threads in the application, the heap data of each group to be dumped are written in parallel into segmented files of the corresponding group.
[0065] Since the GC parallel heap iteration characteristics are used in the related art to try to alleviate the problem that the application is in the STW state during the entire heap data dump process, however, the concurrent threads in the method all competitively write the heap data to the same file, however, the problem of strong lock competition will inevitably be designed, and additional physical memory is required to maintain the above-mentioned concurrent threads (concurrent structure), therefore, resulting in the technical problem of consuming additional memory overhead to maintain concurrent threads during the heap data dump process of the application. However, in an embodiment of the present application, the heap data is written to multiple segmented files concurrently by multiple threads, and the concurrent threads no longer need to maintain a buffer queue (Buffer Queue) and bear additional memory overhead, and there is no lock grabbing, thereby achieving the technical effect of avoiding consuming additional memory overhead to maintain concurrent threads during the heap data dump process of the application.
[0066] As an optional implementation, step S304, within a first time period, writes multiple groups of heap data into corresponding initial files respectively to obtain multiple first target files, including: within the first time period, using the multi-threading of the application to send corresponding heap data to the corresponding initial files respectively; in response to completing the sending of the corresponding heap data to the corresponding initial files, pausing the running of the multi-threading, and writing the sent heap data into the corresponding initial files to obtain corresponding first target files.
[0067] In this embodiment, during the first period, the multithreading of the application can be used to send the corresponding heap data to the corresponding initial file. In this process, it can be detected in real time whether the heap data to be dumped are all sent to the corresponding initial file. If so, it can be said that the process of sending the corresponding heap data to the corresponding initial file is completed. At this time, the multithreading in the application can be suspended, and the sent heap data can be written into the corresponding initial file to obtain the corresponding first target file.
[0068] Optionally, in the STW stage, multiple groups of dumped heap data can be sent to the initial files of the corresponding groups through the multi-threads in the application. For example, a corresponding application thread can be matched for each group of heap data to be dumped. After the matching is completed, the application threads corresponding to each group can be controlled in parallel to send the heap data of the corresponding group to the initial file. After detecting that the heap data to be dumped are all sent to the initial file corresponding to the group of the heap data, the heap data Dump Writer sent is sent to the corresponding initial file to obtain the segmented file in which the heap data is written. And in the STW stage, due to the pause of the application, and the process of the pause, the threads in the entire application will be suspended, and there will be no response.
[0069] As an optional implementation, in the first time period, the multi-threads of the application are respectively used to send the corresponding heap data to the corresponding initial file, including: in the first time period, the multi-threads of the application are respectively used to send the corresponding heap data to the corresponding initial file in parallel.
[0070] In this embodiment, in the first time period, the multithreading of the application program can be used to send corresponding groups of heap data to the corresponding initial files in parallel.
[0071] Optionally, in the first stage, the heap data may be written to multiple segmented files concurrently by multiple threads.
[0072] For example, after detecting three groups of heap data to be transferred out in the application, three groups of initial files corresponding to the groups of heap data can be determined, for example, the three groups of initial files are dump.p1, dump.p2 and dump.p3. The first group of heap data can be sent to dump.p1, the second group of heap data can be sent to dump.p2, and the third group of heap data can be sent to dump.p3 through multithreading. The first group of heap data can be dumped into dump.p1 to obtain the segmented files of the first group; the second group of heap data can be dumped into dump.p2 to obtain the segmented files of the second group; the third group of heap data can be dumped into dump.p3 to obtain the segmented files of the third group.
[0073] As an optional implementation, the method further includes: allocating a corresponding initial file to each group of data based on the data volume of each group of data in different groups of data.
[0074] In this embodiment, the data volume of the heap data contained in each group to be dumped can be determined, and a corresponding initial file can be allocated to each group according to the data volume of the heap data to be dumped.
[0075] Optionally, if there are multiple groups of heap data corresponding to the same initial file, that is, a many-to-one situation, at this time, if it is necessary to allocate initial files to the multiple groups of heap data according to the amount of data, it is necessary to consider the amount of data of the heap data in each group in the multiple groups of heap data corresponding to the initial file to determine the initial file to be allocated.
[0076] Optionally, if there is a situation where a single group of data corresponds to an initial file, that is, a one-to-one situation, at this time, if it is necessary to allocate initial files to multiple groups of heap data according to the data volume, it is necessary to consider the data volume of the heap data of the group corresponding to the initial file to determine the initial file to be allocated for the current group of heap data.
[0077] For example, if the heap data to be dumped is one-to-one with the initial file, that is, one group of heap data corresponds to one initial file, then the amount of heap data in each group to be dumped can be determined, and the initial file corresponding to each group can be determined by the amount of data in each group. For example, if the amount of heap data in a certain group is large, then it can be matched with an initial file that can store a larger amount of data; if the amount of heap data in a certain group is small, then it can be matched with an initial file that can store a smaller amount of data.
[0078] In an embodiment of the present application, the initial file to be matched is determined based on the amount of heap data to be dumped in each group corresponding to the initial file, thereby avoiding the situation where the amount of heap data does not match the amount of data that can be written in the initial file, resulting in a corresponding amount of heap data not being written in the matched initial file, or a waste caused by a large amount of data that can be written in the initial file, thereby achieving a technical effect of improving the accuracy of matching the initial file.
[0079] As an optional implementation, based on the data volume of each group of data in different groups of data, a corresponding initial file is allocated to each group of data, including: in the third target file, segmented files matching the data volume of different groups of data are obtained respectively, wherein the initial file includes the segmented file.
[0080] In this embodiment, in the third target file, the segmented files that match it can be obtained according to the data amount of different groups of data, wherein the initial file can include segmented files, and different segmented files corresponding to different groups of data can be used to splice into the third target file. The storage space occupied by the third target file is less than the storage space occupied by the second target file. The segmented file can be a form of the initial file that can divide a large file into multiple smaller file segments to facilitate transmission and storage. It should be noted that the segmented files included in the above-mentioned initial file are only for example illustration, and no specific restrictions are made here. In addition to the segmented files, other files that can be used for splicing can also be used, such as text files, table files, image files, audio files, video files, compressed files, database files and log files, etc., which are not specifically limited here. As long as the files are spliced at the binary or text level, they are all within the protection scope of the embodiments of the present application.
[0081] Optionally, the corresponding segment files in the first target file are matched according to the data volume of the heap data in different groups, and the segment files can be spliced into a third target file whose storage space is smaller than the storage space of the second target file.
[0082] As an optional implementation, step S306, merging multiple first target files in a second time period after the first time period to obtain a second target file, includes: in the second time period after the first time period, splicing multiple first target files to obtain the second target file.
[0083] In this embodiment, in a second time period after the first time period, a plurality of first target files may be spliced to obtain a final spliced and completed second target file.
[0084] Optionally, in order to obtain a final complete heap dump file, in the second stage, multiple segment files can be merged into a complete heap dump file. In this stage, the application can continue to execute without STW.
[0085] As an optional implementation, in a second time period after the first time period, multiple first target files are spliced together to obtain a second target file, including: in the second time period after the first time period, multiple first target files are spliced together using the multi-threading of the application to obtain the second target file.
[0086] In this embodiment, in a second time period after the first time period, the multithreading of the application program can be used to perform splicing processing on a corresponding number of first target files to obtain a spliced second target file.
[0087] Optionally, in the Non-STW stage, the first target file of the heap data written to the corresponding group can be spliced by multithreading in the application, and the first target files corresponding to the group to be dumped can be merged into a complete second target file. For example, the file can be sent (send file) to the request receiving thread (AttachListener), and the first target file corresponding to the group to be dumped can be spliced (splice) by Attach Listener to obtain the final complete heap dump file, that is, dump.hprof file. And in the Non-STW stage, since the application does not need to pause during this process, the dumping process of the heap data in the application is divided into two stages to ensure that the application can be executed normally during this stage.
[0088] For example, after writing the heap data of the first group into dump.p1 to obtain the segmented file of the first group, writing the heap data of the second group into dump.p2 to obtain the segmented file of the second group, and writing the heap data of the third group into dump.p3 to obtain the segmented file of the third group, the dump.p1, dump.p2 and dump.p3 corresponding to the first group, the second group and the third group can be spliced together to obtain a complete heap dump file dump.hprof obtained by splicing and merging the above three groups.
[0089] As an optional implementation, in a second time period after the first time period, multiple first target files are spliced together to obtain a second target file, including: in the second time period after the first time period, multiple first target files are spliced together according to the arrangement order of the corresponding initial files to obtain the second target file.
[0090] In this embodiment, in a second time period after the first time period, the splicing order between the first target files can be determined according to the arrangement order of the initial files corresponding to the heap data to be dumped, and the first target files can be spliced according to the splicing order to obtain the second target file after the final splicing is completed.
[0091] Optionally, an arrangement order of initial files corresponding to the group of heap data to be dumped is determined, and according to the arrangement order, an arrangement order between the first target files after each initial file is written into the heap data in the group is determined, so that the arrangement order can be determined as the splicing order for splicing and merging the first target files, so that the corresponding first target files under each group can be spliced and merged according to the corresponding splicing order to obtain a final heap dump file.
[0092] For example, the amount of data that can be written in the initial file can be used as the basis for the arrangement order, or the priority of the initial file can be used as the basis for the arrangement order. It should be noted that the above determination of the arrangement order of the initial files, that is, the basis for considering the splicing order of the first target file is only for example description and is not specifically limited here.
[0093] As an optional implementation, the second target file is a heap dump file.
[0094] In this embodiment, the second target file may be a complete heap dump file obtained by concatenating and merging the first target files.
[0095] Optionally, the heap data to be dumped is written into an initial file to obtain a first target file, and the heap dump file obtained by splicing the first target file can be saved in a local file in real time for subsequent analysis.
[0096] The present application also provides a method for processing heap data of an application program. Figure 4 is a flow chart of a method for processing heap data of an application according to an embodiment of the present application, such as Figure 4 As shown, the method may include the following steps:
[0097] Step S402: determine the application program to be processed in the virtual machine.
[0098] In the technical solution provided in step S402 of the present application, the application to be processed in the virtual machine can be determined, wherein the virtual machine can be a Java virtual machine. The application can be created based on an object-oriented programming language, for example, can be created based on Java, that is, can be a Java application.
[0099] Optionally, an application program for which heap data dumping is required may be determined from the application programs in the virtual machine, that is, the application program to be processed.
[0100] Step S404: Detect multiple groups of heap data to be dumped in the application.
[0101] In the technical solution provided in the above step S404 of the present application, after determining the application to be processed in the virtual machine, multiple groups of heap data to be dumped in the application to be processed can be detected, wherein different groups of heap data can correspond to different initial files in the local of the virtual machine, and different groups of heap data can also correspond to the same initial file in the local of the virtual machine.
[0102] Optionally, after the application to be processed in the virtual machine is determined, the heap data in the application to be processed may be detected, and the groups corresponding to the heap data may be determined, and the initial files corresponding to the groups may also be determined.
[0103] Optionally, if it is necessary to dump the heap data in the application, the heap data contained in the application can be grouped in advance to obtain multiple groups of heap data. Therefore, when it is detected that there is a need to dump some groups of heap data, the group corresponding to the heap data to be dumped can be detected, and the initial file corresponding to the group, that is, the segmented file, can be determined.
[0104] Step S406, writing the plurality of groups of heap data into corresponding initial files respectively in a first period of time to obtain a plurality of first target files, wherein the application is in a suspended state in the first period of time.
[0105] In the technical solution provided in the above step S406 of the present application, after detecting that there are multiple groups of heap data to be dumped in the application and determining the initial files corresponding to the groups of heap data, the application can enter the first time period. During the first time period, the application can be controlled to be in a suspended state, at which time different groups of heap data can be written to the initial files of the corresponding groups to obtain different groups of first target files, wherein the application can be in a suspended state during the first time period. The number of first target files can be the same as the number of groups of heap data to be dumped, that is, multiple first target files correspond one-to-one to multiple groups of heap data, and the number of first target files can also be less than the number of groups of heap data to be dumped, that is, multiple heap data and multiple first target files can also be many-to-one. .
[0106] Optionally, in the STW stage, multiple groups of heap data to be dumped can be written into segmented files corresponding to different groups through the application thread in the application, that is, the heap data can be written into the initial files corresponding to the respective groups. After the multiple groups of heap data to be dumped are written, the first target file of each group can be obtained, that is, the segmented file into which the heap data is written.
[0107] Step S408, in a second time period after the first time period, the plurality of first target files are merged to obtain a second target file in the local of the virtual machine, wherein the application is in a continuous running state in the second time period.
[0108] In the technical solution provided in the above step S408 of the present application, in the first period, the multiple groups of heap data to be dumped are respectively written into the initial files corresponding to each group, and after obtaining the first target file, the second period can be entered. In the second period, the application can be controlled to resume operation so that the application is in a continuous operation state. In the second period, the first target files into which the heap data has been written can be merged to obtain the merged second target file, wherein the application is in a continuous operation state in the second period.
[0109] Optionally, after writing the heap data into the corresponding first target file through the first stage, the second stage can be entered. In the second stage, the first target files corresponding to the groups to be dumped can be merged into a complete second target file, and the second target file can be stored locally as a local file, so that it can be directly analyzed through the local file later.
[0110] In an embodiment of the present application, the dumping process of the heap data can be analyzed to determine whether the entire dumping process requires the application to be suspended to execute. The analysis shows that only part of the process in the entire process requires the application to be suspended, and the application can continue to run at other times. Through the above analysis, the entire dumping process can be divided into two stages. The first stage is the stage in which the application is suspended. In this stage, the multithreading in the application can be controlled to write the heap data to be dumped into the corresponding segmented files. In the second stage, the application does not need to suspend execution. Through the above analysis, the embodiment of the present application achieves the purpose of being able to slightly suspend the application, thereby achieving the technical effect of not having to suspend the application during the entire heap data dumping process.
[0111] Step S410: output the second target file to a data analysis platform associated with the virtual machine for analysis.
[0112] In the technical solution provided in the above step S410 of the present application, after the first target file is merged in the second time period to obtain the second target file, the second target file output value can be analyzed in the data analysis platform associated with the virtual machine.
[0113] Optionally, the second target file obtained by splicing and merging, that is, the heap dump file, can be saved in a local file. If the heap dump file of the application needs to be analyzed, the heap dump file of the corresponding application in the local file can be analyzed through the data analysis platform associated with the virtual machine.
[0114] Through the above steps S402 to S410 of the present application, the application to be processed in the virtual machine is determined; multiple groups of heap data to be dumped in the application are detected; in a first time period, the multiple groups of heap data are written into the corresponding initial files respectively to obtain multiple first target files, wherein the application is in a suspended state in the first time period; in a second time period after the first time period, the multiple first target files are merged to obtain a second target file in the local of the virtual machine, wherein the application is in a continued state in the second time period; the second target file is output to a data analysis platform associated with the virtual machine for analysis, thereby achieving the technical effect of being able to effectively dump the heap data of the application, and solving the technical problem that the heap data of the application cannot be effectively dumped.
[0115] The embodiment of the present application also provides another method for dumping heap data of an application. Figure 5 is a flowchart of another method for dumping heap data of an application according to an embodiment of the present application, such as Figure 5 As shown, the method may include the following steps:
[0116] Step S502, obtaining multiple groups of heap data to be dumped in the application by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter is multiple groups of heap data, and different groups of heap data correspond to different initial files.
[0117] In the technical solution provided in the above step S502 of the present application, multiple groups of heap data to be dumped in the application program of the virtual machine can be obtained by calling the first interface, wherein the first interface can include a first parameter, and the parameter value of the first parameter can be multiple groups of heap data.
[0118] Optionally, if it is necessary to dump the heap data of a certain application in the virtual machine, the corresponding heap data can be determined according to the demand, and the group corresponding to the heap data can be determined. Multiple groups of heap data can be input into the first interface.
[0119] Step S504, writing multiple groups of heap data into corresponding initial files respectively in a first period of time to obtain multiple first target files, wherein the application is in a suspended state in the first period of time.
[0120] In the technical solution provided in the above step S504 of the present application, after obtaining multiple groups of heap data to be dumped in the application through the first calling interface, the application can enter the first time period. During the first time period, the application can be controlled to be in a suspended state, at which time different groups of heap data can be written to the initial files of the corresponding groups to obtain different groups of first target files, wherein the application can be in a suspended state during the first time period. Different groups of heap data can correspond to different initial files, and different groups of heap data can also correspond to the same initial file.
[0121] Optionally, in the first stage, multiple groups of heap data to be dumped can be written into segmented files corresponding to different groups through the application thread in the application, that is, the heap data can be written into the initial files corresponding to the respective groups. After the multiple groups of heap data to be dumped are written, the first target file corresponding to each group can be obtained, that is, the segmented file in which the heap data is written can be obtained.
[0122] Step S506: In a second time period after the first time period, the plurality of first target files are merged to obtain a second target file, wherein the application is in a continuous running state in the second time period.
[0123] In the technical solution provided in the above step S506 of the present application, in the first period, the multiple groups of heap data to be dumped are respectively written into the initial files corresponding to each group, and after obtaining the first target file, the second period can be entered. In the second period, the application can be controlled to resume operation so that the application is in a continuous operation state. In the second period, the first target files into which the heap data has been written can be merged to obtain the merged second target file, wherein the application can be in a continuous operation state in the second period.
[0124] Optionally, after writing the heap data into the corresponding first target file through the first stage, the second stage can be entered. In the second stage, the first target files corresponding to the groups to be dumped can be merged into a complete second target file, and the second target file can be stored locally as a local file, so that it can be directly analyzed through the local file later.
[0125] Optionally, in the second stage, multiple segment files can be merged into a complete heap dump file, and throughout the second stage, the application can continue to execute without STW.
[0126] Step S508: outputting the second target file by calling the second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter is the second target file.
[0127] In the technical solution provided in the above step S508 of the present application, the second target file can be output by calling the second interface, wherein the second interface can include a second parameter, and the parameter value of the second parameter can be the second target file.
[0128] Optionally, after obtaining the second target file, the second interface may be called to output the second target file, for example, the second target file may be output to a local computer and retained in the form of a local file.
[0129] Through the above steps S502 to S508 of the present application, multiple groups of heap data to be dumped in the application are obtained by calling the first interface, wherein the first interface includes a first parameter, and the parameter value of the first parameter is the multiple groups of heap data; within a first time period, the multiple groups of heap data are respectively written into corresponding initial files to obtain multiple first target files, wherein the application is in a suspended state during the first time period; within a second time period after the first time period, the multiple first target files are merged to obtain a second target file, wherein the application is in a continued state during the second time period; the second target file is output by calling the second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter is the second target file, thereby achieving the technical effect of being able to effectively dump the heap data of the application, and solving the technical problem that the heap data of the application cannot be effectively dumped.
[0130] Example 2
[0131] According to an embodiment of the present application, an embodiment of a system for dumping heap data of an application is also provided. It should be noted that the system for dumping heap data of an application of this embodiment can be used to execute the method for dumping heap data of an application of this embodiment. Figure 6 is a schematic diagram of a heap data dump system of an application according to an embodiment of the present application, such as Figure 6 As shown, the heap data dumping system of the application may include: a heap data dumping device 601 and a server 602 .
[0132] A heap data dumping device 601 is used to detect multiple groups of heap data to be dumped in an application of a virtual machine; in a first time period, the multiple groups of heap data are written into corresponding initial files respectively to obtain multiple first target files, wherein the application is in a suspended running state in the first time period; in a second time period after the first time period, the multiple first target files are merged to obtain a second target file, wherein the application is in a continued running state in the second time period.
[0133] Optionally, the heap data dumping device 601 can detect the heap data that needs to be dumped in the application and divide it into multiple groups. In the first period when the application is in a suspended running state, the heap data of different groups can be written into the corresponding initial files respectively to obtain the first target file corresponding to each group. After all the heap data to be dumped are written into the initial file, the application can be controlled to continue running, and in the second period when the application is in a continued running state, the first target file of each group is merged to obtain the final complete second target file that needs to be dumped, thereby completing the process of dumping the heap data to be dumped in the application.
[0134] Optionally, when it is detected that some groups of heap data among the multiple groups of heap data in the application need to be dumped, an initial file corresponding to the group of heap data to be dumped may be determined.
[0135] Optionally, the dumping process of the heap data can be analyzed by the heap data dumping device 601 to determine whether the whole dumping process requires the application program to suspend operation to execute, and the analysis shows that only a part of the process requires the application program to suspend operation in the whole process, and the application program can continue to run at other times. Through the above analysis, the whole dumping process can be divided into two stages, the first stage is the stage in which the application program suspends execution, in which the multithreading in the application program can be controlled to write the heap data to be dumped into the file of the corresponding segmentation. In the second stage, the application program does not need to suspend execution. In the second stage, the first target file corresponding to the group to be dumped can be merged into a complete second target file, and the second target file can be stored locally as a local file, so that it can be directly analyzed by the local file afterwards.
[0136] Optionally, after the heap data dumping device 601 obtains the final second target file through concatenation and merging, the second target file may be transmitted to the server 602 .
[0137] The server 602 is used to receive the second target file and output the second target file to a data analysis platform associated with the virtual machine for analysis.
[0138] Optionally, the server 602 may be used to receive the second target file sent by the heap data dumping device 601 , and may output the second target file to a data analysis platform associated with the virtual machine for analysis.
[0139] Optionally, the second target file obtained by the splicing and merging, that is, the heap dump file, can be saved in a local file. If the heap dump file of the application needs to be analyzed, the second target file can be transmitted to a data analysis platform associated with the virtual machine through server 602, and the heap dump file of the corresponding application in the local file can be analyzed through the data analysis platform.
[0140] In this embodiment, a heap data dump system for an application is provided. A heap data dump device detects multiple groups of heap data to be dumped in an application of a virtual machine; in a first time period, the multiple groups of heap data are respectively written into corresponding initial files to obtain multiple first target files, wherein the application is in a suspended running state in the first time period; in a second time period after the first time period, the multiple first target files are merged to obtain a second target file, wherein the application is in a continued running state in the second time period; the second target file is received through a server, and the second target file is output to a data analysis platform associated with the virtual machine for analysis, thereby achieving a technical effect that the heap data of the application can be effectively dumped, and solving the technical problem that the heap data of the application cannot be effectively dumped.
[0141] 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, for example, the data for verification, 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 the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0142] Example 3
[0143] Currently, in the process of performing a heap dump of an application, it is a well-known pain point that the application must be suspended, the heap dump operation must be performed through the VM, and the application operation must be controlled after the heap dump operation is completed.
[0144] In a related technique, Figure 7 is a schematic diagram of dumping heap data in an application program in a related technology according to an embodiment of the present application, such as Figure 7 As shown, if it is necessary to dump the heap data in the application, the heap data in the application is dumped by using the parallel heap iteration feature of the global directory GC. During the entire heap data dump process, the application is in the application suspension execution stage. In this process, the heap data can be written into the program buffer queue through the dump writing program or the virtual machine thread (VM Thread) through parallel heap iteration. It can be compressed by the compression backend to obtain a work list (Work List). The final heap dump file (dump.hprof) is obtained by the writer thread (Writer Thread) and the file writer (File Writer). However, since all the heap data will be competitively written into the same file, it is inevitable that strong lock competition (lock grabbing / lock) will be designed, and additional physical memory, that is, extra memory (extra memory) overhead, is required to maintain the relevant concurrent structure, and additional interaction overhead (interact overhead) is required, so that the performance of the heap data dump cannot be improved. Therefore, there is still a technical problem that the heap data of the application cannot be effectively dumped.
[0145] In another related technology, by establishing a new process (vfork) and performing the dump in the new process, just like the remote dictionary service (redis) data persistence, the application can be paused without or in sub-seconds. However, the technical risk of this solution is relatively large, it is not easy to be widely accepted, and there are some obvious technical defects. Therefore, there is still a technical problem that the heap data of the application cannot be effectively dumped.
[0146] In one embodiment, a solution for Java two-stage heap dump with micro-pause is proposed. The method can detect the heap data that needs to be dumped in the application and divide it into multiple groups. In the STW stage when the application is in a suspended running state, the heap data of different groups can be written into corresponding segmented files respectively to obtain the segmented files corresponding to each group that have been written. After all the heap data to be dumped are written into the segmented files, the application can be controlled to continue running, and in the Non-STW stage when the application is in a continued running state, the segmented files of each group are merged to obtain the final complete heap dump file that needs to be dumped, completing the process of dumping the heap data to be dumped in the application. Considering that the process of dumping the heap data of the entire application can be divided into two different stages, in the STW stage, the application has to suspend running while the heap data is written into the segmented file, and in the Non-STW stage, the application does not need to suspend running while the segmented files are merged to obtain the completed heap dump file. Therefore, by analyzing whether the application needs to be suspended to divide the time period, it is possible to avoid the situation where the application needs to be suspended during the entire heap dump process. Instead, the application does not need to be suspended at a certain stage to achieve the purpose of shortening the suspension time of the application, thereby achieving the technical effect of effectively dumping the heap data of the application and solving the technical problem of not being able to effectively dump the heap data of the application.
[0147] Furthermore, the present application provides a solution for a micro-pause Java two-stage heap dump, which solves the technical problem of being unable to effectively dump the heap data of an application. This method is different from the traditional solution in which the process of dumping the entire heap data cannot be divided into stages, and solves the technical problem of being unable to effectively dump the heap data of an application.
[0148] In an embodiment of the present application, the heap data that needs to be dumped in the application can be detected and divided into multiple groups. In the STW stage when the application is in a suspended running state, the heap data of different groups can be written into corresponding segmented files respectively to obtain the segmented files corresponding to each group that have been written. After all the heap data to be dumped are written into the segmented files, the application can be controlled to continue running, and in the Non-STW stage when the application is in a continued running state, the segmented files of each group are merged to obtain the final complete heap dump file that needs to be dumped, completing the process of dumping the heap data to be dumped in the application. Considering that the process of dumping the heap data of the entire application can be divided into two different stages, in the STW stage, the application has to suspend running while the heap data is written into the segmented file, and in the Non-STW stage, the application does not need to suspend running while the segmented files are merged to obtain the completed heap dump file. Therefore, by analyzing whether the application needs to be suspended to divide the time period, it is possible to avoid the situation where the application needs to be suspended during the entire heap dump process. Instead, the application does not need to be suspended at a certain stage to achieve the purpose of shortening the suspension time of the application, thereby achieving the technical effect of effectively dumping the heap data of the application and solving the technical problem of not being able to effectively dump the heap data of the application.
[0149] The above method of this embodiment is further introduced below.
[0150] In this embodiment, if it is necessary to dump the heap data in the application, the numerous heap data to be dumped in the application can be grouped in advance to obtain multiple groups of heap data. Therefore, when it is detected that there is a need to dump certain groups of heap data, it is possible to detect which multiple groups of heap data are to be dumped, so as to facilitate processing of the multiple groups of heap data to be dumped and complete the dump operation.
[0151] Optionally, when it is detected that some groups of heap data among the multiple groups of heap data in the application need to be dumped, segmented files corresponding to the groups of heap data to be dumped may be determined.
[0152] In this embodiment, in the STW stage, multiple groups of heap data to be dumped can be written into segmented files corresponding to different groups through threads in the application, that is, the heap data can be written into initial files corresponding to respective groups. After the multiple groups of heap data to be dumped are written, the first target file of each group can be obtained, that is, the segmented files into which the heap data has been written.
[0153] Optionally, in the STW stage, multiple groups of dumped heap data can be sent to the segmented files of the corresponding groups through the multi-threads in the application. For example, a corresponding application thread can be matched for each group of heap data to be dumped. After the matching is completed, the application threads corresponding to each group can be controlled in parallel to send the heap data of the corresponding group to the initial file. The sent heap data can be Dump Writer to the corresponding segmented file to obtain the segmented file with the heap data written. In the STW stage, due to the pause of the application, and the process of the pause, the threads in the entire application will be suspended without any response.
[0154] In this embodiment, after the heap data is written into the corresponding segmented files through the first stage, the second stage can be entered. In the second stage, the segmented files corresponding to the groups to be dumped can be merged into a complete heap dump file, and the heap dump file can be stored locally as a local file, so that it can be directly analyzed through the local file later.
[0155] Optionally, in the Non-STW stage, the first target file of the heap data that has been written to the corresponding group can be spliced through the multithreading in the application, and the first target files corresponding to the group to be dumped can be merged into a complete second target file. For example, the file can be sent to the request receiving thread, and the first target file corresponding to the group to be dumped can be spliced through the Attach Listener to obtain the final complete heap dump file, that is, the dump.hprof file. And in the Non-STW stage, since the application does not need to pause during this process, the dumping process of the heap data in the application is divided into two stages to ensure that the application can be executed normally during this stage.
[0156] For example, Figure 8 is a schematic diagram of a Java two-stage heap dump with a micro-pause according to an embodiment of the present application, such as Figure 8As shown, taking three groups of heap data as an example, the dumping process of heap data in a Java application can be divided into two stages, the application recovery execution stage and the application suspension execution stage. In the first stage, that is, the application suspension execution stage, the heap data can be written to files in parallel. In this stage, the application threads in the application program can be used to write multiple groups of heap data into the corresponding group's segmented files using a dump writing program. For example, the first group can be written into the first segmented file, named dump.p1; the second group can be written into the second segmented file, named dump.p2; the third group can be written into the third segmented file, named dump.p3. After writing the corresponding segmented files respectively and obtaining the segmented files, the second stage can be entered, that is, the application recovery execution stage. In this stage, a file / splice can be sent, and a receiving thread can be requested to merge the three segmented files into a complete heap dump file.
[0157] In an embodiment of the present application, the heap data that needs to be dumped in the application can be detected and divided into multiple groups. In the STW stage when the application is in a suspended running state, the heap data of different groups can be written into corresponding segmented files respectively to obtain the segmented files corresponding to each group that have been written. After all the heap data to be dumped are written into the segmented files, the application can be controlled to continue running, and in the Non-STW stage when the application is in a continued running state, the segmented files of each group are merged to obtain the final complete heap dump file that needs to be dumped, completing the process of dumping the heap data to be dumped in the application. Considering that the process of dumping the heap data of the entire application can be divided into two different stages, in the STW stage, the application has to suspend running while the heap data is written into the segmented file, and in the Non-STW stage, the application does not need to suspend running while the segmented files are merged to obtain the completed heap dump file. Therefore, by analyzing whether the application needs to be suspended to divide the time period, it is possible to avoid the situation where the application needs to be suspended during the entire heap dump process. Instead, the application does not need to be suspended at a certain stage to achieve the purpose of shortening the suspension time of the application, thereby achieving the technical effect of effectively dumping the heap data of the application and solving the technical problem of not being able to effectively dump the heap data of the application.
[0158] Example 4
[0159] According to an embodiment of the present application, there is also provided a method for implementing the above Figure 3 The method for dumping heap data of an application program is shown in an apparatus for dumping heap data of an application program.
[0160] Fig. 9 is a schematic diagram of a heap data dumping device of an application according to an embodiment of the present application, such as Fig. 9 As shown, the heap data dump 900 of the application may include: a first detection unit 902 , a first writing unit 904 , and a first merging unit 906 .
[0161] A first detection unit 902, used to detect multiple groups of heap data to be dumped in an application program;
[0162] A first writing unit 904 is used to write multiple groups of heap data into corresponding initial files in a first time period to obtain multiple first target files, wherein the application is in a suspended state in the first time period;
[0163] The first merging unit 906 is used to merge the multiple first target files in a second time period after the first time period to obtain a second target file, wherein the application is in a continuous running state in the second time period.
[0164] Here, the first detection unit 902, the first writing unit 904 and the first merging unit 906 correspond to steps S302 to S306 in Embodiment 1, and the three units and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in Embodiment 1. It should be noted that the above units may be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b..., 102n), and the above units may also be part of a device and run in the computer terminal 10 provided in Embodiment 1.
[0165] According to an embodiment of the present application, there is also provided a method for implementing the above Figure 4 The method for dumping heap data of an application program is shown in an apparatus for dumping heap data of an application program.
[0166] Fig.10 is a schematic diagram of another heap data dumping device of an application according to an embodiment of the present application, such as Fig.10 As shown, the heap data dump 1000 of the application may include: a first determining unit 1002 , a second detecting unit 1004 , a second writing unit 1006 , a second merging unit 1008 and an analyzing unit 1010 .
[0167] The first determining unit 1002 is configured to determine an application program to be processed in the virtual machine.
[0168] The second detection unit 1004 is used to detect multiple groups of heap data to be dumped in the application.
[0169] The second writing unit 1006 is used to write multiple groups of heap data into corresponding initial files respectively in a first time period to obtain multiple first target files, wherein the application is in a suspended running state in the first time period.
[0170] The second merging unit 1008 is used to merge the multiple first target files in a second time period after the first time period to obtain a second target file in the local of the virtual machine, wherein the application is in a continuous running state in the second time period.
[0171] The analysis unit 1010 is used to output the second target file to a data analysis platform associated with the virtual machine for analysis.
[0172] It should be noted that the first determination unit 1002, the second detection unit 1004, the second writing unit 1006, the second merging unit 1008 and the analysis unit 1010 correspond to steps S402 to S410 in Example 1, and the five units and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned units can be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b..., 102n), and the above-mentioned units can also be run in the computer terminal 10 provided in Example 1 as part of the device.
[0173] According to an embodiment of the present application, there is also provided a method for implementing the above Figure 5 The method for dumping heap data of an application program is shown in an apparatus for dumping heap data of an application program.
[0174] Fig.11 is a schematic diagram of another heap data dumping device of an application according to an embodiment of the present application, such as Fig.11 As shown, the heap data dumping apparatus 1100 of the application may include: a first calling unit 1102 , a third writing unit 1104 , a third merging unit 1106 and a second calling unit 1108 .
[0175] The first calling unit 1102 is used to obtain multiple groups of heap data to be dumped in the application program by calling a first interface, wherein the first interface includes a first parameter, and a parameter value of the first parameter is the multiple groups of heap data.
[0176] The third writing unit 1104 is used to write multiple groups of heap data into corresponding initial files respectively in a first time period to obtain multiple first target files, wherein the application is in a suspended running state in the first time period.
[0177] The third merging unit 1106 is used to merge the multiple first target files in a second time period after the first time period to obtain a second target file, wherein the application is in a continuous running state in the second time period.
[0178] The second calling unit 1108 is configured to output a second target file by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter is the second target file.
[0179] It should be noted that the first calling unit 1102, the third writing unit 1104, the third merging unit 1106 and the second calling unit 1108 correspond to steps S502 to S508 in Embodiment 1, and the four units and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in Embodiment 1. It should be noted that the above units can be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b..., 102n), and the above units can also be run in the computer terminal 10 provided in Embodiment 1 as part of the device.
[0180] In the heap data dumping device of the application, the heap data to be dumped in the application can be detected and divided into multiple groups. In the first period when the application is in a suspended running state, the heap data of different groups can be written into the corresponding initial files respectively to obtain the first target file corresponding to each group. After all the heap data to be dumped are written into the initial file, the application can be controlled to continue running, and in the second period when the application is in a continued running state, the first target file of each group is merged to obtain the final complete second target file to be dumped, thereby completing the process of dumping the heap data to be dumped in the application. Considering that the process of dumping the heap data of the entire application can be divided into two different time periods, in the first time period, the application has to suspend running while the heap data is written to the initial file, and in the second time period, the application does not need to suspend running while the first target file is merged to obtain the completed heap dump file. Therefore, by analyzing whether the application needs to be suspended to divide the time periods, it is possible to avoid the situation where the application needs to be suspended during the entire heap dump process. Instead, the application does not need to be suspended at a certain stage to achieve the purpose of shortening the suspension time of the application, thereby achieving the technical effect of effectively dumping the heap data of the application and solving the technical problem of not being able to effectively dump the heap data of the application.
[0181] Example 5
[0182] The embodiment of the present application may provide a computer terminal, which may be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced by a terminal device such as a mobile terminal.
[0183] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of the computer network.
[0184] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the heap data dumping method of the application: detecting multiple groups of heap data to be dumped in the application; writing the multiple groups of heap data into corresponding initial files respectively in a first time period to obtain multiple first target files, wherein the application is in a suspended running state in the first time period; in a second time period after the first time period, merging the multiple first target files to obtain a second target file, wherein the application is in a continued running state in the second time period.
[0185] Optionally, Fig.12 is a structural block diagram of a computer terminal according to an embodiment of the present application, such as Fig.12 As shown, the computer terminal A may include: one or more (only one is shown in the figure) processors 1202 , a memory 1204 and a transmission device 1206 .
[0186] Wherein, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the heap data dump method and device of the application in the embodiment of the present application, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the heap data dump method of the above-mentioned application. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to terminal A via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0187] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: detect multiple groups of heap data to be dumped in the application; write the multiple groups of heap data into the corresponding initial files respectively in a first time period to obtain multiple first target files, wherein the application is in a suspended state in the first time period; merge the multiple first target files in a second time period after the first time period to obtain a second target file, wherein the application is in a continued state in the second time period.
[0188] Optionally, the processor may also execute the following program code: within a first time period, write multiple groups of stack data into corresponding initial files respectively to obtain multiple first target files, including: within a first time period, write multiple groups of stack data into corresponding initial files in parallel to obtain multiple first target files.
[0189] Optionally, the processor may also execute program code of the following steps: within a first time period, write multiple groups of heap data into corresponding initial files respectively to obtain multiple first target files, including: within the first time period, use the multi-threading of the application to send corresponding heap data to corresponding initial files respectively; in response to completing sending the corresponding heap data to the corresponding initial file, suspend the running of the multi-threading, and write the sent heap data into the corresponding initial file to obtain the corresponding first target file.
[0190] Optionally, the processor may further execute the program code of the following steps: allocating a corresponding initial file to each group of data based on the data volume of each group of data in different groups of data.
[0191] Optionally, the processor may also execute the following program code: based on the data volume of each group of data in different groups of data, allocate a corresponding initial file to each group of data, including: in the third target file, respectively obtain segmented files matching the data volume of different groups of data.
[0192] Optionally, the processor may also execute the following program code: merging multiple first target files in a second time period after the first time period to obtain a second target file, including: splicing multiple first target files in the second time period after the first time period to obtain a second target file.
[0193] Optionally, the processor may further execute the program code of the following steps: in a second time period after the first time period, concatenate multiple first target files according to the arrangement order of the corresponding initial files to obtain a second target file.
[0194] Optionally, the processor may also execute the following program code: in a second time period after the first time period, determine the splicing order of multiple first target files according to the arrangement order of different initial files; and splice the multiple first target files according to the splicing order to obtain a second target file.
[0195] Optionally, the processor may further execute program code of the following steps: the second target file is a heap dump file.
[0196] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: determine the application to be processed in the virtual machine; detect multiple groups of heap data to be dumped in the application; in a first time period, write the multiple groups of heap data into the corresponding initial files respectively to obtain multiple first target files, wherein the application is in a suspended state in the first time period; in a second time period after the first time period, merge the multiple first target files to obtain a second target file in the local of the virtual machine, wherein the application is in a continued state in the second time period; output the second target file to a data analysis platform associated with the virtual machine for analysis.
[0197] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain multiple groups of heap data to be dumped in the application by calling the first interface, wherein the first interface includes a first parameter, and the parameter value of the first parameter is the multiple groups of heap data; within a first time period, write the multiple groups of heap data into the corresponding initial files respectively to obtain multiple first target files, wherein the application is in a suspended running state during the first time period; within a second time period after the first time period, merge the multiple first target files to obtain a second target file, wherein the application is in a continued running state during the second time period; output the second target file by calling the second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter is the second target file.
[0198] By using the embodiment of the present application, a method for dumping heap data of an application is provided. In the embodiment of the present application, the heap data to be dumped in the application can be detected and divided into multiple groups. In a first period when the application is in a suspended running state, the heap data of different groups can be written into corresponding initial files respectively to obtain the first target file corresponding to each group. After all the heap data to be dumped are written into the initial file, the application can be controlled to continue running, and in a second period when the application is in a continued running state, the first target file of each group is merged to obtain the final complete second target file to be dumped, thereby completing the process of dumping the heap data to be dumped in the application. Considering that the process of dumping the heap data of the entire application can be divided into two different time periods, in the first time period, the application has to suspend running while the heap data is written to the initial file, and in the second time period, the application does not need to suspend running while the first target file is merged to obtain the completed heap dump file. Therefore, by analyzing whether the application needs to be suspended to divide the time periods, it is possible to avoid the situation where the application needs to be suspended during the entire heap dump process. Instead, the application does not need to be suspended at a certain stage to achieve the purpose of shortening the suspension time of the application, thereby achieving the technical effect of effectively dumping the heap data of the application and solving the technical problem of not being able to effectively dump the heap data of the application.
[0199] It can be understood by those skilled in the art that Fig.12 The structure shown is for illustration only, and the computer terminal A may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, referred to as MID), a PAD, or other terminal devices. Fig.12 It does not limit the structure of the above-mentioned computer terminal A. For example, the computer terminal A may also include Fig.12 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Fig.12 Different configurations are shown.
[0200] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0201] Example 6
[0202] The embodiment of the present application also provides a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the heap data dumping method of the application provided in the first embodiment.
[0203] Optionally, in this embodiment, the computer-readable storage medium may be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.
[0204] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: detecting multiple groups of heap data to be dumped in an application; writing the multiple groups of heap data into corresponding initial files respectively within a first time period to obtain multiple first target files, wherein the application is in a suspended state within the first time period; merging the multiple first target files within a second time period after the first time period to obtain a second target file, wherein the application is in a continued state within the second time period.
[0205] Optionally, the computer-readable storage medium may also execute program code of the following steps: in a first time period, writing multiple groups of heap data into corresponding initial files in parallel respectively, to obtain multiple first target files.
[0206] Optionally, the computer-readable storage medium may also execute program code of the following steps: within a first time period, respectively utilizing the multi-threads of the application to send corresponding heap data to a corresponding initial file; in response to completion of sending the corresponding heap data to the corresponding initial file, pausing the running of the multi-threads, and writing the sent heap data to the corresponding initial file to obtain a corresponding first target file.
[0207] Optionally, the computer-readable storage medium may also execute program code for the following steps: allocating a corresponding initial file to each group of data based on the data volume of each group of data in different groups of data.
[0208] Optionally, the computer-readable storage medium can also execute the following steps of program code: based on the data volume of each group of data in different groups of data, allocate a corresponding initial file to each group of data, including: in the third target file, respectively obtain segmented files that match the data volume of different groups of data.
[0209] Optionally, the computer-readable storage medium may also execute program code for the following steps: within a second time period after the first time period, concatenate multiple first target files to obtain a second target file.
[0210] Optionally, the computer-readable storage medium may also execute program code for the following steps: in a second time period after the first time period, concatenate multiple first target files according to the arrangement order of the corresponding initial files to obtain a second target file.
[0211] Optionally, the computer-readable storage medium may also execute program code for the following steps: determining a splicing order of multiple first target files according to an arrangement order of different initial files in a second time period after the first time period; and splicing multiple first target files according to the splicing order to obtain a second target file.
[0212] Optionally, the computer-readable storage medium may also execute program code of the following steps: the second target file is a heap dump file.
[0213] As an optional example, a computer-readable storage medium is configured to store program code for performing the following steps: determining an application to be processed in a virtual machine; detecting multiple groups of heap data to be dumped in the application; writing the multiple groups of heap data into corresponding initial files respectively within a first time period to obtain multiple first target files, wherein the application is in a suspended state within the first time period; merging the multiple first target files within a second time period after the first time period to obtain a second target file in the local area of the virtual machine, wherein the application is in a continued state within the second time period; and outputting the second target file to a data analysis platform associated with the virtual machine for analysis.
[0214] As an optional example, a computer-readable storage medium is configured to store program code for performing the following steps: obtaining multiple groups of heap data to be dumped in an application by calling a first interface, wherein the first interface includes a first parameter, and a parameter value of the first parameter is the multiple groups of heap data; within a first time period, writing the multiple groups of heap data into corresponding initial files respectively to obtain multiple first target files, wherein the application is in a suspended state during the first time period; within a second time period after the first time period, merging the multiple first target files to obtain a second target file, wherein the application is in a continued state during the second time period; outputting the second target file by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter is the second target file, thereby achieving a technical effect of effectively dumping the heap data of the application and solving the technical problem of being unable to effectively dump the heap data of the application.
[0215] Example 7
[0216] An embodiment of the present application may provide an electronic device, which may include a memory and a processor.
[0217] Fig.13It is a block diagram of an electronic device according to a method for dumping heap data of an application program in an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0218] like Fig.13 As shown, the device 1300 includes a computing unit 1301, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1302 or a computer program loaded from a storage unit 1308 into a random access memory (RAM) 1303. In the RAM 1303, various programs and data required for the operation of the device 1300 can also be stored. The computing unit 1301, the ROM 1302, and the RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to the bus 1304.
[0219] A number of components in the device 1300 are connected to the I / O interface 1305, including: an input unit 1306, such as a keyboard, a mouse, etc.; an output unit 1304, such as various types of displays, speakers, etc.; a storage unit 1308, such as a disk, an optical disk, etc.; and a communication unit 1309, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1309 allows the device 1300 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0220] The computing unit 1301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSP), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1301 performs the various methods and processes described above, such as a verification method for data. For example, in some embodiments, the verification method for data may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 1308. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1300 via the ROM 1302 and / or the communication unit 1309. When the computer program is loaded into the RAM 1303 and executed by the computing unit 1301, one or more steps of the verification method for data described above may be performed. Alternatively, in other embodiments, the computing unit 1301 may be configured to execute the data verification method in any other appropriate manner (for example, by means of firmware).
[0221] Various embodiments of the systems and techniques described above herein may be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard parts (ASSPs), system-on-a-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor that may be a dedicated or general purpose programmable processor that may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0222] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0223] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory for short), an optical fiber, a portable compact disk read-only memory (CD-ROM for short), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0224] To provide interaction with a user, the systems and techniques described herein may be implemented on a computer having: a display device (e.g., a cathode ray tube (CRT) or a liquid crystal display (LCD), a monitor for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a path ball), through which the user may provide input to the computer. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0225] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a Local Area Network (LAN), a Wide Area Network (WAN), and the Internet.
[0226] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0227] It should be noted that the serial numbers of the above-mentioned embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.
[0228] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0229] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0230] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0231] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0232] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, read-only memories, random access memories, mobile hard disks, magnetic disks or optical disks.
[0233] The above are only preferred implementations of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for dumping heap data of an application, characterized in that: include: Detect multiple sets of heap data to be dumped in the application; In a first time period, the plurality of groups of heap data are respectively written into corresponding initial files to obtain a plurality of first target files, wherein the application is in a suspended state in the first time period; In a second time period after the first time period, the plurality of first target files are merged to obtain a second target file, wherein the application is in a continuous running state in the second time period.
2. The method according to claim 1, characterized in that In a first period, the plurality of groups of heap data are respectively written into the corresponding initial files to obtain a plurality of first target files, including: In the first time period, the multiple groups of heap data are respectively written in parallel into the corresponding initial files to obtain the multiple first target files.
3. The method according to claim 1, characterized in that In a first period, the plurality of groups of heap data are respectively written into the corresponding initial files to obtain a plurality of first target files, including: In the first time period, respectively using the multithreading of the application to send the corresponding heap data to the corresponding initial file; In response to completing sending the corresponding heap data to the corresponding initial file, suspending the running of the multithreading, and writing the sent heap data into the corresponding initial file to obtain the corresponding first target file.
4. The method according to claim 1, characterized in that: The method further comprises: Based on the data amount of each group of heap data in different groups of the heap data, the corresponding initial file is allocated to each group of the heap data.
5. The method according to claim 4, characterized in that Based on the data amount of each group of the heap data in different groups, allocating the corresponding initial file to each group of the heap data includes: In the third target file, segment files matching the data amounts of different groups of the heap data are respectively obtained, wherein the initial file includes the segment files.
6. The method according to claim 1, characterized in that In a second time period after the first time period, merging the plurality of first target files to obtain a second target file includes: In a second time period after the first time period, the plurality of first target files are concatenated to obtain the second target file.
7. The method according to claim 6, characterized in that In a second time period after the first time period, The plurality of first target files are concatenated to obtain the second target file, including: In a second time period after the first time period, the plurality of first target files are concatenated using the multithreading of the application program to obtain the second target file.
8. The method according to claim 6, characterized in that In a second time period after the first time period, The plurality of first target files are concatenated to obtain the second target file, including: In a second time period after the first time period, the plurality of first target files are concatenated according to the arrangement order of the corresponding initial files to obtain the second target file.
9. The method according to any one of claims 1 to 8, characterized in that The second target file is a heap dump file.
10. A method for processing heap data of an application, characterized in that: include: Determine the application to be processed in the virtual machine; Detecting multiple sets of heap data to be dumped in the application; In a first time period, the plurality of groups of heap data are respectively written into corresponding initial files to obtain a plurality of first target files, wherein the application is in a suspended state in the first time period; In a second time period after the first time period, merging the plurality of first target files to obtain a second target file in the local of the virtual machine, wherein the application is in a continuous running state in the second time period; The second target file is output to a data analysis platform associated with the virtual machine for analysis.
11. A method for dumping heap data of an application, characterized in that: include: Acquire multiple groups of heap data to be dumped in an application program by calling a first interface, wherein the first interface includes a first parameter, and a parameter value of the first parameter is the multiple groups of heap data; In a first time period, the plurality of groups of heap data are respectively written into corresponding initial files to obtain a plurality of first target files, wherein the application is in a suspended state in the first time period; In a second time period after the first time period, merging the plurality of first target files to obtain a second target file, wherein the application is in a continuous running state in the second time period; The second target file is output by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter is the second target file.
12. A heap data dump system for an application, characterized in that: include: A heap data dumping device, used for detecting multiple groups of heap data to be dumped in an application program of a virtual machine; In a first time period, the plurality of groups of heap data are respectively written into corresponding initial files to obtain a plurality of first target files, wherein the application is in a suspended running state in the first time period; in a second time period after the first time period, the plurality of first target files are merged to obtain a second target file, wherein the application is in a continued running state in the second time period; The server is used to receive the second target file and output the second target file to a data analysis platform associated with the virtual machine for analysis.
13. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 11 when running.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 11.