A memory leak testing method, system, terminal and storage medium
By automatically collecting and analyzing memory test data, the problem of memory leakage testing is solved, and fast and accurate memory leakage detection is achieved.
Patent Information
- Application Number
- CN202411459180.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-10-18
AI Technical Summary
In the memory leak test, the data acquisition and judgment process takes a long time, resulting in too long test cycles.
By generating test commands, automatically collecting multi-device memory test data, conducting preliminary and secondary traversal judgments, generating memory curves and analyzing results, realizing automated testing and result analysis.
Shorten the memory leak test time, improve the testing efficiency, and obtain accurate memory test results through two traversals.
Smart Images

Figure CN118964221B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of memory leakage testing, and in particular to a memory leakage testing method, system, terminal and storage medium. Background Art
[0002] Currently, in projects and actual production processes, corresponding data usually needs to be stored in multiple devices. For the storage situation of each device, it is necessary to determine whether all processes have the risk of memory leakage.
[0003] However, in the memory leak test, a lot of time is consumed in the data collection stage, and the user is required to make his own judgment in the process of determining whether there is a memory leak, which results in the entire memory leak test process being too long and consuming too much time.
[0004] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0005] The main purpose of the present invention is to provide a memory leak testing method, system, terminal and computer-readable storage medium, aiming to solve the problem in the prior art that in the memory leak test, a lot of time is consumed in the data collection stage, and the user is required to make his own judgment in the corresponding process of determining whether there is a memory leak, which leads to the entire memory leak testing process cycle being too long and consuming too much time.
[0006] To achieve the above object, the present invention provides a memory leak testing method, which comprises the following steps:
[0007] Obtaining user configuration requirements, and generating test commands according to the user configuration requirements;
[0008] Acquire memory test data of multiple devices according to the test command, and store the memory test data in a preset storage mode;
[0009] Convert all the memory test data into a form to obtain multiple table files, perform a preliminary traversal on each process in each table file, and determine whether each process is a preliminary memory leak process;
[0010] When the preliminary traversal is completed, all preliminary memory leak processes are obtained, each of the preliminary memory leak processes is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information;
[0011] A memory leak test result is generated according to each of the memory curves, and the corresponding memory leak test result is sent to a corresponding target device.
[0012] Optionally, the obtaining of user configuration requirements and generating a test command according to the user configuration requirements specifically includes:
[0013] Obtaining user configuration requirements, wherein the user configuration requirements include an interval time, a start time, and an end time;
[0014] A first command is obtained, and the first command is adjusted according to the interval time, the start time, and the end time to generate the test command.
[0015] Optionally, acquiring memory test data of multiple devices according to the test command and storing the memory test data in a preset storage mode specifically includes:
[0016] Run the test command, and obtain memory test data of each process of each device at intervals from the start time to the end time according to the test command;
[0017] Set unique identifiers for all memory test data and store them in a preset directory.
[0018] Optionally, the converting all the memory test data into a form to obtain a plurality of table files, and preliminarily traversing each process in each of the table files to determine whether each process is a preliminary memory leak process specifically includes:
[0019] Convert the corresponding memory test data into a form according to a unique identifier of each memory test data to obtain a plurality of preliminary table files, and save the preliminary table files corresponding to the processes of each device into the same file to obtain a table file;
[0020] Each process in each of the table files is preliminarily traversed to obtain a preliminary memory curve of each process, and whether each process is a preliminary memory leak process is determined according to the preliminary memory curve of each process.
[0021] Optionally, judging whether each process is a preliminary memory leak process according to the preliminary memory curve of each process specifically includes:
[0022] If the initial memory curve of the process is an upward curve, the corresponding process is a preliminary memory leak process, and the corresponding process in each device is marked as a preliminary memory leak process, and the traversal of the process is skipped;
[0023] If the initial memory curve of the process is not an upward curve, the corresponding process is not an initial memory leak process.
[0024] Optionally, when the preliminary traversal is completed, all preliminary memory leak processes are obtained, each of the preliminary memory leak processes is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information, specifically including:
[0025] When the initial traversal is completed, all preliminary memory leak processes are obtained;
[0026] Perform a second traversal of the preliminary memory leak process in each device, and save the traversal information obtained after traversing each device in the corresponding device in a table form;
[0027] According to the traversal information of each preliminary memory leak process obtained by each device, a corresponding memory curve is generated.
[0028] Optionally, generating a memory leak test result according to each of the memory curves, and sending the corresponding memory leak test result to a corresponding target device specifically includes:
[0029] According to each of the memory curves, determining whether a preliminary memory leak process of a corresponding device is a memory leak process;
[0030] Obtaining result information of whether all preliminary memory leak processes of all devices are memory leak processes, generating a memory leak test result for each device according to the result information, and taking the device with the memory leak process in the result information as the corresponding target device;
[0031] Send the corresponding memory leak test results to the corresponding target device.
[0032] In addition, to achieve the above object, the present invention also provides a memory leak testing system, wherein the memory leak testing system comprises:
[0033] A command generation module, used to obtain user configuration requirements and generate test commands according to the user configuration requirements;
[0034] A test data acquisition module, used to acquire memory test data of multiple devices according to the test command, and store the memory test data in a preset storage mode;
[0035] A first judgment module is used to convert all the memory test data into a form to obtain multiple table files, and to preliminarily traverse each process in each of the table files to determine whether each process is a preliminary memory leak process;
[0036] The second judgment module is used to obtain all preliminary memory leak processes when the preliminary traversal is completed, perform a secondary traversal on each of the preliminary memory leak processes, obtain traversal information obtained after the traversal of each device, and generate a memory curve of each preliminary memory leak process on each device according to the traversal information;
[0037] The result sending module is used to generate a memory leak test result according to each of the memory curves, and send the corresponding memory leak test result to the corresponding target device.
[0038] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a memory leak test program stored in the memory and executable on the processor, and when the memory leak test program is executed by the processor, the steps of the memory leak test method as described above are implemented.
[0039] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a memory leak test program, and when the memory leak test program is executed by a processor, the steps of the memory leak test method described above are implemented.
[0040] In the present invention, user configuration requirements are obtained, and test commands are generated according to the user configuration requirements; memory test data of multiple devices are obtained according to the test commands, and the memory test data are stored in a preset storage method; all the memory test data are converted into a form to obtain multiple table files, and each process in each of the table files is preliminarily traversed to determine whether each process is a preliminary memory leak process; when the preliminary traversal is completed, all the preliminary memory leak processes are obtained, each of the preliminary memory leak processes is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information; based on each of the memory curves, a memory leak test result is generated, and the corresponding memory leak test result is sent to the corresponding target device. The present invention solves the problem that, in the memory leak test, a lot of time is consumed in the data collection stage, and the user is required to make his own judgment in the corresponding process of determining whether there is a memory leak, which leads to the problem that the entire memory leak test process is too long and consumes too much time. The present invention uses a generated test command to automatically perform the memory leak test, and then analyzes the data of the memory leak test to obtain the corresponding memory test result. In this process, the test is automatically performed as well as the analysis and judgment of the memory test result, so that the present application can complete the entire memory leak test in a short time and obtain accurate memory test results through two traversals. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a flow chart of a preferred embodiment of the memory leak testing method of the present invention;
[0042] Figure 2 is a structural diagram of a preferred embodiment of the memory leak testing system of the present invention;
[0043] Figure 3 It is a structural diagram of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0045] At present, in projects and actual production processes, corresponding data is usually stored in multiple devices, and for the storage situation of each device, it is necessary to determine whether all processes have the risk of memory leaks. However, in the memory leak test, the data collection stage consumes a lot of time, and the corresponding judgment of whether there is a memory leak requires the user to judge by himself, which makes the entire memory leak test process too long and consumes too much time.
[0046] In response to one or more of the above-mentioned problems, the present invention obtains user configuration requirements and generates a test command according to the user configuration requirements; obtains memory test data of multiple devices according to the test command, and stores the memory test data in a preset storage method; converts all of the memory test data into a form to obtain multiple table files, performs a preliminary traversal on each process in each of the table files, and determines whether each process is a preliminary memory leak process; when the preliminary traversal is completed, obtains all preliminary memory leak processes, performs a secondary traversal on each of the preliminary memory leak processes, and obtains traversal information obtained after the traversal of each device, and generates a memory curve of each preliminary memory leak process on each device according to the traversal information; generates a memory leak test result according to each of the memory curves, and sends the corresponding memory leak test result to the corresponding target device.
[0047] The memory leak testing method described in the preferred embodiment of the present invention is as follows: Figure 1 As shown, the memory leak testing method comprises the following steps:
[0048] Step S10: Obtain user configuration requirements, and generate test commands according to the user configuration requirements.
[0049] Specifically, in the project, it is necessary to collect memory data of multiple devices. For example, for device type A and device type B, it is necessary to determine whether all processes in the device have the risk of memory leakage. More than 160 processes will run on each device. In a project test cycle, at least one device needs to be tested within a week, that is, 24 devices, and at most three devices need to be tested within a week. In other words, at least 24 pieces of memory data need to be checked, and at most 35 pieces of memory data need to be checked, which takes a lot of time. Therefore, in order to perform automated testing on whether there is a memory leak in the process on the device, it is necessary to first generate corresponding test commands to implement automated testing.
[0050] The obtaining of user configuration requirements and generating a test command according to the user configuration requirements specifically includes:
[0051] Obtaining user configuration requirements, wherein the user configuration requirements include an interval time, a start time, and an end time;
[0052] A first command is obtained, and the first command is adjusted according to the interval time, the start time, and the end time to generate the test command.
[0053] Specifically, in the present application, the user configuration requirements are obtained in advance, and the user configuration requirements include the interval time, the start time and the end time. Then, the first command is obtained, and the corresponding test command is generated through the user configuration requirements and the first command. Among them, the first command is the hidumper command (i.e., hdc hidumper --mem), which is a command that comes with the OpenHarmony system. This command will allow the system to return the memory usage of all processes at this moment; the start time and the end time are used in the test command to control the running time of the first command, and the interval time is used to control the time interval between each execution of the first command during the running time. That is, the test command enables the system to send the hidumper command to the device at intervals within the start time and the end time, and store the obtained memory test data in a preset storage method.
[0054] Step S20: acquiring memory test data of multiple devices according to the test command, and storing the memory test data in a preset storage mode.
[0055] Specifically, in the present application, after receiving the test command, a corresponding automated test is performed to obtain memory test data.
[0056] The acquiring memory test data of multiple devices according to the test command, and storing the memory test data in a preset storage mode, specifically includes:
[0057] Run the test command, and obtain memory test data of each process of each device at intervals from the start time to the end time according to the test command;
[0058] Set unique identifiers for all memory test data and store them in a preset directory.
[0059] Specifically, in the present application, the corresponding test command is run so that the system sends a hidumper command to the device at intervals within the start time and end time, and stores the obtained memory test data in a preset storage method. When storing, a unique identifier is set for the memory test data obtained for each device according to the name of each device, and the corresponding memory test data is stored in a preset directory, wherein the storage is in the form of an exe (executable file) file.
[0060] Among them, in this application, memory test data is placed in the occupied data block for calculation before the process in the system performs an operation; for example, after turning on the WIFI switch, the device performs a WIFI scan and sets a scan for 10 seconds. In this process, the timer will occupy the data block, the WIFI scan will occupy the data block when registered in the event, and the scanning module will write the discovered WIFI name to the device and occupy the data block; among them, the data block occupied is the memory test data, and this application will store the corresponding data block in a preset storage method. The data block releases the memory after the device is shut down, that is, the memory test data is not saved after the device is restarted. The processes that collect memory test data include WIFI, Bluetooth, setting applications, etc. Some of these processes have no interface but still work for the device.
[0061] Step S30: convert all the memory test data into a format to obtain a plurality of table files, perform a preliminary traversal on each process in each of the table files, and determine whether each process is a preliminary memory leak process.
[0062] Furthermore, in the present application, after obtaining the corresponding memory test data, the corresponding memory test data is traversed to determine whether there is a memory leak.
[0063] Furthermore, the format of all the memory test data is converted to obtain multiple table files, each process in each table file is preliminarily traversed, and each process is judged whether it is a preliminary memory leak process, specifically including:
[0064] Convert the corresponding memory test data into a form according to a unique identifier of each memory test data to obtain a plurality of preliminary table files, and save the preliminary table files corresponding to the processes of each device into the same file to obtain a table file;
[0065] Each process in each of the table files is preliminarily traversed to obtain a preliminary memory curve of each process, and whether each process is a preliminary memory leak process is determined according to the preliminary memory curve of each process.
[0066] Specifically, in this application, the memory test data is first converted into a table format, which includes the process name, time point and specific memory test data, that is, the occupied memory data, in kb; and the name of each table file is the corresponding unique identifier. The unique identifiers of the memory test data corresponding to different processes of the same device are the same, so the preliminary table file corresponding to the process of each device is saved in the same file to obtain a table file, in which the table name is the corresponding unique identifier.
[0067] Perform a preliminary traversal of each process in each table file, fit the memory test data of each process according to the time point, and obtain a preliminary memory curve to determine whether each process is a preliminary memory leak process.
[0068] Furthermore, judging whether each process is a preliminary memory leak process according to the preliminary memory curve of each process specifically includes:
[0069] If the initial memory curve of the process is an upward curve, the corresponding process is a preliminary memory leak process, and the corresponding process in each device is marked as a preliminary memory leak process, and the traversal of the process is skipped;
[0070] If the initial memory curve of the process is not an upward curve, the corresponding process is not an initial memory leak process.
[0071] Specifically, when judging whether each process is a preliminary memory leak process, if the memory test data of this process increases steadily during the test cycle, that is, the preliminary memory curve is an upward curve, the process of all devices will be judged as a preliminary memory leak process, and the traversal of this process by all other devices will be skipped.
[0072] Step S40: when the preliminary traversal is completed, all preliminary memory leak processes are obtained, each of the preliminary memory leak processes is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information.
[0073] Specifically, in the present application, the initial traversal can identify which process has a memory leak, and the secondary traversal is used to identify on which devices the processes with memory leaks will have memory leaks.
[0074] Furthermore, when the preliminary traversal is completed, all preliminary memory leak processes are obtained, each preliminary memory leak process is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information, specifically including:
[0075] When the initial traversal is completed, all preliminary memory leak processes are obtained;
[0076] Perform a second traversal of the preliminary memory leak process in each device, and save the traversal information obtained after traversing each device in the corresponding device in a table form;
[0077] According to the traversal information of each preliminary memory leak process obtained by each device, a corresponding memory curve is generated.
[0078] Specifically, in the present application, after the initial traversal is completed, a secondary traversal is performed in each device. The secondary traversal processes the corresponding memory test data for the initial memory leak process in each device to obtain traversal information, and stores it in the form of a table. The traversal information includes the name of the initial memory leak process, the probability of leakage, the highest growth memory curve, the lowest growth memory curve, and the memory test data of each initial memory leak process. The probability of leakage is the probability of the initial memory leak process accounting for the total process. The highest growth memory curve is the initial memory curve of the process with the largest change in memory test data, and the lowest growth memory curve is the initial memory curve of the process with the smallest change in memory test data. Then, the memory test data of each initial memory leak process in the traversal information is used to generate the memory curve of each process on each device.
[0079] Step S50: Generate a memory leak test result according to each of the memory curves, and send the corresponding memory leak test result to the corresponding target device.
[0080] Furthermore, after obtaining the memory curve, the memory leak test result can be matched, and the corresponding information can be sent to the target device where the memory leak occurs.
[0081] Furthermore, generating a memory leak test result according to each of the memory curves, and sending the corresponding memory leak test result to the corresponding target device, specifically includes:
[0082] According to each of the memory curves, determining whether a preliminary memory leak process of a corresponding device is a memory leak process;
[0083] Obtaining result information of whether all preliminary memory leak processes of all devices are memory leak processes, generating a memory leak test result for each device according to the result information, and taking the device with the memory leak process in the result information as the corresponding target device;
[0084] Send the corresponding memory leak test results to the corresponding target device.
[0085] Specifically, in this application, the memory curve is used to see whether the initial memory leak process of the corresponding device is a memory leak process. If the memory curve is an upward curve, it will be determined that the initial memory leak process of the corresponding device is a memory leak process, thereby obtaining the result information of the memory leak process and obtaining the corresponding device information. All result information in the same device is obtained, and the result information is aggregated to obtain the memory leak test result, and the memory leak test result is sent to the target device, and the target device is the device with the memory leak process.
[0086] The present invention obtains user configuration requirements, generates test commands according to the user configuration requirements; obtains memory test data of multiple devices according to the test commands, and stores the memory test data in a preset storage method; converts all the memory test data into a form to obtain multiple table files, performs a preliminary traversal on each process in each of the table files, and determines whether each process is a preliminary memory leak process; when the preliminary traversal is completed, obtains all the preliminary memory leak processes, performs a secondary traversal on each of the preliminary memory leak processes, and obtains traversal information obtained after the traversal of each device, and generates a memory curve of each preliminary memory leak process on each device according to the traversal information; generates a memory leak test result according to each of the memory curves, and sends the corresponding memory leak test result to the corresponding target device. The present invention solves the problem that, in the memory leak test, a lot of time is consumed in the data collection stage, and the user is required to make his own judgment in the corresponding process of determining whether there is a memory leak, which leads to the problem that the entire memory leak test process is too long and consumes too much time. The present invention uses a generated test command to automatically perform the memory leak test, and then analyzes the data of the memory leak test to obtain the corresponding memory test result. In this process, the test is automatically performed as well as the analysis and judgment of the memory test result, so that the present application can complete the entire memory leak test in a short time and obtain accurate memory test results through two traversals.
[0087] Furthermore, if Figure 2 As shown, based on the above memory leakage testing method, the present invention also provides a memory leakage testing system accordingly, wherein the memory leakage testing system comprises:
[0088] The command generation module 21 is used to obtain user configuration requirements and generate test commands according to the user configuration requirements;
[0089] A test data acquisition module 22, used for acquiring memory test data of multiple devices according to the test command, and storing the memory test data in a preset storage mode;
[0090] The first judgment module 23 is used to convert all the memory test data into a form to obtain multiple table files, and to perform a preliminary traversal on each process in each of the table files to determine whether each process is a preliminary memory leak process;
[0091] The second judgment module 24 is used to obtain all preliminary memory leak processes when the preliminary traversal is completed, perform a secondary traversal on each of the preliminary memory leak processes, and obtain traversal information obtained after the traversal of each device, and generate a memory curve of each preliminary memory leak process on each device according to the traversal information;
[0092] The result sending module 25 is used to generate a memory leakage test result according to each of the memory curves, and send the corresponding memory leakage test result to the corresponding target device.
[0093] Furthermore, if Figure 3 As shown, based on the above-mentioned memory leakage testing method and system, the present invention also provides a terminal accordingly, and the terminal includes a processor 10, a memory 20 and a display 30. Figure 3 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0094] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the terminal, such as the program code of the installation terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a memory leak test program 40 is stored on the memory 20, and the memory leak test program 40 can be executed by the processor 10, thereby realizing the memory leak test method in the present application.
[0095] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, and is used to run the program code or process data stored in the memory 20, such as executing the memory leak testing method.
[0096] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a system bus.
[0097] In one embodiment, when the processor 10 executes the memory leak test program 40 in the memory 20 , the steps in the above memory leak test method are implemented.
[0098] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a memory leak test program, and when the memory leak test program is executed by a processor, the following steps of the memory leak test method are implemented:
[0099] Obtaining user configuration requirements, and generating test commands according to the user configuration requirements;
[0100] Acquire memory test data of multiple devices according to the test command, and store the memory test data in a preset storage mode;
[0101] Convert all the memory test data into a form to obtain multiple table files, perform a preliminary traversal on each process in each table file, and determine whether each process is a preliminary memory leak process;
[0102] When the preliminary traversal is completed, all preliminary memory leak processes are obtained, each of the preliminary memory leak processes is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information;
[0103] A memory leak test result is generated according to each of the memory curves, and the corresponding memory leak test result is sent to a corresponding target device.
[0104] The obtaining of user configuration requirements and generating test commands according to the user configuration requirements specifically include:
[0105] Obtaining user configuration requirements, wherein the user configuration requirements include an interval time, a start time, and an end time;
[0106] A first command is obtained, and the first command is adjusted according to the interval time, the start time, and the end time to generate the test command.
[0107] The acquiring of memory test data of multiple devices according to the test command and storing the memory test data in a preset storage mode specifically includes:
[0108] Run the test command, and obtain memory test data of each process of each device at intervals from the start time to the end time according to the test command;
[0109] Set unique identifiers for all memory test data and store them in a preset directory.
[0110] The method of converting all the memory test data into a form to obtain a plurality of table files, and performing a preliminary traversal on each process in each of the table files to determine whether each process is a preliminary memory leak process specifically includes:
[0111] Convert the corresponding memory test data into a form according to a unique identifier of each memory test data to obtain a plurality of preliminary table files, and save the preliminary table files corresponding to the processes of each device into the same file to obtain a table file;
[0112] Each process in each of the table files is preliminarily traversed to obtain a preliminary memory curve of each process, and whether each process is a preliminary memory leak process is determined according to the preliminary memory curve of each process.
[0113] The step of judging whether each process is a preliminary memory leak process according to the preliminary memory curve of each process specifically includes:
[0114] If the initial memory curve of the process is an upward curve, the corresponding process is a preliminary memory leak process, and the corresponding process in each device is marked as a preliminary memory leak process, and the traversal of the process is skipped;
[0115] If the initial memory curve of the process is not an upward curve, the corresponding process is not an initial memory leak process.
[0116] When the preliminary traversal is completed, all preliminary memory leak processes are obtained, each preliminary memory leak process is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information, specifically including:
[0117] When the initial traversal is completed, all preliminary memory leak processes are obtained;
[0118] Perform a second traversal of the preliminary memory leak process in each device, and save the traversal information obtained after traversing each device in the corresponding device in a table form;
[0119] According to the traversal information of each preliminary memory leak process obtained by each device, a corresponding memory curve is generated.
[0120] The step of generating a memory leak test result according to each of the memory curves and sending the corresponding memory leak test result to a corresponding target device specifically includes:
[0121] According to each of the memory curves, determining whether a preliminary memory leak process of a corresponding device is a memory leak process;
[0122] Obtaining result information of whether all preliminary memory leak processes of all devices are memory leak processes, generating a memory leak test result for each device according to the result information, and taking the device with the memory leak process in the result information as the corresponding target device;
[0123] Send the corresponding memory leak test results to the corresponding target device.
[0124] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or terminal including the element.
[0125] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium that can be read by a computer, and the program can include the processes of the above-mentioned method embodiments when executed. The computer-readable storage medium can be a memory, a disk, an optical disk, etc.
[0126] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A memory leak testing method, characterized in that: The memory leak testing method comprises: Obtaining user configuration requirements, and generating test commands according to the user configuration requirements; Acquire memory test data of multiple devices according to the test command, and store the memory test data in a preset storage mode; Convert all the memory test data into a form to obtain multiple table files, perform a preliminary traversal on each process in each table file, and determine whether each process is a preliminary memory leak process; When the preliminary traversal is completed, all preliminary memory leak processes are obtained, each of the preliminary memory leak processes is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information; Generate a memory leak test result according to each of the memory curves, and send the corresponding memory leak test result to the corresponding target device; The method of converting all the memory test data into a form to obtain a plurality of table files, and preliminarily traversing each process in each of the table files to determine whether each process is a preliminary memory leak process specifically includes: Convert the corresponding memory test data into a form according to a unique identifier of each memory test data to obtain a plurality of preliminary table files, and save the preliminary table files corresponding to the processes of each device into the same file to obtain a table file; Perform a preliminary traversal of each process in each of the table files to obtain a preliminary memory curve of each process, and determine whether each process is a preliminary memory leak process according to the preliminary memory curve of each process; The step of judging whether each process is a preliminary memory leak process according to the preliminary memory curve of each process specifically includes: If the initial memory curve of the process is an upward curve, the corresponding process is a preliminary memory leak process, and the corresponding process in each device is marked as a preliminary memory leak process, and the traversal of the process is skipped; If the initial memory curve of the process is not an upward curve, the corresponding process is not an initial memory leak process; When the preliminary traversal is completed, all preliminary memory leak processes are obtained, each preliminary memory leak process is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information, specifically including: When the initial traversal is completed, all preliminary memory leak processes are obtained; Perform a second traversal of the preliminary memory leak process in each device, and save the traversal information obtained after traversing each device in the corresponding device in a table form; According to the traversal information of each preliminary memory leak process obtained by each device, a corresponding memory curve is generated.
2. The memory leak testing method according to claim 1, characterized in that: The obtaining of user configuration requirements and generating a test command according to the user configuration requirements specifically includes: Obtaining user configuration requirements, wherein the user configuration requirements include an interval time, a start time, and an end time; A first command is obtained, and the first command is adjusted according to the interval time, the start time, and the end time to generate the test command.
3. The memory leak testing method according to claim 2, characterized in that: The acquiring memory test data of multiple devices according to the test command, and storing the memory test data in a preset storage mode, specifically includes: Run the test command, and obtain memory test data of each process of each device at intervals from the start time to the end time according to the test command; Set unique identifiers for all memory test data and store them in a preset directory.
4. The memory leak testing method according to claim 1, characterized in that: The generating a memory leak test result according to each of the memory curves, and sending the corresponding memory leak test result to the corresponding target device, specifically includes: According to each of the memory curves, determining whether a preliminary memory leak process of a corresponding device is a memory leak process; Obtaining result information of whether all preliminary memory leak processes of all devices are memory leak processes, generating a memory leak test result for each device according to the result information, and taking the device with the memory leak process in the result information as the corresponding target device; Send the corresponding memory leak test results to the corresponding target device.
5. A memory leak testing system, characterized in that: The memory leak testing system comprises: A command generation module, used to obtain user configuration requirements and generate test commands according to the user configuration requirements; A test data acquisition module, used to acquire memory test data of multiple devices according to the test command, and store the memory test data in a preset storage mode; A first judgment module is used to convert all the memory test data into a form to obtain multiple table files, and to preliminarily traverse each process in each of the table files to determine whether each process is a preliminary memory leak process; The second judgment module is used to obtain all preliminary memory leak processes when the preliminary traversal is completed, perform a secondary traversal on each of the preliminary memory leak processes, obtain traversal information obtained after the traversal of each device, and generate a memory curve of each preliminary memory leak process on each device according to the traversal information; A result sending module, used for generating a memory leak test result according to each of the memory curves, and sending the corresponding memory leak test result to the corresponding target device; The method of converting all the memory test data into a form to obtain a plurality of table files, and preliminarily traversing each process in each of the table files to determine whether each process is a preliminary memory leak process specifically includes: Convert the corresponding memory test data into a form according to a unique identifier of each memory test data to obtain a plurality of preliminary table files, and save the preliminary table files corresponding to the processes of each device into the same file to obtain a table file; Perform a preliminary traversal of each process in each of the table files to obtain a preliminary memory curve of each process, and determine whether each process is a preliminary memory leak process according to the preliminary memory curve of each process; The step of judging whether each process is a preliminary memory leak process according to the preliminary memory curve of each process specifically includes: If the initial memory curve of the process is an upward curve, the corresponding process is a preliminary memory leak process, and the corresponding process in each device is marked as a preliminary memory leak process, and the traversal of the process is skipped; If the initial memory curve of the process is not an upward curve, the corresponding process is not an initial memory leak process; When the preliminary traversal is completed, all preliminary memory leak processes are obtained, each preliminary memory leak process is traversed twice, and traversal information obtained after the traversal of each device is obtained, and a memory curve of each preliminary memory leak process on each device is generated according to the traversal information, specifically including: When the initial traversal is completed, all preliminary memory leak processes are obtained; Perform a second traversal of the preliminary memory leak process in each device, and save the traversal information obtained after traversing each device in the corresponding device in a table form; According to the traversal information of each preliminary memory leak process obtained by each device, a corresponding memory curve is generated.
6. A terminal, characterized in that: The terminal includes: a memory, a processor, and a memory leak test program stored in the memory and executable on the processor. When the memory leak test program is executed by the processor, the steps of the memory leak test method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a memory leak test program, and when the memory leak test program is executed by a processor, the steps of the memory leak test method according to any one of claims 1 to 4 are implemented.
