Virtual machine memory processing method, processing device, equipment, medium and program product

By obtaining process parameters and global recycling time thresholds in the virtual machine memory, global garbage collection and analysis are performed, which solves the problems of long memory leak detection and low accuracy in the existing technology, and achieves fast and accurate memory leak identification.

CN118567790APending Publication Date: 2024-08-30CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410913314.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing memory leak detection methods are time-consuming and may have omissions, which reduces the identification accuracy.

Method used

Obtain process parameters in the virtual machine memory, determine the global recycling time threshold based on the time allocation list, perform global garbage collection operations and generate garbage collection logs, analyze multiple logs to determine memory leaks, and determine the target causing the leak through the process memory image file program.

Benefits of technology

It improves the efficiency and accuracy of identifying memory leaks, reduces the detection time cost, and can accurately determine whether there is a memory leak within a preset time period.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567790A
    Figure CN118567790A
Patent Text Reader

Abstract

The invention provides a virtual machine memory processing method and device, equipment, a medium and a program product, and can be applied to the technical field of finance and data processing. The method comprises the steps of obtaining process parameters of a to-be-tested program under the condition that the to-be-tested program runs in a virtual machine memory; determining a global recovery duration threshold value corresponding to the process parameter from a time allocation list based on the process parameter; under the condition that the running time of the to-be-tested program reaches a global recovery duration threshold each time, executing a global garbage recovery operation on a virtual machine memory to generate a garbage recovery log; the multiple garbage collection logs in the preset time period are analyzed and processed, an analysis result is obtained, and the analysis result represents whether memory leakage exists in the memory of the virtual machine or not.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, and in particular to a method, a processing device, a equipment, a medium and a program product for processing a virtual machine memory. Background Art

[0002] A memory leak is a situation where dynamically allocated memory space is not properly released or reclaimed when a program is running in the virtual machine's memory. When a memory leak occurs in a program, the memory space allocated to the program will gradually be exhausted, causing system performance degradation, program crashes, or unexpected terminations. Therefore, memory leaks are very serious system problems, and timely detection and repair of memory leaks is critical to maintaining program stability, performance, and security.

[0003] In the process of implementing the concept of the present disclosure, it is found that the existing memory leak detection method takes a long time and may have omissions, thereby reducing the recognition accuracy. Summary of the invention

[0004] In view of the above problems, the present disclosure provides a method, a processing device, a equipment, a medium and a program product for processing a virtual machine memory.

[0005] According to a first aspect of the present disclosure, a method for processing a virtual machine memory is provided, comprising:

[0006] When the program to be tested is running in the memory of the virtual machine, obtaining process parameters of the program to be tested;

[0007] Based on the process parameters, determine a global recycling duration threshold corresponding to the process parameters from a time allocation list;

[0008] When the running time of the program under test reaches the global garbage collection time threshold each time, a global garbage collection operation is performed on the virtual machine memory to generate a garbage collection log;

[0009] The plurality of garbage collection logs within a preset time period are analyzed and processed to obtain an analysis result, wherein the analysis result indicates whether there is a memory leak in the memory of the virtual machine.

[0010] According to an embodiment of the present disclosure, the above method further includes:

[0011] When the above analysis result indicates that the above memory leak exists, obtaining the process memory image file generated after each global garbage collection operation;

[0012] The target program causing the memory leak in the program to be tested is determined according to the plurality of process memory image files.

[0013] According to an embodiment of the present disclosure, the above-mentioned program to be tested includes a plurality of test subroutines;

[0014] Wherein, determining the target program causing the memory leak in the program to be tested according to the plurality of the process memory image files comprises:

[0015] For each of the above process memory image files, extract a memory occupancy list from the above process memory image file, wherein the above memory occupancy list includes at least one test subroutine that occupies more than a preset proportion of the virtual machine memory;

[0016] For each of the test subprograms, if a preset number of memory occupancy lists include the test subprogram, the test subprogram is determined as the target program.

[0017] According to an embodiment of the present disclosure, the above-mentioned program to be tested includes a plurality of test subroutines;

[0018] Wherein, determining the target program causing the memory leak in the program to be tested according to the plurality of the process memory image files comprises:

[0019] For each of the above-mentioned process memory image files, extract a memory occupancy list from the above-mentioned process memory image file, wherein the above-mentioned memory occupancy list includes at least one test subroutine that occupies more than a preset proportion of the virtual machine memory;

[0020] The test subroutine corresponding to the maximum value of memory occupancy is determined as the above-mentioned target program.

[0021] According to an embodiment of the present disclosure, the above method further includes:

[0022] Sending the target program to a client so that the client can modify the target program to obtain a new program to be tested;

[0023] The global garbage collection operation is iteratively performed on the new program to be tested using the virtual machine memory until an analysis result indicating that the memory leak does not exist in the virtual machine memory is obtained.

[0024] According to an embodiment of the present disclosure, the virtual machine memory includes a heap memory of the virtual machine, and the heap memory includes a first memory management area;

[0025] The multiple garbage collection logs within a preset time period are analyzed and processed to obtain analysis results, including:

[0026] For each of the garbage collection logs, determine the capacity value of the first memory management area according to the garbage collection log, wherein different capacity values ​​are arranged in chronological order;

[0027] When the plurality of capacity values ​​that are continuous in time sequence gradually increase, the analysis result is determined as the presence of the memory leak.

[0028] According to an embodiment of the present disclosure, the above-mentioned time allocation list includes multiple initial recovery duration thresholds, wherein one of the above-mentioned initial recovery duration thresholds corresponds to a type of initial process parameters, and the above-mentioned global recovery duration threshold is the above-mentioned initial recovery duration threshold corresponding to the above-mentioned process parameters.

[0029] A second aspect of the present disclosure provides a virtual machine memory processing device, including:

[0030] An acquisition module, used for acquiring process parameters of the program under test when the program under test is running in the memory of the virtual machine;

[0031] A determination module, configured to determine a global recycling time threshold corresponding to the process parameter from a time allocation list based on the process parameter;

[0032] A recycling module, used to perform a global garbage collection operation on the virtual machine memory to generate a garbage collection log each time the running time of the program under test reaches the global recycling time threshold;

[0033] The analysis module is used to analyze and process the multiple garbage collection logs within a preset time period to obtain an analysis result, wherein the analysis result indicates whether there is a memory leak in the virtual machine memory.

[0034] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.

[0035] The fourth aspect of the present disclosure further provides a computer-readable storage medium having a computer program or instructions stored thereon, which implements the steps of the above method when the above computer program or instructions are executed by a processor.

[0036] The fifth aspect of the present disclosure further provides a computer program product, including a computer program or instructions, which implement the steps of the above method when the above computer program or instructions are executed by a processor.

[0037] According to an embodiment of the present disclosure, by determining the global recycling time threshold corresponding to the program to be tested of different types of process parameters in the time allocation table, multiple global recycling operations are performed within a preset time period, thereby analyzing multiple garbage collection logs to determine whether there is a memory leak. Since different global recycling time thresholds are allocated to each type of process parameter in the time allocation list, it is possible to accurately determine whether there is a memory leak within the preset time period, thereby improving the recognition efficiency and accuracy of memory leaks and reducing the time cost required for testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0039] Figure 1 The diagram schematically shows the division of JVM heap memory;

[0040] Figure 2 The following schematically shows an application scenario diagram of a method for processing a virtual machine memory according to an embodiment of the present disclosure;

[0041] Figure 3 A flowchart schematically shows a method for processing virtual machine memory according to an embodiment of the present disclosure;

[0042] Figure 4 A schematic diagram showing the occupation of a process memory image file according to an embodiment of the present disclosure is shown;

[0043] Figure 5 A schematic diagram schematically shows heap usage after global garbage collection according to an embodiment of the present disclosure;

[0044] Figure 6 A schematic diagram schematically shows a heap usage after global garbage collection according to another embodiment of the present disclosure;

[0045] Figure 7 A structural block diagram schematically shows a device for processing a virtual machine memory according to an embodiment of the present disclosure; and

[0046] Figure 8 A block diagram of an electronic device suitable for implementing the above method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0047] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0048] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0049] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0050] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0051] Figure 1 The diagram schematically shows the division of JVM heap memory.

[0052] The JVM heap (i.e., virtual machine memory) is divided into the new generation, the old generation, and the persistent generation, such as Figure 1 As shown, the new generation is generally divided into three areas, Eden+From Survicor+To Survicor, and the memory ratio of Eden and Survicor is 8:1. Only one Eden and one Survicor area are used each time, and the other Survicor is used to reclaim memory by the copy collection algorithm.

[0053] Objects are generally allocated to the new generation as much as possible. Large objects (long strings and large data groups) are directly allocated to the old generation. At the same time, objects with a long "age" are automatically promoted from the new generation to the old generation. PermanetGenerationg stores some class information, etc.

[0054] In general, newly created objects are allocated to the Eden area (some large objects are directly allocated in the old generation). After the first Minor GC (new generation garbage collection operation), if these objects are still alive, they will be moved to the Survicor area. Every time an object survives a Minor GC (Minor Garbage Collection) in the Survicor area, its age will increase by 1 year. When its age increases to a certain extent (15 years by default), it will be moved to the old generation.

[0055] Because more than 80% of the objects in the new generation are born and die overnight, the garbage collection algorithm for the young generation uses a copy algorithm (the memory is divided into two blocks, only one of which is used at a time. When one block of memory is used up, the living objects are copied to the other block of memory. The copy algorithm does not generate memory fragmentation), as follows:

[0056] At the beginning, objects only exist in the Eden area and the Survstor area named "From", and the Survstor area named "To" is empty. Then GC is performed, and all surviving objects in the Eden area will be copied to "To", and in the "From" area, the surviving objects will be determined according to their age value. Objects that reach a certain age (the age value can be set by -XX:MaxTenuringThreshold) will be moved to the old generation, and objects that do not reach the threshold will be copied to the "To" area. After this GC, the Edcn area and the From area have been cleared. At this time, "From" and "To" will exchange their roles, that is, the new "To" is the "From" before the last GC, and the new "From" is the "To" before the last GC. In any case, it will ensure that the Survivor area named To is empty. Minor GC will repeat this process until the "To" area is filled. After the "To" area is filled, all objects will be moved to the old generation. If the old generation space is insufficient (or the conditions for triggering old generation garbage collection are met), a global garbage collection operation (Full Garbage Collection, Full GC) is triggered.

[0057] However, in the related art, the triggering interval of the global garbage collection operation is generally long, especially for some systems where programs rarely use the JVM heap, it takes a long time to observe the trend of memory leaks, and this method is costly, time-consuming, and slow to locate the problem. Alternatively, the size of the JVM heap configuration is repeatedly adjusted so that the global garbage collection operation can be automatically triggered in a short time. This method requires a large amount of work to adjust the heap configuration, which is time-consuming and laborious.

[0058] In view of this, the present disclosure provides a method, a processing device, a equipment, a medium and a program product for processing virtual machine memory, the method comprising: obtaining process parameters of a program to be tested when the program to be tested is running in the virtual machine memory; determining a global recycling duration threshold corresponding to the process parameters from a time allocation list based on the process parameters; performing a global garbage collection operation on the virtual machine memory to generate a garbage collection log each time the running time of the program to be tested reaches the global recycling duration threshold; and analyzing and processing multiple garbage collection logs within a preset time period to obtain analysis results, wherein the analysis results characterize whether there is a memory leak in the virtual machine memory.

[0059] It should be noted that the virtual machine memory processing method and processing device provided by the present disclosure can be used in the financial field, such as banks, and can also be used in any field other than the financial field, such as the Internet and other enterprises. Therefore, the application field of the virtual machine memory processing method and processing device provided by the present disclosure is not limited.

[0060] At the same time, in the embodiments of the present disclosure, some existing solutions in the industry, such as certain software, components, models, etc., may be mentioned. They should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present disclosure, but it does not mean that the applicant has or will necessarily use the solution.

[0061] In addition, in the technical solution of the present disclosure, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0062] Figure 2 The application scenario diagram of the method for processing virtual machine memory according to an embodiment of the present disclosure is schematically shown.

[0063] like Figure 2 As shown, the application scenario 200 according to this embodiment may include a software testing scenario. The network 204 is used to provide a medium for a communication link between the first terminal device 201, the second terminal device 202, the third terminal device 203 and the server 205. The network 204 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0064] The user may use the first terminal device 201, the second terminal device 202, and the third terminal device 203 to interact with the server 205 through the network 204 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 201, the second terminal device 202, and the third terminal device 203, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0065] The first terminal device 201, the second terminal device 202, and the third terminal device 203 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0066] The server 205 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 201, the second terminal device 202, and the third terminal device 203. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0067] It should be noted that the method for processing virtual machine memory provided in the embodiment of the present disclosure can generally be executed by the server 205. Accordingly, the processing device for virtual machine memory provided in the embodiment of the present disclosure can generally be set in the server 205. The method for processing virtual machine memory provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 205 and can communicate with the first terminal device 201, the second terminal device 202, the third terminal device 203 and / or the server 205. Accordingly, the processing device for virtual machine memory provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 205 and can communicate with the first terminal device 201, the second terminal device 202, the third terminal device 203 and / or the server 205.

[0068] It should be understood that Figure 2 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0069] Figure 3 The flowchart of the method for processing the virtual machine memory according to the embodiment of the present disclosure is schematically shown.

[0070] like Figure 3 As shown, the method for processing the virtual machine memory of this embodiment includes operations S310 to S340, and the transaction processing method can be executed by an electronic device.

[0071] In operation S310, when the program to be tested is running in the memory of the virtual machine, the process parameters of the program to be tested are obtained;

[0072] In operation S320, a global recycling duration threshold corresponding to the process parameter is determined from the time allocation list based on the process parameter;

[0073] In operation S330, when the running time of the program to be tested reaches the global garbage collection time threshold each time, a global garbage collection operation is performed on the virtual machine memory to generate a garbage collection log;

[0074] In operation S340, multiple garbage collection logs within a preset time period are analyzed and processed to obtain an analysis result, wherein the analysis result indicates whether there is a memory leak in the virtual machine memory.

[0075] According to an embodiment of the present disclosure, the virtual machine may be a Java virtual machine, and the time allocation list includes multiple initial recycling time thresholds, wherein an initial recycling time threshold corresponds to a type of initial process parameter. The global recycling time threshold is an initial recycling time threshold corresponding to the process parameter, such as 3600s or 7200s.

[0076] According to the embodiments of the present disclosure, the global garbage collection operation (Full Garbage Collection, Full GC) refers to the clearing and recycling of objects in the memory heap that have died or have not been used for a long time, so as to release the space occupied by garbage and prevent memory leaks. Memory leak refers to the heap memory that has been dynamically allocated in the program, which is not released or cannot be released by the program for some reason, resulting in waste of system memory, slowing down the program running speed or even system crashes and other serious consequences.

[0077] According to an embodiment of the present disclosure, when testing a program to be tested, the program to be tested is loaded into the virtual machine memory. At this time, the program to be tested is tested using the virtual machine memory, and the process parameters of the program to be tested, that is, the process number, are obtained. Thereafter, the global recovery duration threshold corresponding to the process parameter is read from the time allocation list.

[0078] According to an embodiment of the present disclosure, during the testing of the program to be tested, the test time is monitored. After each test time reaches the global recycling time threshold, a global garbage collection operation is performed on the virtual machine memory. For example, a global garbage collection operation is performed every 3600 seconds, and each time a global garbage collection operation is performed, a corresponding garbage collection log is generated. By analyzing multiple garbage collection logs within a preset time period (for example, 12 hours), it is determined whether there is a memory leak in the current virtual machine memory.

[0079] According to an embodiment of the present disclosure, by determining the global recycling time threshold corresponding to the program to be tested of different types of process parameters in the time allocation table, multiple global recycling operations are performed within a preset time period, thereby analyzing multiple garbage collection logs to determine whether there is a memory leak. Since different global recycling time thresholds are allocated to each type of process parameter in the time allocation list, it is possible to accurately determine whether there is a memory leak within the preset time period, thereby improving the recognition efficiency and accuracy of memory leaks and reducing the time cost required for testing.

[0080] Figure 4 The diagram schematically shows the occupation of the process memory image file according to an embodiment of the present disclosure.

[0081] According to an embodiment of the present disclosure, the method further includes:

[0082] When the analysis result indicates that there is a memory leak, obtain the process memory image file generated after each global garbage collection operation;

[0083] A target program causing a memory leak in a program under test is determined according to multiple process memory image files.

[0084] According to an embodiment of the present disclosure, after determining that there is a memory leak, the following information is generated after each global garbage collection operation: Figure 4 The process memory image file dump shown in the figure can determine the target program that causes memory leak in the program under test by analyzing multiple process memory image file dumps. The process memory image file dump contains the contents of the virtual machine memory. If there is a memory leak, it means that the global garbage collection operation cannot completely recycle the contents of the virtual machine memory. At this time, the contents that cannot be recycled are reflected in the process memory image file dump.

[0085] According to the embodiments of the present disclosure, by analyzing the process memory image file after a memory leak occurs to determine the target program in the program under test that caused the memory leak, it is helpful to quickly determine the target program with problems in the test, improve the test speed of the program under test, and then reduce the test cost.

[0086] According to an embodiment of the present disclosure, the program to be tested includes a plurality of test subroutines.

[0087] In a specific embodiment, determining a target program causing a memory leak in a program to be tested according to a plurality of process memory image files includes:

[0088] For each process memory image file, extracting a memory occupancy list from the process memory image file, wherein the memory occupancy list includes at least one test subroutine that occupies more than a preset proportion of the virtual machine memory;

[0089] For each test subprogram, if the test subprogram is included in a preset number of memory occupation lists, the test subprogram is determined as a target program.

[0090] According to an embodiment of the present disclosure, for each process memory image file, a memory occupancy list is extracted from the process memory image file, and the memory occupancy list includes the test subprograms retained in the virtual machine memory after the global garbage collection operation. If a preset number (for example, 3) of memory occupancy lists all include a test subprogram, the test subprogram can be determined as the target program that caused the memory leak.

[0091] According to the embodiments of the present disclosure, by analyzing and processing the process memory image file after the memory leak occurs to determine the target program causing the memory leak, it is helpful to quickly determine the cause of the memory leak and improve the testing speed.

[0092] In another specific embodiment, determining a target program causing a memory leak in a program to be tested according to a plurality of process memory image files includes:

[0093] For each process memory image file, extracting a memory occupancy list from the process memory image file, wherein the memory occupancy list includes at least one test subroutine that occupies more than a preset proportion of the virtual machine memory;

[0094] The test subroutine corresponding to the maximum value of memory occupancy is determined as the target program.

[0095] According to an embodiment of the present disclosure, the preset ratio may be 1% of the virtual machine memory, namely, Top Components, or other ratios.

[0096] According to an embodiment of the present disclosure, after a memory leak occurs, the global garbage collection operation Full GC cannot recycle the contents of the JVM heap (i.e., the virtual machine memory), and it will naturally grow to its maximum. Generally, the largest object is most likely to be the object of the memory leak. However, this does not mean that only the largest object is analyzed. Other objects that occupy a large amount of memory (for example, objects whose memory occupancy is ranked greater than a preset ranking, such as the top three test subroutines in memory occupancy) may all be the cause of the memory leak. In other words, there may be more than one object with a memory leak.

[0097] According to an embodiment of the present disclosure, the method further includes:

[0098] Sending the target program to the client so that the client can modify the target program to obtain a new program to be tested;

[0099] The virtual machine memory is used to iteratively perform global garbage collection operations on the new program under test until an analysis result is obtained indicating that there is no memory leak in the virtual machine memory.

[0100] According to an embodiment of the present disclosure, after determining the target program that causes the memory leak, the target program or the identifier of the target program is sent to the client so that the tester can modify the target program according to the feedback information to obtain a new program to be tested, and repeatedly execute the processing method of the present disclosure until there is no memory leak.

[0101] According to an embodiment of the present disclosure, the virtual machine memory includes a heap memory of the virtual machine, and the heap memory includes a first memory management area;

[0102] The multiple garbage collection logs within a preset time period are analyzed and processed to obtain analysis results, including:

[0103] For each garbage collection log, determine a capacity value of the first memory management area according to the garbage collection log, wherein different capacity values ​​are arranged in chronological order;

[0104] When a plurality of capacity values ​​that are consecutive in time sequence gradually increase, the analysis result is determined to indicate that a memory leak exists.

[0105] According to an embodiment of the present disclosure, the heap memory can be divided into a new generation and an old generation (i.e., a first memory management area). The new generation is generally divided into three areas, Eden+From Survicor+To Survicor. The memory ratio of Eden and Survicor is 8:1. Only one Eden and one Survicor area is used each time, and the other Survicor is used to reclaim memory by a copy collection algorithm.

[0106] According to an embodiment of the present disclosure, the garbage collection log is associated with the time of the global garbage collection operation performed, so the capacity value determined according to each garbage collection log is also correspondingly associated with the time. After determining the capacity value corresponding to each garbage collection log, it is determined whether multiple capacity values ​​that are consecutive in time are in a state of continuous growth. If they are in a state of continuous growth, it can be determined that there is a memory leak.

[0107] According to an embodiment of the present disclosure, the time allocation list includes multiple initial recovery duration thresholds, wherein an initial recovery duration threshold corresponds to a type of initial process parameter, and the global recovery duration threshold is an initial recovery duration threshold corresponding to the process parameter.

[0108] According to an embodiment of the present disclosure, the global garbage collection operation may be triggered by a script, and the script triggering enables the present disclosure to perform multiple global garbage collection operations in a short period of time.

[0109] Figure 5 The figure schematically shows a heap usage diagram after global garbage collection according to an embodiment of the present disclosure.

[0110] In a specific embodiment, after testing the first program to be tested, the virtual machine memory processing method disclosed in the present invention is used to determine whether there is a memory leak, and the global recycling time threshold is 7200s, wherein, it can be obtained as follows: Figure 5 The heap usage diagram shown shows that there is no memory leak.

[0111] Figure 6 The figure schematically shows a heap usage diagram after global garbage collection according to another embodiment of the present disclosure.

[0112] In another specific embodiment, after testing the second program to be tested, the virtual machine memory processing method disclosed in the present invention is used to determine whether there is a memory leak, and the global recycling time threshold is also 7200s, wherein, it can be obtained as follows: Figure 6 The heap usage diagram shown in the figure shows that the capacity value gradually increases, thereby determining that a memory leak occurs.

[0113] Figure 7 The structure block diagram of a virtual machine memory processing device according to an embodiment of the present disclosure is schematically shown.

[0114] like Figure 7 As shown, the virtual machine memory processing device 700 of this embodiment includes an acquisition module 710 , a determination module 720 , a recovery module 730 , and an analysis module 740 .

[0115] The acquisition module 710 is used to acquire the process parameters of the program under test when the program under test is running in the memory of the virtual machine;

[0116] A determination module 720, configured to determine a global recycling duration threshold corresponding to the process parameter from a time allocation list based on the process parameter;

[0117] The recycling module 730 is used to perform a global garbage collection operation on the virtual machine memory to generate a garbage collection log each time the running time of the program under test reaches the global recycling time threshold;

[0118] The analysis module 740 is used to analyze and process multiple garbage collection logs within a preset time period to obtain an analysis result, wherein the analysis result indicates whether there is a memory leak in the virtual machine memory.

[0119] According to an embodiment of the present disclosure, by determining the global recycling time threshold corresponding to the program to be tested of different types of process parameters in the time allocation table, multiple global recycling operations are performed within a preset time period, thereby analyzing multiple garbage collection logs to determine whether there is a memory leak. Since different global recycling time thresholds are allocated to each type of process parameter in the time allocation list, it is possible to accurately determine whether there is a memory leak within the preset time period, thereby improving the recognition efficiency and accuracy of memory leaks and reducing the time cost required for testing.

[0120] According to an embodiment of the present disclosure, the processing device 700 further includes:

[0121] The second acquisition module is used to acquire the process memory image file generated after each global garbage collection operation when the analysis result indicates that there is a memory leak;

[0122] The second determination module is used to determine a target program causing memory leakage in the program to be tested according to a plurality of process memory image files.

[0123] According to an embodiment of the present disclosure, the program to be tested includes a plurality of test subroutines.

[0124] According to an embodiment of the present disclosure, the second determination module includes:

[0125] A first extraction unit is used to extract a memory occupation list from the process memory image file for each process memory image file, wherein the memory occupation list includes at least one test subroutine that occupies a virtual machine memory exceeding a preset ratio;

[0126] The first determining unit is configured to determine, for each test subprogram, the test subprogram as a target program when a preset number of memory occupancy lists all include the test subprogram.

[0127] According to an embodiment of the present disclosure, the program to be tested includes a plurality of test subroutines.

[0128] According to an embodiment of the present disclosure, the second determination module includes:

[0129] A second extraction unit is used to extract a memory occupation list from the process memory image file for each process memory image file, wherein the memory occupation list includes at least one test subroutine that occupies a virtual machine memory exceeding a preset ratio;

[0130] The second determining unit is used to determine the test subroutine corresponding to the maximum value of the occupied memory as the target program.

[0131] According to an embodiment of the present disclosure, the processing device 700 further includes:

[0132] The sending module is used to send the target program to the client so that the client can modify the target program to obtain a new program to be tested;

[0133] The second recycling module is used to iteratively perform global garbage collection operations on the new program to be tested using the virtual machine memory until an analysis result indicating that there is no memory leak in the virtual machine memory is obtained.

[0134] According to an embodiment of the present disclosure, the virtual machine memory includes a heap memory of the virtual machine, and the heap memory includes a first memory management area.

[0135] According to an embodiment of the present disclosure, the analysis module 740 includes:

[0136] a third determining unit, configured to determine, for each garbage collection log, a capacity value of the first memory management area according to the garbage collection log, wherein different capacity values ​​are arranged in chronological order;

[0137] The fourth determining unit is used to determine the analysis result as a memory leak when a plurality of capacity values ​​that are consecutive in time sequence gradually increase.

[0138] According to an embodiment of the present disclosure, the time allocation list includes multiple initial recovery duration thresholds, wherein an initial recovery duration threshold corresponds to a type of initial process parameter, and the global recovery duration threshold is an initial recovery duration threshold corresponding to the process parameter.

[0139] According to an embodiment of the present disclosure, any multiple modules among the acquisition module 710, the determination module 720, the recovery module 730, and the analysis module 740 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the acquisition module 710, the determination module 720, the recovery module 730, and the analysis module 740 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, at least one of the acquisition module 710, the determination module 720, the recovery module 730, and the analysis module 740 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0140] Figure 8 A block diagram of an electronic device suitable for implementing the above method according to an embodiment of the present disclosure is schematically shown.

[0141] like Figure 8 As shown, the electronic device 800 according to an embodiment of the present disclosure includes a processor 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 to a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include an onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0142] In RAM 803, various programs and data required for the operation of electronic device 800 are stored. Processor 801, ROM 802 and RAM 803 are connected to each other via bus 804. Processor 801 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 802 and / or RAM 803. It should be noted that the program can also be stored in one or more memories other than ROM 802 and RAM 803. Processor 801 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0143] According to an embodiment of the present disclosure, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to the bus 804. The electronic device 800 may further include one or more of the following components connected to the input / output (I / O) interface 805: an input portion 806 including a keyboard, a mouse, etc.; an output portion 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 808 including a hard disk, etc.; and a communication portion 809 including a network interface card such as a LAN card, a modem, etc. The communication portion 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output (I / O) interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that the computer program read therefrom is installed into the storage portion 808 as needed.

[0144] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0145] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: 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), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 802 and / or RAM 803 described above and / or one or more memories other than ROM 802 and RAM 803.

[0146] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present disclosure.

[0147] The above functions defined in the system / device of the embodiment of the present disclosure are executed when the computer program is executed by the processor 801. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0148] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 809, and / or installed from a removable medium 811. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0149] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the processor 801, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.

[0150] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).

[0151] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0152] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0153] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A method for processing virtual machine memory, It is characterized in that The method comprises: When the program to be tested is running in the memory of the virtual machine, obtaining process parameters of the program to be tested; Determine a global recycling duration threshold value corresponding to the process parameter from a time allocation list based on the process parameter; When the running time of the program to be tested reaches the global garbage collection time threshold each time, performing a global garbage collection operation on the virtual machine memory to generate a garbage collection log; The plurality of garbage collection logs within a preset time period are analyzed and processed to obtain an analysis result, wherein the analysis result indicates whether there is a memory leak in the virtual machine memory.

2. The method according to claim 1, It is characterized in that The method further comprises: When the analysis result indicates that the memory leak exists, obtaining a process memory image file generated after each global garbage collection operation; A target program causing the memory leak in the program to be tested is determined according to the multiple process memory image files.

3. The method according to claim 2, It is characterized in that The program to be tested includes a plurality of test subroutines; Wherein, determining the target program causing the memory leak in the program to be tested according to the plurality of process memory image files includes: For each of the process memory image files, extracting a memory occupancy list from the process memory image file, wherein the memory occupancy list includes at least one test subroutine that occupies more than a preset proportion of the virtual machine memory; For each of the test subprograms, when a preset number of memory occupancy lists include the test subprogram, the test subprogram is determined as the target program.

4. The method according to claim 2, It is characterized in that The program to be tested includes a plurality of test subroutines; Wherein, determining the target program causing the memory leak in the program to be tested according to the plurality of process memory image files includes: For each of the process memory image files, extracting a memory occupancy list from the process memory image file, wherein the memory occupancy list includes at least one test subroutine that occupies more than a preset proportion of the virtual machine memory; The test subroutine corresponding to the maximum value of the occupied memory is determined as the target program.

5. The method according to any one of claims 2 to 4, It is characterized in that The method further comprises: Sending the target program to a client so that the client can modify the target program to obtain a new program to be tested; The global garbage collection operation is iteratively performed on the new program to be tested using the virtual machine memory until an analysis result indicating that the virtual machine memory does not have the memory leak is obtained.

6. The method according to claim 1, It is characterized in that The virtual machine memory includes a heap memory of the virtual machine, and the heap memory includes a first memory management area; The multiple garbage collection logs within a preset time period are analyzed and processed to obtain analysis results, including: For each of the garbage collection logs, determining a capacity value of the first memory management area according to the garbage collection log, wherein different capacity values ​​are arranged in chronological order; In the case that a plurality of the capacity values ​​that are continuous in time sequence gradually increase, the analysis result is determined as the presence of the memory leak.

7. The method according to claim 1, It is characterized in that The time allocation list includes multiple initial recovery duration thresholds, wherein one initial recovery duration threshold corresponds to a type of initial process parameter, and the global recovery duration threshold is the initial recovery duration threshold corresponding to the process parameter.

8. A processing device for a virtual machine memory, It is characterized in that The device comprises: An acquisition module, used for acquiring process parameters of the program under test when the program under test is running in the memory of the virtual machine; A determination module, configured to determine a global recycling duration threshold corresponding to the process parameter from a time allocation list based on the process parameter; A recycling module, used for performing a global garbage collection operation on the virtual machine memory to generate a garbage collection log each time the running time of the program under test reaches the global recycling time threshold; The analysis module is used to analyze and process the multiple garbage collection logs within a preset time period to obtain an analysis result, wherein the analysis result indicates whether there is a memory leak in the virtual machine memory.

9. An electronic device, include: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program or instructions stored thereon, It is characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

11. A computer program product comprising a computer program or instructions, It is characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.