Memory leak detection method, device, terminal and storage medium

By using the memory detection model to predict the memory information of the running scenario and directly determine the detection results, the problem of low memory leakage detection efficiency in the prior art is solved, and a faster detection process is achieved.

CN112463603BActive Publication Date: 2025-02-11BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011340207.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-25
Publication Date
2025-02-11
Estimated Expiration
2041-02-11

AI Technical Summary

Technical Problem

In the prior art, memory leak detection requires running the script files of the application multiple times, resulting in low detection efficiency.

Method used

By obtaining the first memory information generated by the running scenario, using the memory detection model to predict, determine the detection results of the running scenario, and avoiding repeated running of the application.

Benefits of technology

It shortens the time to determine the memory leak detection results and improves the efficiency of memory leak detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112463603B_ABST
    Figure CN112463603B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, device, terminal and storage medium for detecting memory leaks, and relates to the field of computer technology. The method includes: obtaining first memory information generated by a running scenario; determining a model prediction result of the memory detection model based on the first memory information and a memory detection model; determining the detection result of the running scenario based on the model prediction result; wherein the memory detection model is determined based on model data set training, and the model data set includes memory data preprocessed based on a sliding window. Since the memory detection model learns the relationship between memory information and the detection result of memory leaks during the training process, the detection result of the running scenario can be determined based on the model prediction result, and there is no need to repeatedly trigger the running scenario to determine the detection result, which shortens the time for determining the detection result of memory leaks and improves the detection efficiency of memory leaks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a memory leak detection method, device, terminal and storage medium. Background Art

[0002] After developing an application, developers need to perform performance testing on the application first. Only after the performance test passes can the application be released online. Memory leak detection is an important part of performance testing of applications. Among them, memory leak refers to the phenomenon that after the application ends, the memory occupied by the application during operation is not released for some reason, resulting in memory waste.

[0003] In the related art, the terminal runs the script file of the application N times (N is an integer greater than 1), collects the memory usage value of the application each time the script file is run; then determines the difference between two adjacent memory usage values, that is, determines the difference between the Nth and N-1th memory usage values, the difference between the N-2nd and N-1th memory usage values, ..., the difference between the 2nd and 1st memory usage values, and obtains the difference between N-1 memory usage values. In response to a preset proportion of the differences between the N-1 memory usage values ​​being positive numbers, it is determined that the application has a memory leak, otherwise, it is determined that the application does not have a memory leak.

[0004] In the above method, the script file of the application needs to be run N times to determine the detection result of the memory leak of the application. However, running the script file of the application N times is time-consuming, resulting in low efficiency of memory leak detection. Summary of the invention

[0005] The present disclosure provides a memory leak detection method, device, terminal and storage medium, which can improve the memory leak detection efficiency. The technical solution of the present disclosure is as follows:

[0006] According to one aspect of an embodiment of the present disclosure, a method for detecting a memory leak is provided, comprising:

[0007] Obtain the first memory information generated by the running scene;

[0008] Determine a model prediction result of the memory detection model based on the first memory information and the memory detection model;

[0009] Determining a detection result of the operating scenario based on the model prediction result;

[0010] The memory detection model is determined based on model data set training, and the model data set includes memory data preprocessed based on a sliding window.

[0011] In some embodiments, determining a model prediction result of the memory detection model based on the first memory information and the memory detection model includes:

[0012] Based on the first memory information and the memory detection model, obtaining a first prediction result of the running scenario, wherein the first prediction result includes whether a memory leak exists in the running scenario or whether there is no memory leak in the running scenario;

[0013] Based on the first prediction result, the model prediction result is determined.

[0014] In some embodiments, determining the model prediction result based on the first prediction result includes:

[0015] In response to the first prediction result indicating that there is a memory leak in the operating scenario, determining a leakage probability of the operating scenario;

[0016] Determine that the model prediction result is the existence of leakage and leakage probability in the operating scenario.

[0017] In some embodiments, determining the detection result of the operating scenario based on the model prediction result includes:

[0018] In response to the leakage probability being greater than a probability threshold, determining that the detection result is that a memory leak and a leakage probability exist in the running scenario;

[0019] In response to the leakage probability being not greater than the probability threshold, triggering the running scenario to be re-run, and updating the first memory information.

[0020] In some embodiments, determining the detection result of the operating scenario based on the model prediction result includes:

[0021] In response to the first prediction result being that there is no memory leak in the running scenario, determining that the model prediction result is that there is no leak in the running scenario;

[0022] Determine that the detection result is that there is no memory leak in the running scenario.

[0023] According to another aspect of an embodiment of the present disclosure, a method for training a memory detection model is provided, comprising:

[0024] Automatically trigger the test scenario to run in a loop;

[0025] Acquire a plurality of second memory information generated during multiple runs of the test scenario and sample marks of the test scenario;

[0026] Based on the plurality of second memory information and the sample labels, acquiring a model data set;

[0027] Based on the model data set, a memory detection model is trained and determined.

[0028] In some embodiments, acquiring the model data set based on the plurality of second memory information and the sample labels includes:

[0029] Determine the memory data in the plurality of second memory information based on the data sliding window;

[0030] Connect the memory data in series to generate sample memory data;

[0031] The model data set is generated based on the sample memory data and the sample labels.

[0032] In some embodiments, the training and determining the memory detection model based on the model data set includes:

[0033] Based on the model data set, generate a training set and a test set;

[0034] training an initial memory detection model based on the training set;

[0035] Based on the test set, testing the trained initial memory detection model;

[0036] Based on the initial memory detection model after the test, the memory detection model is determined.

[0037] In some embodiments, determining the memory detection model based on the initial memory detection model after the test includes:

[0038] In response to the initial memory detection model being trained and tested multiple times based on the training set and the test set, updating the algorithm model parameters of the initial memory detection model;

[0039] Based on the model data set, the initial memory detection model after updating the parameters is trained to obtain the memory detection model.

[0040] In some embodiments, the sample is marked as a memory leak result of the test scenario, wherein the memory leak result includes that a memory leak exists in the test scenario or that a memory leak does not exist in the test scenario.

[0041] In some embodiments, determining the memory data in the plurality of second memory information based on the data sliding window includes:

[0042] For each second memory information, the second memory information is intercepted based on the data sliding window to obtain memory data, wherein the sampling duration corresponding to the memory data is equal to the length of the data sliding window.

[0043] According to another aspect of an embodiment of the present disclosure, a memory leak detection device is provided, including:

[0044] A first acquisition unit is configured to execute acquisition of first memory information generated by the running scenario;

[0045] A first determining unit is configured to determine a model prediction result of the memory detection model based on the first memory information and the memory detection model;

[0046] The second determination unit is configured to execute the detection result of the operation scenario based on the model prediction result; wherein the memory detection model is determined based on the training of the model data set, and the model data set includes memory data preprocessed based on the sliding window.

[0047] In some embodiments, the first determining unit includes:

[0048] A first acquisition subunit acquires a first prediction result of the operation scenario based on the first memory information and a memory detection model, wherein the first prediction result includes whether a memory leak exists in the operation scenario or whether there is no memory leak in the operation scenario;

[0049] The first determining subunit determines the model prediction result based on the first prediction result.

[0050] In some embodiments, the first determining subunit is configured to execute, in response to the first prediction result being that there is a memory leak in the operating scenario, determining the leakage probability of the operating scenario; and determining that the model prediction result is that there is a leakage and the leakage probability in the operating scenario.

[0051] In some embodiments, the first determination subunit is configured to execute, in response to the leakage probability being greater than a probability threshold, determining that the detection result is that there is a memory leak and a leakage probability in the operation scenario; in response to the leakage probability being not greater than the probability threshold, triggering the operation scenario to re-run and updating the first memory information.

[0052] In some embodiments, the first determining subunit is configured to execute, in response to the first prediction result being that there is no memory leak in the operating scenario, determining that the model prediction result is that there is no leak in the operating scenario; and determining that the detection result is that there is no memory leak in the operating scenario.

[0053] According to another aspect of an embodiment of the present disclosure, a training device for a memory detection model is provided, comprising:

[0054] A running unit, configured to execute a loop of automatically triggered test scenarios;

[0055] A second acquisition unit is configured to execute acquisition of a plurality of second memory information generated during multiple runs of the test scenario and sample marks of the test scenario;

[0056] A third acquisition unit is configured to acquire a model data set based on the plurality of second memory information and the sample tags;

[0057] The third determination unit is configured to perform training to determine the memory detection model based on the model data set.

[0058] In some embodiments, the third acquisition unit includes:

[0059] A second determining subunit is configured to determine the memory data in the plurality of second memory information based on the data sliding window;

[0060] A series connection subunit, configured to execute series connection of the memory data to generate sample memory data;

[0061] The first generating subunit is configured to generate the model data set based on the sample memory data and the sample label.

[0062] In some embodiments, the third determining unit includes:

[0063] A second generating subunit is configured to generate a training set and a test set based on the model data set;

[0064] A training subunit, configured to train an initial memory detection model based on the training set;

[0065] A testing subunit, configured to execute a test based on the test set to test the trained initial memory detection model;

[0066] The third determining subunit is configured to execute the memory detection model based on the initial memory detection model after the test.

[0067] In some embodiments, the third determination subunit is configured to execute, in response to multiple trainings and multiple tests of the initial memory detection model based on the training set and the test set, updating the algorithm model parameters of the initial memory detection model; based on the model data set, training the initial memory detection model after the updated parameters to obtain the memory detection model.

[0068] In some embodiments, the sample is marked as a memory leak result of the test scenario, wherein the memory leak result includes that a memory leak exists in the test scenario or that a memory leak does not exist in the test scenario.

[0069] In some embodiments, the second determination subunit is configured to execute, for each second memory information, intercepting the second memory information based on the data sliding window to obtain memory data, wherein the sampling duration corresponding to the memory data is equal to the length of the data sliding window.

[0070] According to another aspect of an embodiment of the present disclosure, a terminal is provided, comprising a processor and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the memory leak detection method and the memory detection model training method in the above-mentioned embodiment.

[0071] According to another aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, in which instructions are stored. When the instructions in the storage medium are executed by a processor of a terminal, the terminal is enabled to execute the memory leak detection method and the memory detection model training method in the above-mentioned embodiment.

[0072] According to another aspect of an embodiment of the present disclosure, a computer program product is provided. When instructions in the computer program product are executed by a processor of a terminal, the terminal is enabled to execute the memory leak detection method and the memory detection model training method in the above-mentioned embodiment.

[0073] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0074] In the disclosed embodiment, the first memory information generated by the running scenario is obtained and the model detection result is determined with the help of a memory detection model. Since the memory detection model learns the relationship between the memory information and the detection result of the memory leak during the training process, the detection result of the running scenario can be determined based on the model prediction result. There is no need to repeatedly trigger the running scenario to determine the detection result, which shortens the time for determining the detection result of the memory leak and improves the detection efficiency of the memory leak.

[0075] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0076] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0077] Figure 1 The present invention is a flowchart of a method for detecting a memory leak according to an exemplary embodiment.

[0078] Figure 2The figure is a flowchart of a method for training a memory detection model according to an exemplary embodiment.

[0079] Figure 3 The figure is a flowchart of a method for training a memory detection model according to an exemplary embodiment.

[0080] Figure 4 The present invention is a flowchart of a method for detecting a memory leak according to an exemplary embodiment.

[0081] Figure 5 The invention is a block diagram showing a memory leak detection device according to an exemplary embodiment.

[0082] Figure 6 It is a block diagram of a training device for a memory detection model according to an exemplary embodiment.

[0083] Figure 7 It is a structural block diagram of a terminal according to an exemplary embodiment. DETAILED DESCRIPTION

[0084] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0085] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0086] The user information involved in the present disclosure may be information authorized by the user or fully authorized by all parties.

[0087] Figure 1 is a flowchart of a method for detecting a memory leak according to an exemplary embodiment. Figure 1 As shown, the memory leak detection method is used in a terminal and includes the following steps.

[0088] In step S11, the terminal obtains first memory information generated by the running scenario.

[0089] In step S12, the terminal determines a model prediction result of the memory detection model based on the first memory information and the memory detection model.

[0090] In step S13, the terminal determines the detection result of the operation scenario based on the model prediction result.

[0091] The memory detection model is determined based on model data set training, and the model data set includes memory data preprocessed based on a sliding window.

[0092] In some embodiments, determining a model prediction result of the memory detection model based on the first memory information and the memory detection model includes:

[0093] Based on the first memory information and the memory detection model, obtaining a first prediction result of the running scenario, wherein the first prediction result includes whether a memory leak exists in the running scenario or whether there is no memory leak in the running scenario;

[0094] Based on the first prediction result, the model prediction result is determined.

[0095] In some embodiments, determining the model prediction result based on the first prediction result includes:

[0096] In response to the first prediction result indicating that there is a memory leak in the running scenario, determining a leakage probability of the running scenario;

[0097] It is determined that the model prediction result is that there is leakage and leakage probability in this operating scenario.

[0098] In some embodiments, determining the detection result of the operation scenario based on the model prediction result includes:

[0099] In response to the leakage probability being greater than the probability threshold, determining that the detection result is that a memory leak and a leakage probability exist in the running scenario;

[0100] In response to the leakage probability being not greater than the probability threshold, the running scenario is triggered to be re-run, and the first memory information is updated.

[0101] In some embodiments, determining the detection result of the operation scenario based on the model prediction result includes:

[0102] In response to the first prediction result being that there is no memory leak in the running scenario, determining that the model prediction result is that there is no leak in the running scenario;

[0103] The detection result is confirmed that there is no memory leak in the running scenario.

[0104] In the disclosed embodiment, the first memory information generated by the running scenario is obtained and the model detection result is determined with the help of a memory detection model. Since the memory detection model learns the relationship between the memory information and the detection result of the memory leak during the training process, the detection result of the running scenario can be determined based on the model prediction result. There is no need to repeatedly trigger the running scenario to determine the detection result, which shortens the time for determining the detection result of the memory leak and improves the detection efficiency of the memory leak.

[0105] Figure 2 is a flowchart of a method for training a memory detection model according to an exemplary embodiment. Figure 2 As shown, the training method of the memory detection model is used in a terminal and includes the following steps.

[0106] In step S21, the terminal automatically triggers the test scenario to run in a loop;

[0107] In step S22, the terminal obtains a plurality of second memory information generated during multiple runs of the test scenario and a sample mark of the test scenario;

[0108] In step S23, the terminal acquires a model data set based on the plurality of second memory information and the sample label;

[0109] In step S24, the terminal trains and determines the memory detection model based on the model data set.

[0110] In some embodiments, based on the plurality of second memory information and the sample label, acquiring the model data set includes:

[0111] Determine the memory data in the plurality of second memory information based on the data sliding window;

[0112] The memory data is concatenated to generate sample memory data;

[0113] The model data set is generated based on the sample memory data and the sample label.

[0114] In some embodiments, the training and determining of the memory detection model based on the model data set includes:

[0115] Based on the model data set, generate a training set and a test set;

[0116] Train an initial memory detection model based on the training set;

[0117] Based on the test set, test the trained initial memory detection model;

[0118] The memory detection model is determined based on the initial memory detection model after the test.

[0119] In some embodiments, the determining the memory detection model based on the initial memory detection model after the test includes:

[0120] In response to the initial memory detection model being trained and tested multiple times based on the training set and the test set, updating the algorithm model parameters of the initial memory detection model;

[0121] Based on the model data set, the initial memory detection model with updated parameters is trained to obtain the memory detection model.

[0122] In some embodiments, the sample is marked as a memory leak result of the test scenario, wherein the memory leak result includes whether a memory leak exists in the test scenario or whether a memory leak does not exist in the test scenario.

[0123] In some embodiments, determining the memory data in the plurality of second memory information based on the data sliding window includes:

[0124] For each second memory information, based on the data sliding window, the second memory information is intercepted to obtain memory data, wherein the sampling time length corresponding to the memory data is equal to the length of the data sliding window.

[0125] In the disclosed embodiment, the first memory information generated by the running scenario is obtained and the model detection result is determined with the help of a memory detection model. Since the memory detection model learns the relationship between the memory information and the detection result of the memory leak during the training process, the detection result of the running scenario can be determined based on the model prediction result. There is no need to repeatedly trigger the running scenario to determine the detection result, which shortens the time for determining the detection result of the memory leak and improves the detection efficiency of the memory leak.

[0126] Figure 3 is a flowchart of a method for training a memory detection model according to an exemplary embodiment. Figure 3 As shown, in the embodiment of the present disclosure, the training of the memory detection model is taken as an example for explanation, and the training method of the memory detection model is used in the terminal, including the following steps:

[0127] In step 301, the terminal automatically triggers the test scenario to run in a loop.

[0128] Among them, the test scenario is a scenario corresponding to a testable function in the application to be tested, and the application to be tested is installed in the Android system. Since in the process of training the memory detection model, it is necessary to trigger the cyclic operation of the test scenario to build a model data set, the number of the test scenarios is multiple. Correspondingly, the multiple test scenarios are scenarios in the same application to be tested, or the multiple test scenarios are scenarios in different applications to be tested. In this step, the terminal cyclically runs the script file corresponding to the test scenario, triggering the test scenario to cyclically run.

[0129] In this step, the terminal automatically triggers the test scenario to run in a loop according to a preset number of runs. In some embodiments, the terminal pre-sets the number of runs of the run scenario, for example, the number of runs is run_times, and the terminal sets run_times=5, that is, the run scenario runs in a loop 5 times.

[0130] In step 302, the terminal obtains a plurality of second memory information generated during multiple runs of the test scenario and a sample mark of the test scenario.

[0131] Among them, the second memory information is the memory occupancy information generated by the test scenario during operation. The way in which the terminal obtains the multiple second memory information can be selected according to user needs, and the embodiments of the present disclosure do not limit this. In some embodiments, the terminal obtains multiple second memory information generated by multiple runs of the test scenario according to the Android Debug Bridge (ADB) command, and the number of the multiple second memory information is equal to the number of runs. For example, the terminal sets the second memory information generated by running the test scenario to X_A. In response to the number of runs being 5, the multiple second memory information obtained by the terminal are x_a0, x_a1, x_a2, x_a3 and x_a4, respectively.

[0132] The sample mark of the test scenario is the memory leak result of the test scenario. The memory leak result includes whether the test scenario has a memory leak or whether the test scenario does not have a memory leak. The terminal obtains the sample mark in the following manner: the terminal uses a memory detection tool to monitor the changes in the second memory information generated by the test scenario in multiple runs, and determines the sample mark according to the changes.

[0133] In this step, the terminal determines the implementation method of the sample marking according to the change: in response to the second memory information changing with time, and the length of the memory data included in the second memory information reaches a first threshold, the terminal determines the sample marking as: there is a memory leak in the test scenario; in response to the second memory information changing with time, and the length of the memory data included in the second memory information does not reach the first threshold, the terminal determines the sample marking as: there is no memory leak in the test scenario.

[0134] For example, the memory detection tool may be an Android Monitor, the sample is marked as y_A, and the first threshold is the maximum running memory of the terminal. The type of the memory detection tool may be set according to the needs of the user, and the embodiment of the present disclosure does not limit this. The first threshold may be set according to the needs of the user, and the embodiment of the present disclosure does not limit this.

[0135] In this step, the terminal obtains second memory information including multiple memory types, or, based on the target memory type, obtains second memory information corresponding to the target memory type.

[0136] In some embodiments, the terminal determines a plurality of preset memory types. In each process of running the test scenario, based on the plurality of memory types, memory information of each memory type is obtained, and the memory information of each memory type is formed into the second memory information.

[0137] For example, the preset multiple memory types are Java (a computer programming language) layer memory, native (local application) layer memory, graphics card memory, total physical memory and virtual memory; the memory information of each memory type is Java layer memory information, native layer memory information, graphics card memory information, total physical memory information and virtual memory information, and the terminal combines the memory information of each memory type into the second memory information.

[0138] In other embodiments, the terminal determines a target memory type to be tested, obtains memory information of the target memory type based on the target memory type, and uses the memory information of the target memory type as the second memory information.

[0139] For example, the target memory type is Java layer memory. During each execution of the test scenario, the terminal obtains memory information of the Java layer memory based on the Java layer memory and uses the memory information of the Java layer memory as the second memory information, that is, the second memory information is the second Java layer memory information.

[0140] In this step, the terminal obtains sample labels of the test scenario respectively according to the second memory information including memory information of multiple memory types.

[0141] In an embodiment of the present disclosure, the terminal obtains different types of memory information based on different types of second memory information to obtain second memory information and sample labels, and then uses the second memory information and sample labels as model input to improve the accuracy of model training.

[0142] In step 303, the terminal obtains a model data set based on the multiple pieces of second memory information and the sample label.

[0143] Wherein, step 303 is implemented by steps 3031-3033:

[0144] In step 3031, the terminal determines the memory data in the multiple second memory information based on the data sliding window.

[0145] In some embodiments, when the terminal is running the test scenario, as time goes by, the memory usage information of the application to be tested will fluctuate slightly, so the multiple second memory information corresponding to the same test scenario are not completely the same, and there are noise data in the multiple second memory information. At the end of the test scenario, as time goes by, the memory usage information of the application to be tested will have a downward trend. Therefore, the terminal sets a data sliding window in advance.

[0146] In this step, the terminal intercepts the second memory information for each second memory information based on the data sliding window to obtain memory data, wherein the sampling duration corresponding to the memory data is equal to the length of the data sliding window. The memory data is the memory information in which the difference between the memory occupancy values ​​at adjacent sampling moments in the second memory information is less than a preset value. The length of the data sliding window is less than the minimum value of the length of memory information of different memory types in each second memory information. The size of the preset value can be set according to user needs, and the embodiment of the present disclosure does not limit this.

[0147] For example, if the data sliding window is window, the sampling duration len(window) is 2s. The terminal intercepts the memory data with a sampling duration of 2s, and the obtained multiple memory data are x_a0', x_a1', x_a2', x_a3' and x_a4'.

[0148] In step 3032, the terminal concatenates the memory data to generate sample memory data.

[0149] For example, the terminal obtains multiple memory data x_a0', x_a1', x_a2', x_a3' and x_a4', then the terminal concatenates the multiple memory data generated by the same test scenario to obtain sample memory data corresponding to the same test scenario, which is X_A'.

[0150] In this step, the terminal connects the multiple memory data in series in the following manner: the terminal connects the multiple memory data in series according to the order in which the multiple memory data are obtained. For example, the second memory information obtained after the first test scenario is run is x_a0, the second memory information obtained after the second test scenario is run is x_a1, and the second memory information obtained after the third test scenario is run is x_a2. The three memory data intercepted are x_a0', x_a1', and x_a2'. Then the three memory data are connected in series according to the order in which they are obtained to obtain the sample memory data X_A'.

[0151] In step 3033, the terminal generates the model data set based on the sample memory data and the sample label.

[0152] The terminal combines sample memory data and sample tags corresponding to the same test scenario into first model data. In response to the number of test scenarios being multiple, the terminal determines multiple first model data and combines the multiple first model data into the model data set.

[0153] In an embodiment of the present disclosure, the terminal connects multiple groups of memory data corresponding to the same test scenario by connecting the memory data obtained after intercepting multiple second memory information in series, and combines the memory data with the sample labels of the test scenario to obtain multiple model data sets, thereby improving the stability of the model data set.

[0154] In step 304, the terminal generates a training set and a test set based on the model data set.

[0155] In some embodiments, the terminal divides the model data set into a training set and a test set according to a preset ratio. The preset ratio is the ratio of the number of samples in the training set to the number of samples in the test set. For example, if the preset ratio is 4:1, 80% of the model data set is used as a training set and 30% of the model data set is used as a test set. The size of the preset ratio can be set according to user needs, and the embodiments of the present disclosure are not limited to this.

[0156] In some embodiments, the terminal divides sample memory information of different target memory types into training data and test data according to the target memory type, for example, Java layer memory training data, Java layer memory test data, native layer memory training data, and native layer memory test data.

[0157] In the embodiment of the present disclosure, the terminal divides multiple model data sets into training sets and test sets, so that the initial memory detection model obtains characteristic values ​​of multiple sample information based on the training sets and the test sets, adjusts the parameters of the model, and then obtains the optimal model parameters to improve the training accuracy of the initial memory detection model.

[0158] In step 305, the terminal trains an initial memory detection model based on the training set.

[0159] The terminal inputs the training set into the initial memory detection model, trains the initial memory detection model, obtains the trained initial memory detection model, and then tests the trained initial memory detection model. In some embodiments, the trained initial memory detection model can calculate the extracted features based on the model parameters to obtain a predicted sample label.

[0160] For example, the trained initial memory detection model can be a neural network, and the trained initial memory detection model can extract the features of the training set and the features of the sample label, and the neural network can calculate the features of the two based on the network parameters to obtain the sample label. Among them, the type of the trained initial memory detection model can be set according to user needs, and the embodiments of the present disclosure do not limit this.

[0161] In some embodiments, the initial memory detection model can be stored in the terminal and can be called when the terminal needs to perform model training. The initial memory detection model can also be stored in the server, and the terminal can call the initial memory detection model from the server. The model parameters in the initial memory detection model are initial values. The initial memory detection model has not been trained with the second memory information. The result obtained when the initial memory detection model is used to detect memory leaks of the second memory information may be inaccurate. Therefore, the initial memory detection model needs to be trained with the second memory information obtained in the above step 302.

[0162] In some embodiments, the terminal trains the initial memory detection model based on the target memory type, and can train to obtain a trained initial memory detection model corresponding to each target memory type, for example, a trained Java layer initial memory detection model and a trained native layer initial memory detection model.

[0163] In step 306, the terminal tests the trained initial memory detection model based on the test set.

[0164] In this step, the terminal inputs the test set into the trained initial memory detection model, tests the trained initial memory detection model, and obtains the tested initial memory detection model.

[0165] In some embodiments, the terminal tests the trained initial memory detection model based on the target memory type to obtain a tested initial memory detection model corresponding to each target memory type, for example, a tested Java layer initial memory detection model and a tested native layer initial memory detection model.

[0166] In step 307, the terminal determines the memory detection model based on the tested initial memory detection model.

[0167] In some embodiments, the terminal updates the algorithm model parameters of the initial memory detection model in response to the initial memory detection model being trained and tested multiple times based on the training set and the test set. In the training process of step 305 and the testing process of step 306, the initial memory detection model updates the algorithm model parameters based on the error between the predicted sample label and the real sample label until the target condition is met, stops updating, and obtains the initial memory detection model after the updated parameters, and the real sample label is the sample label in the training set.

[0168] In this step, the terminal trains the initial memory detection model after updating parameters based on the model data set to obtain the memory detection model.

[0169] In some embodiments, the terminal updates the algorithm model parameters of the initial memory detection model after the test based on the target memory type, and obtains the initial memory detection model after the updated parameters corresponding to each target memory type, for example, the Java layer initial memory detection model after the updated parameters, and the native layer initial memory detection model after the updated parameters.

[0170] In the disclosed embodiment, the first memory information generated by the running scenario is obtained and the model detection result is determined with the help of a memory detection model. Since the memory detection model learns the relationship between the memory information and the detection result of the memory leak during the training process, the detection result of the running scenario can be determined based on the model prediction result. There is no need to repeatedly trigger the running scenario to determine the detection result, which shortens the time for determining the detection result of the memory leak and improves the detection efficiency of the memory leak.

[0171] Figure 4 is a flowchart of a method for detecting a memory leak according to an exemplary embodiment. Figure 3 As shown, in the embodiment of the present disclosure, taking the first memory information detection based on the memory detection model as an example for description, the memory leak detection method is used in the terminal, and includes the following steps:

[0172] In step 401, the terminal obtains first memory information generated by the running scenario.

[0173] The running scenario is a scenario corresponding to a testable function in the application to be detected. The application to be detected is installed in an Android system, and the type of the application to be detected is the same or different from that of the application to be tested, which is not limited in this application. The first memory information is the memory occupancy information generated by the running scenario during operation.

[0174] In this step, the terminal obtains first memory information including multiple memory types, or, based on the target memory type, obtains first memory information corresponding to the target memory type.

[0175] In some embodiments, the terminal determines a plurality of preset memory types, and in the process of running the running scenario, obtains memory information of each memory type based on the plurality of memory types, and combines the memory information of each memory type into the first memory information.

[0176] In other embodiments, the terminal determines a target memory type to be detected, obtains memory information of the target memory type based on the target memory type, and uses the memory information of the target memory type as the first memory information.

[0177] For example, the terminal determines that the target memory type is a native layer memory, obtains memory information of the native layer memory, and uses the native layer memory information as the first memory information.

[0178] In some embodiments, the terminal obtains the first memory information generated by the running scenario according to an ADB command.

[0179] In step 402, the terminal obtains a first prediction result of the running scenario based on the first memory information and the memory detection model, wherein the first prediction result includes whether a memory leak exists in the running scenario or whether there is no memory leak in the running scenario.

[0180] In this step, the terminal inputs the first memory information into the memory detection model, and the memory detection model extracts features of the first memory information, and determines a first prediction result corresponding to the operating scenario based on the extracted features of the first memory information.

[0181] The terminal needs to first determine the memory detection model, which can be obtained by training in the above steps 301-307; and from the above steps 301-307, it can be known that the terminal can obtain the memory detection model through two types of second memory information training, that is, the memory detection model is trained based on the second memory information corresponding to the target memory type, or is trained based on the second memory information corresponding to multiple memory types. In some embodiments, the step of the terminal determining the memory detection model includes:

[0182] In response to the first memory information including memory information of multiple memory types, the terminal determines that the memory detection model is a memory detection model trained by the second memory information including multiple memory types; in response to the first memory information including memory information of a target memory type, the terminal determines a memory detection model corresponding to the target memory type based on the target memory type. For example, if the target memory type is a native layer memory, the terminal determines a native layer memory detection model.

[0183] In step 403, the terminal determines the model prediction result based on the first prediction result.

[0184] In some embodiments, the terminal determines the leakage probability of the running scenario in response to the first prediction result that the running scenario has a memory leak. The terminal determines that the model prediction result is that the running scenario has a leak and a leakage probability.

[0185] The memory detection model determines the probability of the model output based on the extracted features of the first memory information, and the terminal uses the probability of the model output as the leakage probability.

[0186] In other embodiments, the terminal determines that the model prediction result is that there is no leak in the running scenario in response to the first prediction result being that there is no memory leak in the running scenario.

[0187] In some embodiments, the terminal determines the model prediction result based on the target memory type and the first prediction result. For example, if the target memory type is native layer memory and the first prediction result is that there is no memory leak in the running scenario, the terminal determines that the model prediction result is that there is no memory leak in the native layer memory in the running scenario.

[0188] In step 404, the terminal determines the detection result of the operation scenario based on the prediction result of the model.

[0189] In some embodiments, the terminal determines that the detection result is that there is a memory leak and a leakage probability in the operation scenario in response to the leakage probability being greater than the probability threshold. For example, if the probability threshold is 60%, the leakage probability is P, and P is 70%, then 70%>60%, and the terminal determines that the detection result is that there is a leakage and 70% in the operation scenario. Among them, the type of probability can be set according to user needs, for example, percentage, fraction, decimal, etc., and the value of the probability threshold can be set according to user needs, and this application does not limit this.

[0190] In other embodiments, in response to the leakage probability being not greater than the probability threshold, the terminal triggers the re-execution of the running scenario and updates the first memory information.

[0191] The terminal triggers the running scenario to re-run according to a preset update number, and updates the first memory information. The update number can be set according to user needs, for example, the update number is 5, and this application does not make specific restrictions on this. The terminal re-executes the operations of steps 402-404 according to the updated first memory information and the memory detection model.

[0192] In other embodiments, the terminal determines that the detection result is that there is no memory leak in the running scenario in response to the model prediction result that there is no leak in the running scenario.

[0193] When the model prediction result is that there is no leakage in the running scenario, the terminal determines that the detection result is that there is no memory leak in the running scenario.

[0194] In some embodiments, the terminal determines the detection result of the operating scenario based on the target memory type and the model prediction result.

[0195] In the disclosed embodiment, the terminal obtains the detection result of the memory leak of the running scenario by inputting the first memory information into the memory detection model, such as no memory leak, or there is a memory leak and the leakage probability is P, so that the terminal does not need to trigger the running scenario again, and can know the memory leak of the application to be detected according to the leakage probability, saving the running time of the terminal. And the terminal obtains the memory information of the target memory type according to different memory types to obtain the first memory information, and inputs the first memory information into the corresponding memory detection model to obtain the detection result, so that the terminal outputs the detection results corresponding to the memory information of different memory types, refines the types of memory leak detection, and improves the accuracy of memory leak detection.

[0196] Figure 5 is a block diagram of a memory leak detection device according to an exemplary embodiment. Figure 5 The device 500 includes a first acquisition unit 501, a first determination unit 502 and a second determination unit 503.

[0197] The first acquisition unit 501 is configured to execute acquisition of first memory information generated by the running scenario;

[0198] A first determining unit 502 is configured to determine a model prediction result of the memory detection model based on the first memory information and the memory detection model;

[0199] The second determination unit 503 is configured to execute based on the prediction result of the model to determine the detection result of the operation scenario; wherein the memory detection model is determined based on the training of the model data set, and the model data set includes memory data preprocessed based on the sliding window.

[0200] In some embodiments, the first determining unit 502 includes:

[0201] A first acquisition subunit acquires a first prediction result of the running scenario based on the first memory information and a memory detection model, wherein the first prediction result includes whether a memory leak exists in the running scenario or whether there is no memory leak in the running scenario;

[0202] The first determining subunit determines the model prediction result based on the first prediction result.

[0203] In some embodiments, the first determination subunit is configured to execute, in response to the first prediction result being that there is a memory leak in the operation scenario, determining the leakage probability of the operation scenario; and determining that the model prediction result is that there is a leak and the leakage probability in the operation scenario.

[0204] In some embodiments, the first determination subunit is configured to execute, in response to the leakage probability being greater than a probability threshold, determine that the detection result is that there is a memory leak and a leakage probability in the running scenario; in response to the leakage probability being not greater than the probability threshold, trigger the running scenario to re-run and update the first memory information.

[0205] In some embodiments, the first determination subunit is configured to execute, in response to the first prediction result being that there is no memory leak in the operating scenario, determining that the model prediction result is that there is no leak in the operating scenario; and determining that the detection result is that there is no memory leak in the operating scenario.

[0206] In the disclosed embodiment, the first memory information generated by the running scenario is obtained and the model detection result is determined with the help of a memory detection model. Since the memory detection model learns the relationship between the memory information and the detection result of the memory leak during the training process, the detection result of the running scenario can be determined based on the model prediction result. There is no need to repeatedly trigger the running scenario to determine the detection result, which shortens the time for determining the detection result of the memory leak and improves the detection efficiency of the memory leak.

[0207] Figure 6 is a block diagram of a training device for a memory detection model according to an exemplary embodiment. Figure 6 The device 600 includes an operating unit 601, a second acquiring unit 602, a third acquiring unit 603 and a third determining unit 604.

[0208] The running unit 601 is configured to execute the automatic triggering test scenario loop running;

[0209] The second acquisition unit 602 is configured to execute acquisition of a plurality of second memory information generated during multiple runs of the test scenario and a sample mark of the test scenario;

[0210] A third acquisition unit 603 is configured to acquire a model data set based on the plurality of second memory information and the sample mark;

[0211] The third determination unit 604 is configured to perform training to determine the memory detection model based on the model data set.

[0212] In some embodiments, the third acquisition unit 603 includes:

[0213] A second determining subunit is configured to determine the memory data in the plurality of second memory information based on the data sliding window;

[0214] A series connection subunit is configured to execute series connection of the memory data to generate sample memory data;

[0215] The first generating subunit is configured to generate the model data set based on the sample memory data and the sample label.

[0216] In some embodiments, the third determining unit 604 includes:

[0217] A second generating subunit is configured to generate a training set and a test set based on the model data set;

[0218] A training subunit is configured to train an initial memory detection model based on the training set;

[0219] The testing subunit is configured to execute the test based on the test set to test the trained initial memory detection model;

[0220] The third determining subunit is configured to execute the initial memory detection model based on the test to determine the memory detection model.

[0221] In some embodiments, the third determination subunit is configured to execute, in response to multiple trainings and multiple tests of the initial memory detection model based on the training set and the test set, updating the algorithm model parameters of the initial memory detection model; based on the model data set, training the initial memory detection model after the updated parameters to obtain the memory detection model.

[0222] In some embodiments, the sample is marked as a memory leak result of the test scenario, wherein the memory leak result includes whether a memory leak exists in the test scenario or whether a memory leak does not exist in the test scenario.

[0223] In some embodiments, the second determination subunit is configured to execute, for each second memory information, intercepting the second memory information based on the data sliding window to obtain memory data, wherein the sampling duration corresponding to the memory data is equal to the length of the data sliding window.

[0224] In the disclosed embodiment, the first memory information generated by the running scenario is obtained and the model detection result is determined with the help of a memory detection model. Since the memory detection model learns the relationship between the memory information and the detection result of the memory leak during the training process, the detection result of the running scenario can be determined based on the model prediction result. There is no need to repeatedly trigger the running scenario to determine the detection result, which shortens the time for determining the detection result of the memory leak and improves the detection efficiency of the memory leak.

[0225] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0226] Figure 7 The structure block diagram of a terminal 700 provided by an exemplary embodiment of the present disclosure is shown. In some embodiments, the terminal 700 may be: a smart phone, a tablet computer, a notebook computer or a desktop computer, etc. The terminal 700 may also be called a user equipment, a portable terminal, a laptop terminal, a desktop terminal, etc.

[0227] Typically, the terminal 700 includes a processor 701 and a memory 702 .

[0228] In some embodiments, the processor 701 includes one or more processing cores, such as a 4-core processor, an 8-core processor, etc. In some embodiments, the processor 701 is implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). In some embodiments, the processor 701 also includes a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 701 is integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 701 also includes an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0229] In some embodiments, the memory 702 includes one or more computer-readable storage media, which are non-transitory. In some embodiments, the memory 702 also includes a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 702 is used to store at least one instruction, which is used to be executed by the processor 701 to implement the memory leak detection method provided by the method embodiment of the present disclosure.

[0230] In some embodiments, the terminal 700 may further optionally include: a peripheral device interface 703 and at least one peripheral device. In some embodiments, the processor 701, the memory 702 and the peripheral device interface 703 are connected via a bus or a signal line. In some embodiments, each peripheral device is connected to the peripheral device interface 703 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 704, a display screen 705, a camera assembly 706, an audio circuit 707, a positioning assembly 708 and a power supply 709.

[0231] The peripheral device interface 703 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 701 and the memory 702. In some embodiments, the processor 701, the memory 702, and the peripheral device interface 703 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 701, the memory 702, and the peripheral device interface 703 are implemented on a separate chip or circuit board, which is not limited in this embodiment.

[0232] The radio frequency circuit 704 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 704 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 704 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. In some embodiments, the radio frequency circuit 704 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. In some embodiments, the radio frequency circuit 704 communicates with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 704 also includes circuits related to NFC (Near Field Communication), which is not limited in the present disclosure.

[0233] The display screen 705 is used to display a UI (User Interface). In some embodiments, the UI includes graphics, text, icons, videos, and any combination thereof. When the display screen 705 is a touch display screen, the display screen 705 also has the ability to collect touch signals on the surface or above the surface of the display screen 705. In some embodiments, the touch signal is input to the processor 701 as a control signal for processing. At this time, the display screen 705 is also used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 705 is one, which is arranged on the front panel of the terminal 700; in other embodiments, the display screen 705 is at least two, which are arranged on different surfaces of the terminal 700 or are folded; in other embodiments, the display screen 705 is a flexible display screen, which is arranged on a curved surface or a folded surface of the terminal 700. Even, the display screen 705 is also arranged in a non-rectangular irregular shape, that is, a special-shaped screen. In some embodiments, the display screen 705 is made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode, organic light-emitting diode).

[0234] The camera assembly 706 is used to capture images or videos. In some embodiments, the camera assembly 706 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and the VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 706 also includes a flash. In some embodiments, the flash is a monochrome temperature flash, and in some embodiments, the flash is a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which is used for light compensation at different color temperatures.

[0235] In some embodiments, the audio circuit 707 includes a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 701 for processing, or input them into the radio frequency circuit 704 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, in some embodiments, there are multiple microphones, which are respectively arranged at different parts of the terminal 700. In some embodiments, the microphone is an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 701 or the radio frequency circuit 704 into sound waves. In some embodiments, the speaker is a traditional film speaker, and in some embodiments, the speaker is a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 707 also includes a headphone jack.

[0236] Positioning component 708 is used to locate the current geographical location of terminal 700 to implement navigation or LBS (Location Based Service). In some embodiments, positioning component 708 is a positioning component based on the US GPS (Global Positioning System), China's Beidou system or Russia's Galileo system.

[0237] The power supply 709 is used to power various components in the terminal 700. In some embodiments, the power supply 709 is an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 709 includes a rechargeable battery, the rechargeable battery is a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery is also used to support fast charging technology.

[0238] In some embodiments, the terminal 700 further includes one or more sensors 710 , including but not limited to: an acceleration sensor 711 , a gyroscope sensor 77 , a pressure sensor 713 , a fingerprint sensor 714 , an optical sensor 715 , and a proximity sensor 716 .

[0239] In some embodiments, the acceleration sensor 711 detects the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 700. For example, the acceleration sensor 711 is used to detect the components of gravity acceleration on the three coordinate axes. In some embodiments, the processor 701 controls the display screen 705 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 711. In some embodiments, the acceleration sensor 711 is also used for collecting motion data of games or users.

[0240] In some embodiments, the gyroscope sensor 712 detects the body direction and rotation angle of the terminal 700, and the gyroscope sensor 712 cooperates with the acceleration sensor 711 to collect the user's 3D actions on the terminal 700. The processor 701 can implement the following functions based on the data collected by the gyroscope sensor 712: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0241] In some embodiments, the pressure sensor 713 is disposed on the side frame of the terminal 700 and / or the lower layer of the display screen 705. When the pressure sensor 713 is disposed on the side frame of the terminal 700, it is capable of detecting the user's holding signal of the terminal 700, and the processor 701 performs left and right hand recognition or shortcut operations according to the holding signal collected by the pressure sensor 713. When the pressure sensor 713 is disposed on the lower layer of the display screen 705, the processor 701 controls the operability controls on the UI interface according to the user's pressure operation on the display screen 705. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0242] The fingerprint sensor 714 is used to collect the user's fingerprint, and the processor 701 identifies the user's identity based on the fingerprint collected by the fingerprint sensor 714, or the fingerprint sensor 714 identifies the user's identity based on the collected fingerprint. When the user's identity is identified as a trusted identity, the processor 701 authorizes the user to perform relevant sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings. In some embodiments, the fingerprint sensor 714 is set on the front, back, or side of the terminal 700. When a physical button or a manufacturer logo is set on the terminal 700, the fingerprint sensor 714 is integrated with the physical button or the manufacturer logo.

[0243] The optical sensor 715 is used to collect the ambient light intensity. In one embodiment, the processor 701 controls the display brightness of the display screen 705 according to the ambient light intensity collected by the optical sensor 715. Specifically, when the ambient light intensity is high, the display brightness of the display screen 705 is increased; when the ambient light intensity is low, the display brightness of the display screen 705 is decreased. In another embodiment, the processor 701 also dynamically adjusts the shooting parameters of the camera assembly 706 according to the ambient light intensity collected by the optical sensor 715.

[0244] The proximity sensor 716, also called a distance sensor, is usually arranged on the front panel of the terminal 700. The proximity sensor 716 is used to collect the distance between the user and the front of the terminal 700. In one embodiment, when the proximity sensor 716 detects that the distance between the user and the front of the terminal 700 is gradually decreasing, the processor 701 controls the display screen 705 to switch from the screen-on state to the screen-off state; when the proximity sensor 716 detects that the distance between the user and the front of the terminal 700 is gradually increasing, the processor 701 controls the display screen 705 to switch from the screen-off state to the screen-on state.

[0245] Those skilled in the art will understand that Figure 7 The structure shown in the figure does not constitute a limitation on the terminal 700, and the terminal 700 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0246] In an exemplary embodiment, a computer-readable storage medium is also provided, which stores instructions. When the instructions in the storage medium are executed by a processor of a terminal, the terminal is enabled to execute the memory leak detection method and the memory detection model training method in the above-mentioned embodiments.

[0247] In an exemplary embodiment, a computer program product is also provided. When the instructions in the computer program product are executed by a processor of a terminal, the terminal is enabled to execute the memory leak detection method and the memory detection model training method in the above-mentioned embodiments.

[0248] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0249] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A memory leak detection method, characterized in that: include: Obtain the first memory information generated by the running scene; Determine a model prediction result of the memory detection model based on the first memory information and the memory detection model; When the model prediction result is that there is a leak and a leak probability in the running scenario, in response to the leak probability being greater than a probability threshold, determining that the detection result of the running scenario is that there is a memory leak and a leak probability in the running scenario; in response to the leak probability being not greater than the probability threshold, triggering the running scenario to re-run, and updating the first memory information; The memory detection model is determined based on training of a model data set, the model data set is obtained based on a plurality of second memory information generated in multiple runs of a test scenario and sample labels of the test scenario, and the model data set includes memory data intercepted from the second memory information based on a sliding window; When the second memory information changes with time and the length of the memory data included in the second memory information reaches a first threshold, the sample is marked as having a memory leak in the test scenario; when the second memory information changes with time and the length of the memory data included in the second memory information does not reach the first threshold, the sample is marked as having no memory leak in the test scenario.

2. The detection method according to claim 1, characterized in that: The determining, based on the first memory information and the memory detection model, a model prediction result of the memory detection model includes: Based on the first memory information and the memory detection model, obtaining a first prediction result of the running scenario, wherein the first prediction result includes whether a memory leak exists in the running scenario or whether there is no memory leak in the running scenario; Based on the first prediction result, the model prediction result is determined.

3. The detection method according to claim 2, characterized in that: Determining the model prediction result based on the first prediction result includes: In response to the first prediction result indicating that there is a memory leak in the operating scenario, determining a leakage probability of the operating scenario; Determine that the model prediction result is the existence of leakage and leakage probability in the operating scenario.

4. The detection method according to claim 2, characterized in that: The method further comprises: In response to the first prediction result being that there is no memory leak in the running scenario, determining that the model prediction result is that there is no leak in the running scenario; It is determined that the detection result is that there is no memory leak in the running scenario.

5. A method for training a memory detection model, characterized in that: The memory detection model is a memory detection model used when determining the detection result of the running scenario in the memory leak detection method according to any one of claims 1 to 4, and the training method comprises: Automatically trigger the test scenario to run in a loop; Acquire a plurality of second memory information generated during multiple runs of the test scenario and sample marks of the test scenario; Based on the plurality of second memory information and the sample labels, acquiring a model data set; Based on the model data set, the memory detection model is trained and determined.

6. The method according to claim 5, characterized in that The acquiring the model data set based on the plurality of second memory information and the sample labels comprises: Based on the data sliding window, determine the memory data in the plurality of second memory information; Concatenate the memory data to generate sample memory data; The model data set is generated based on the sample memory data and the sample labels.

7. The training method according to claim 5, characterized in that: The training and determining the memory detection model based on the model data set includes: Based on the model data set, generate a training set and a test set; training an initial memory detection model based on the training set; Based on the test set, testing the trained initial memory detection model; Based on the initial memory detection model after the test, the memory detection model is determined.

8. The training method according to claim 7, characterized in that: The determining of the memory detection model based on the initial memory detection model after the test includes: In response to the initial memory detection model being trained and tested multiple times based on the training set and the test set, updating the algorithm model parameters of the initial memory detection model; Based on the model data set, the initial memory detection model after updating the parameters is trained to obtain the memory detection model.

9. The training method according to claim 6, characterized in that: The determining, based on the data sliding window, the memory data in the plurality of second memory information comprises: For each second memory information, based on the data sliding window, the second memory information is intercepted to obtain the memory data, wherein the sampling duration corresponding to the memory data is equal to the length of the data sliding window.

10. A memory leak detection device, characterized in that: include: A first acquisition unit is configured to execute acquisition of first memory information generated by the running scenario; A first determining unit is configured to determine a model prediction result of the memory detection model based on the first memory information and the memory detection model; A second determining unit is configured to execute, when the model prediction result is that there is a leak and a leak probability in the running scenario, in response to the leak probability being greater than a probability threshold, determining that the detection result of the running scenario is that there is a memory leak and a leak probability in the running scenario; in response to the leak probability being not greater than the probability threshold, triggering the running scenario to re-run, and updating the first memory information; The memory detection model is determined based on training of a model data set, the model data set is obtained based on a plurality of second memory information generated in multiple runs of a test scenario and sample labels of the test scenario, and the model data set includes memory data intercepted from the second memory information based on a sliding window; When the second memory information changes with time and the length of the memory data included in the second memory information reaches a first threshold, the sample is marked as having a memory leak in the test scenario; when the second memory information changes with time and the length of the memory data included in the second memory information does not reach the first threshold, the sample is marked as having no memory leak in the test scenario.

11. The detection device according to claim 10, characterized in that: The first determining unit includes: A first acquisition subunit is configured to acquire a first prediction result of the operation scenario based on the first memory information and the memory detection model, wherein the first prediction result includes whether there is a memory leak in the operation scenario or whether there is no memory leak in the operation scenario; The first determining subunit is configured to determine the model prediction result based on the first prediction result.

12. The detection device according to claim 11, characterized in that: The first determination subunit is configured to execute, in response to the first prediction result being that there is a memory leak in the operation scenario, determining the leakage probability of the operation scenario; and determining that the model prediction result is that there is a leakage and the leakage probability in the operation scenario.

13. The detection device according to claim 11, characterized in that: The second determination unit is configured to execute, in response to the first prediction result being that there is no memory leak in the running scenario, determining that the model prediction result is that there is no leak in the running scenario; and determining that the detection result is that there is no memory leak in the running scenario.

14. A training device for a memory detection model, characterized in that: The memory detection model is a memory detection model used when determining the detection result of the running scenario in the memory leak detection method according to any one of claims 1 to 4, and the training device comprises: A running unit, configured to execute a loop of automatically triggered test scenarios; A second acquisition unit is configured to execute acquisition of a plurality of second memory information generated during multiple runs of the test scenario and sample marks of the test scenario; A third acquisition unit is configured to acquire a model data set based on the plurality of second memory information and the sample tags; The third determination unit is configured to perform training to determine the memory detection model based on the model data set.

15. The device according to claim 14, characterized in that The third acquisition unit includes: A second determining subunit is configured to determine the memory data in the plurality of second memory information based on the data sliding window; A series connection subunit, configured to execute series connection of the memory data to generate sample memory data; The first generating subunit is configured to generate the model data set based on the sample memory data and the sample label.

16. The training device according to claim 14, characterized in that The third determining unit includes: A second generating subunit is configured to generate a training set and a test set based on the model data set; A training subunit, configured to train an initial memory detection model based on the training set; A testing subunit, configured to execute a test based on the test set to test the trained initial memory detection model; The third determining subunit is configured to execute the memory detection model based on the initial memory detection model after the test.

17. The training device according to claim 16, characterized in that The third determination subunit is configured to execute, in response to the initial memory detection model being trained multiple times and tested multiple times based on the training set and the test set, updating the algorithm model parameters of the initial memory detection model; Based on the model data set, the initial memory detection model after updating the parameters is trained to obtain the memory detection model.

18. The training device according to claim 15, characterized in that The second determination subunit is configured to execute, for each second memory information, intercepting the second memory information based on the data sliding window to obtain the memory data, wherein a sampling duration corresponding to the memory data is equal to a length of the data sliding window.

19. A terminal, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the memory leak detection method as described in any one of claims 1 to 4 or the memory detection model training method as described in any one of claims 5 to 9.

20. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by the processor of the terminal, the terminal is enabled to execute the memory leak detection method as described in any one of claims 1 to 4 or the memory detection model training method as described in any one of claims 5 to 9.

21. A computer program product, characterized in that When the instructions in the computer program product are executed by the processor of the terminal, the terminal is enabled to execute the memory leak detection method as described in any one of claims 1 to 4 or the memory detection model training method as described in any one of claims 5 to 9.

Citation Information

Patent Citations

  • Method for intelligently detecting C program memory leakage based on machine learning

    CN108804332A