Memory management method and device, equipment and storage medium

By monitoring and matching memory change data in real time, identifying consistency exceptions and processing, the lag problem caused by the application memory reaching the virtual machine heap limit is solved, and the stable operation of the application is achieved.

CN120256324APending Publication Date: 2025-07-04VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510318399.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-17
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

As the time when the application is not cleaned up is extended, the application memory size continues to increase, which is easy to reach the virtual machine heap memory limit, resulting in response failures such as application lag or stuck.

Method used

By monitoring the application memory size in real time, recording memory change data, and matching it with the memory exception behavior library, determining consistent exception data, and performing target processing in a timely manner, such as releasing memory or ending process, to reduce the risk of memory reaching limits.

Benefits of technology

Effectively manage application memory, reduce the risk of response failures caused by the memory reaching the virtual machine heap memory limit, and ensure the stable operation of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120256324A_ABST
    Figure CN120256324A_ABST
Patent Text Reader

Abstract

The invention discloses a memory management method and device, equipment and a storage medium, and belongs to the field of electronic equipment. The method comprises the steps of recording application memory change data of an application program based on an obtained application memory size; under the condition that the application memory size is larger than or equal to a memory threshold value, matching the application memory change data with a memory abnormal behavior library, and determining first memory abnormal data; wherein the memory threshold value is smaller than a virtual machine heap memory limit, the memory abnormal behavior library comprises a plurality of memory abnormal data, and the memory abnormal data represents application memory change data of which the application memory size reaches the virtual machine heap memory limit; the first memory exception data is memory exception data meeting a consistency condition with the application memory change data in the multiple pieces of memory exception data; and performing target processing on the application program according to the application memory size and the first memory abnormal data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of electronic devices, and particularly relates to a memory management method, apparatus, device, and storage medium. Background Art

[0002] With the continuous development of electronic devices, the system memory hardware of electronic devices has entered the era of large memory, and the time for application programs not to be cleared is getting longer and longer. However, as the time for application programs not to be cleared becomes longer and longer, the application memory size of the application programs will also become larger and larger, and there are response failures such as lags and freezes in the application programs when the application memory size reaches the virtual machine heap memory limit. Summary of the Invention

[0003] The purpose of the embodiments of this application is to provide a memory management method, apparatus, device, and storage medium, which can manage the application memory in a timely and effective manner and reduce the risk of response failures in application programs.

[0004] In a first aspect, the embodiments of this application provide a memory management method, which includes:

[0005] Based on the obtained application memory size, record the application memory change data of the application program;

[0006] When the application memory size is greater than or equal to the memory threshold, match the application memory change data with the memory abnormal behavior library to determine the first memory abnormal data; wherein, the memory threshold is less than the virtual machine heap memory limit, the memory abnormal behavior library includes multiple memory abnormal data, the memory abnormal data represents the application memory change data when the application memory size reaches the virtual machine heap memory limit, and the first memory abnormal data is any memory abnormal data that satisfies the consistency condition with the application memory change data among the multiple memory abnormal data;

[0007] Perform target processing on the application program according to the application memory size and the first memory abnormal data.

[0008] In a second aspect, the embodiments of this application provide a memory management apparatus, which includes:

[0009] A recording module, configured to record the application memory change data of the application program based on the obtained application memory size;

[0010] A matching module, configured to match the application memory change data with a memory abnormal behavior library when the application memory size is greater than or equal to a memory threshold, so as to determine first memory abnormal data; wherein, the memory threshold is less than the virtual machine heap memory limit, the memory abnormal behavior library includes multiple memory abnormal data, the memory abnormal data represents the application memory change data when the application memory size reaches the virtual machine heap memory limit, and the first memory abnormal data is any one of the multiple memory abnormal data that meets the consistency condition with the application memory change data;

[0011] A processing module, configured to perform target processing on the application program according to the application memory size and the first memory abnormal data.

[0012] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory. The memory stores a program or instruction that can be run on the processor. When the program or instruction is executed by the processor, the steps of the method described in the first aspect are implemented.

[0013] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0014] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor, and the processor is configured to run a program or instruction to implement the method described in the first aspect.

[0015] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.

[0016] In the embodiments of the present application, application memory change data with the final application memory size reaching the virtual machine heap memory limit can be stored in the memory exception behavior library as memory exception data. On this basis, the application memory size of the application program can be obtained in real time and recorded to obtain the application memory change data of the application program. When the application memory size is greater than or equal to the memory threshold, it can be considered that there is a possibility that the application memory size reaches the virtual machine heap memory limit. Based on this, the application memory change data can be matched with the memory exception behavior library to determine the first memory exception data that is consistent with the application memory change data, that is, the situation where the application memory size in the application memory change data reaches the virtual machine heap memory limit can be predicted according to the first memory exception data, so that the application program can be targeted processed in time to reduce the application memory size of the application program. In this way, the application memory can be managed in a timely and effective manner, and the risk of response failure of the application program caused by the application memory size reaching the virtual machine heap memory limit can be reduced. Description of the Drawings

[0017] Figure 1 is a schematic flowchart of the memory management method provided by the embodiments of the present application;

[0018] Figure 2 is a schematic software implementation diagram of target processing of an application program in the memory management method provided by the embodiments of the present application;

[0019] Figure 3a is a schematic diagram of application memory change data in the memory management method provided by the embodiments of the present application;

[0020] Figure 3b is one of the schematic diagrams of memory exception data in the memory management method provided by the embodiments of the present application;

[0021] Figure 3c is another schematic diagram of memory exception data in the memory management method provided by the embodiments of the present application;

[0022] Figure 4 is a schematic flowchart of a scenario implementation example of the memory management method provided by the embodiments of the present application;

[0023] Figure 5 is a schematic structural diagram of the memory management device provided by the embodiments of the present application;

[0024] Figure 6 is a schematic structural diagram of the electronic device provided by the embodiments of the present application;

[0025] Figure 7 is a schematic hardware structural diagram of the electronic device provided by the embodiments of the present application. Detailed Embodiments

[0026] Next, the technical solutions in the embodiments of the present application will be clearly described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art belong to the scope of protection of the present application.

[0027] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such terms can be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same category, and the number of objects is not limited. For example, the first object can be one or multiple. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally means that the associated objects before and after are in an "or" relationship.

[0028] Next, in conjunction with the accompanying drawings, the memory management method provided in the embodiments of the present application will be described in detail through specific embodiments and their application scenarios.

[0029] Figure 1 It is a flowchart of the memory management method provided in the embodiments of the present application. The memory management method may include:

[0030] Step 101, based on the obtained application memory size, record the application memory change data of the application program.

[0031] In step 101, the application memory may represent the memory resources occupied by the application process when the application program is running. It can be understood that when the application program is running continuously, if the application program interacts with the user in the foreground, its application memory size is continuously increasing. In this process, the application memory size can be monitored in real time, and based on the obtained application memory size, the application memory change data of the application program can be recorded. Among them, the application memory change data may refer to the application memory change data to be managed, and the application memory change data may include multiple application memory sizes corresponding to the application program and the application running time.

[0032] Step 102, when the application memory size is greater than or equal to the memory threshold, match the application memory change data with the memory exception behavior library to determine the first memory exception data; wherein, the memory threshold is less than the virtual machine heap memory limit, the memory exception behavior library includes multiple memory exception data, the memory exception data represents the application memory change data when the application memory size reaches the virtual machine heap memory limit, and the first memory exception data is any memory exception data in the multiple memory exception data whose consistency with the application memory change data meets the consistency condition.

[0033] In step 102, a memory exception behavior database can be established in advance. Multiple memory exception data can be stored in the memory exception behavior library. Among them, the memory exception data can represent the application memory change data when the application memory size reaches the virtual machine heap memory limit. In some examples, any two memory exception data among the multiple memory exception data do not satisfy the consistency condition. In other words, there are no duplicate memory exception data in the memory exception behavior library.

[0034] When the application memory size is greater than or equal to the memory threshold, the application memory change data can be matched with the memory exception behavior library.

[0035] Among them, the memory threshold can be determined based on the virtual machine heap memory limit (VM heap limit, hereinafter referred to as limit), and the memory threshold can be less than the virtual machine heap memory limit. For example, the memory threshold can be the difference between the virtual machine heap memory limit minus a preset value, and the memory threshold can also be the product of the virtual machine heap memory limit multiplied by a preset first ratio. For the convenience of description, hereinafter, the case where the memory threshold is limit * 70% will be used as an example for illustration.

[0036] When the application memory size is greater than or equal to limit * 70%, it can be considered that there is a possibility that the application memory size reaches limit if the application continues to run. At this time, in order to further determine that the application memory size reaches limit, thus causing the risk of response failure of the application program, the application memory change data can be matched with the memory exception behavior library.

[0037] The consistency between the application memory change data and each memory exception data in the memory exception behavior library can be calculated. Exemplarily, the consistency can be directly calculated based on the similarity between the change trend of the application memory change data and the change trend of each memory exception data, or the intraclass correlation coefficient (ICC) between the application memory change data and each memory exception data can be calculated to measure the consistency, which is not specifically limited here.

[0038] The first memory exception data that satisfies the consistency condition can be determined according to the consistency between the application memory change data and the multiple memory exception data. Exemplarily, the first memory exception data can be the memory exception data with the highest corresponding consistency among the multiple memory exception data, or the memory exception data with the corresponding consistency greater than a preset consistency threshold among the multiple memory exception data, which is not specifically limited here.

[0039] Step 103, perform target processing on the application program according to the application memory size and the first memory exception data.

[0040] In step 103, as mentioned above, the first memory exception data can be memory exception data that is consistent with the application memory change data. That is, it can be inferred that when the application continues to run, the subsequent change trend of the application memory size is very likely to be similar to the first memory exception data. In other words, if no relevant measures are taken, the final application memory size may also reach the virtual machine heap memory limit, resulting in response failures such as application freezing and crashing.

[0041] Based on this, the application can be target-processed according to the real-time monitored application memory size and the first memory exception data to reduce the application memory size of the application.

[0042] Exemplarily, based on the application memory size and the first memory exception data, the moment when the application memory size reaches the virtual machine heap memory limit can be predicted, and the application can be target-processed in time before this moment to reduce the application memory size of the application. It can also be to continue the consistency between the subsequent application memory change data and the first memory exception data. If the consistency continuously meets the preset consistency condition, the application can be target-processed to reduce the application memory size of the application. The specific method is not specifically limited here.

[0043] It can be understood that the target processing can include ending the application process and releasing the application memory, etc. As Figure 2 shown, the System 200 supports a Virtual Machine 203 for Application 220 (application program) in java format, such as DVM, Android Runtime, and JVM. And the System 200 also provides an interface Memory Size Provider 201 for obtaining the application memory size and an interface MemoryRelease 202 for background cleaning and memory release of the Application 220. The Application 220 is a program running in this system that needs to use the memory allocated by the Virtual Machine 203. The HeapTrendServer 210 can call the Memory Size Provider 201 to obtain the application memory size of the Application 220 and call the Memory Release 202 to perform target processing on the Application 220 when necessary.

[0044] In the embodiments of the present application, the memory management method can store the application memory change data whose final application memory size reaches the virtual machine heap memory limit as memory exception data in the memory exception behavior library. On this basis, the application memory size during the continuous operation of the application can be obtained in real time and recorded to obtain the application memory change data of the application program. When the application memory size is greater than or equal to the memory threshold, it can be considered that there is a possibility that the application memory size reaches the virtual machine heap memory limit. Based on this, the application memory change data can be matched with the memory exception behavior library to determine the first memory exception data that is consistent with the application memory change data, that is, the situation where the application memory size in the application memory change data reaches the virtual machine heap memory limit can be predicted according to the first memory exception data, so that the application program can be timely subjected to target processing to reduce the application memory size of the application program. In this way, the application memory can be managed in a timely and effective manner, and the risk of response failure of the application program caused by the application memory size reaching the virtual machine heap memory limit can be reduced.

[0045] In some embodiments, when the application memory size is greater than or equal to the memory threshold, matching the application memory change data with the memory exception behavior library to determine the first memory exception data may include:

[0046] When the application memory size is greater than or equal to the memory threshold, determining the intraclass correlation coefficient between the application memory change data and multiple memory exception data;

[0047] According to the intraclass correlation coefficient, determining the first memory exception data from multiple memory exception data.

[0048] In this embodiment, when the application memory size is greater than or equal to the memory threshold, the intraclass correlation coefficient between the application memory change data and multiple memory exception data can be determined.

[0049] Among them, ICC is a statistical method used to measure the data consistency level. In this embodiment, the ICC with absolute consistency and single measurement between the application memory change data and each memory exception data can be compared, and the error of the original data is considered at the same time. The ICC model formula can be as shown in formula (1):

[0050]

[0051] Among them, A in ICC(A,1) represents absolute agreement, 1 represents signal, MS R is the mean square of row variables, MS C is the mean square of column variables, MS Eis the mean square error of the error. The calculation of formula (1) can be specifically implemented by calling relevant libraries of languages such as Python or Java.

[0052] It can be understood that the range of ICC can be [-1, 1]. Among them, when ICC is greater than 0.80, the consistency is strong; when it is between 0.61 and 0.80, the consistency is medium; when it is between 0.41 and 0.60, the consistency is general; when it is between 0.11 and 0.40, the consistency is low; and when it is below 0.1, there is no consistency.

[0053] The first memory anomaly data can be determined from multiple memory anomaly data according to the intraclass correlation coefficient. For example, the memory anomaly data corresponding to the highest ICC can be determined as the first memory anomaly data. It is also possible to determine the memory anomaly data corresponding to the ICC greater than the preset threshold among multiple memory anomaly data. For example, the memory anomaly data corresponding to the ICC above 0.61 can be determined as the first memory anomaly data.

[0054] In this way, the intraclass correlation coefficient can be used to measure the consistency between the application memory change data and multiple memory anomaly data, so that the accurate first memory anomaly data can be determined. Furthermore, based on the accurate first memory anomaly data, the application memory can be managed in a timely and effective manner, reducing the risk of application response failures caused by the application memory size reaching the virtual machine heap memory limit.

[0055] In some embodiments, when the application memory size is greater than or equal to the memory threshold, determining the intraclass correlation coefficient between the application memory change data and multiple memory anomaly data may include:

[0056] When the application memory size is greater than or equal to the memory threshold, obtain N first data segments corresponding to N consecutive historical time periods before the first moment from the application memory change data; where the first moment is the moment when the application memory size is greater than or equal to the memory threshold, and N is an integer greater than 1;

[0057] For the i-th memory anomaly data in the memory anomaly behavior library, obtain N second data segments corresponding to N consecutive historical time periods before the second moment; where the second moment is the moment when the application memory size in the i-th memory anomaly data reaches the memory threshold, and i is a positive integer;

[0058] According to the N first data segments and the N second data segments of the i-th memory anomaly data, determine the N intraclass correlation coefficients corresponding to the N historical time periods between the application memory change data and the i-th memory anomaly data;

[0059] When the within-group correlation coefficients corresponding to N historical time periods between the application memory change data and the i-th memory anomaly data are all greater than or equal to a preset threshold, the i-th memory anomaly data is determined as the first memory anomaly data;

[0060] When at least one of the within-group correlation coefficients corresponding to N historical time periods between the application memory change data and the i-th memory anomaly data is less than the preset threshold, for the (i + 1)-th memory anomaly data in the memory anomaly behavior library, N second data segments corresponding to consecutive N historical time periods before the second moment are obtained;

[0061] According to the N first data segments and the N second data segments of the (i + 1)-th memory anomaly data, the within-group correlation coefficients corresponding to N historical time periods between the application memory change data and the (i + 1)-th memory anomaly data are determined.

[0062] In this embodiment, since the time when the application memory size reaches the memory threshold is different during the operation of the application program, all the times when the memory threshold is reached can be set as t. That is, the first moment when the application memory size corresponding to the application memory change data is greater than or equal to the memory threshold is t, and the second moment when the application memory size corresponding to each memory anomaly data is greater than or equal to the memory threshold is also t.

[0063] The time length d of each historical time period in the consecutive N historical time periods is set according to actual needs. For example, it can be 10 minutes, 20 minutes, etc. The value of N can also be set according to actual needs and is not specifically limited here.

[0064] To facilitate the description of the solution of the embodiment of the present application, N = 3 will be taken as an example for illustration. Then the consecutive N historical time periods can include d1, d2, d3. Among them, d1 can be expressed as (t - d, t), d2 can be expressed as (t - 2d, t - d), and d3 can be expressed as (t - 3d, t - 2d).

[0065] The first data segments corresponding to d1, d2, and d3 can be respectively obtained from the application memory change data. In the order of multiple memory anomaly data, the second data segments corresponding to d1, d2, and d3 are sequentially obtained from one memory anomaly data.

[0066] Based on N first data segments and N second data segments, N within-group correlation coefficients corresponding to N historical time periods between the application memory change data and the current memory anomaly data can be determined. For example, for the current memory anomaly data, the within-group correlation coefficient between the first data segment corresponding to d1 and the second data segment corresponding to d1 can be calculated to obtain ICC1 corresponding to d1. The within-group correlation coefficient between the first data segment corresponding to d2 and the second data segment corresponding to d2 can be calculated to obtain ICC2 corresponding to d2. The within-group correlation coefficient between the first data segment corresponding to d3 and the second data segment corresponding to d3 can be calculated to obtain ICC3 corresponding to d3.

[0067] If the N within-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the current memory anomaly data are all greater than or equal to a preset threshold, the current memory anomaly data can be determined as the first memory anomaly data. For example, taking the preset threshold as 0.61, if ICC1, ICC2, and ICC3 between the current memory anomaly data and the application memory change data are all greater than 0.61, it can be considered that the memory anomaly data is the first memory anomaly data.

[0068] If at least one of the N within-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the current memory anomaly data is less than the preset threshold, the same calculation method as above can be used to calculate the N within-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the next memory anomaly data, and then determine whether the N within-group correlation coefficients are all greater than or equal to the preset threshold.

[0069] As Figure 3a 、 Figure 3b and Figure 3c shown, the application memory change data shown in Figure 3a can be respectively matched with the memory anomaly data shown in Figure 3b and Figure 3c to calculate the within-group correlation coefficients corresponding to d1, d2, and d3 to determine the first memory anomaly data. As can be seen from the figure, the memory anomaly data shown in Figure 3b can be determined as the first memory anomaly data.

[0070] In this way, taking the first moment and the second moment as the benchmarks, the application memory change data and the memory anomaly data can be segmented to calculate the within-group correlation coefficients between the application memory change data and multiple memory anomaly data in segments. On the one hand, determining the first memory anomaly data based on the segmented within-group correlation coefficients can reduce the impact of data errors on the consistency result and improve the accuracy of determining the first memory anomaly data. On the other hand, it can reduce the amount of data for calculating the within-group correlation coefficients and save computing power resources.

[0071] In some embodiments, performing target processing on an application according to the application memory size and the first memory exception data may include:

[0072] When the application is running in the foreground, obtain M third data segments corresponding to M consecutive preset time periods after the first moment from the application memory change data, where M is an integer greater than 1;

[0073] Obtain M fourth data segments corresponding to M consecutive preset time periods after the second moment from the first memory exception data;

[0074] Determine M intra-group correlation coefficients corresponding to M preset time periods between the application memory change data and the first memory exception data according to the M third data segments and the M fourth data segments;

[0075] Perform target processing on the application when the M intra-group correlation coefficients meet the preset conditions.

[0076] In this embodiment, if the process of the application is still running in the foreground, it can continue to be compared with the first memory exception data to confirm the consistency of subsequent behaviors.

[0077] The time length of each preset time period in the M consecutive preset time periods is set according to actual needs. For example, it can be set to 3 minutes, and the value of M can also be set according to actual needs, which is not specifically limited here. For the convenience of describing the solution of the embodiments of the present application, it will be described by taking the time length of each preset time period as 3 minutes and M as 3 as an example.

[0078] For example, from the application memory change data, starting from the first moment, obtain a third data segment every 3 minutes, and repeat 3 times to obtain 3 third data segments. Similarly, from the first memory exception data, starting from the second moment, continuously obtain 3 fourth data segments at intervals of 3 minutes.

[0079] The M intra-group correlation coefficients corresponding to M preset time periods between the application memory change data and the first memory exception data can be determined according to the M third data segments and the M fourth data segments. The intra-group correlation coefficient 1 between the first third data segment and the first fourth data segment can be calculated. The intra-group correlation coefficient 2 between the second third data segment and the second fourth data segment can be calculated. The intra-group correlation coefficient 3 between the third third data segment and the third fourth data segment can be calculated.

[0080] When the correlation coefficients within M groups meet the preset conditions, target processing can be performed on the application. For example, if the number of correlation coefficients within M groups that are greater than or equal to the preset threshold reaches the preset quantity, the consistency of subsequent behaviors can be considered, and at this time, target processing can be performed on the application. For example, if two of the within-group correlation coefficient 1, within-group correlation coefficient 2, and within-group correlation coefficient 3 are greater than or equal to 0.61, target processing can be performed on the application.

[0081] In some examples, if the process of the application is running in the background, the application process of the application can be cleared when the continuous duration of running in the background is greater than or equal to the duration threshold, so as to restart the application and reduce the application memory size.

[0082] In this way, when the application is running in the foreground, the consistency between the subsequent behaviors of the application memory change data and the first memory exception data can be continuously confirmed, and target processing can be performed on the application when the consistency is relatively high. In this way, the necessity of memory management can be ensured, and while not affecting the normal use of the application, the application memory can be managed in a timely and effective manner, reducing the risk of the application program experiencing response failures due to the application memory size reaching the virtual machine heap memory limit.

[0083] In some embodiments, when the correlation coefficients within M groups meet the preset conditions and target processing is performed on the application, it may include:

[0084] When the correlation coefficients within M groups meet the preset conditions, obtain the running state of the application;

[0085] When the running state indicates that the application is still running in the foreground, release the application memory of the application;

[0086] When the running state indicates that the application changes from running in the foreground to running in the background, end the application process of the application.

[0087] In this embodiment, if the correlation coefficients within M groups meet the preset conditions, it can be considered that the consistency between the subsequent behaviors of the application memory change data and the first memory exception data is relatively high. In other words, the risk of the application program experiencing response failures due to the application memory size reaching the virtual machine heap memory limit is relatively large, and memory management is relatively urgent. Based on this, the running state of the application can be obtained.

[0088] If the running state indicates that the application is still running in the foreground, at this time, the application memory of the application can be released. In other words, the invisible but still existing interactive interface in the application can be released to achieve memory release and reduce the application memory size.

[0089] If the running state indication application changes from running in the foreground to running in the background, the application process of the application can be directly terminated at this time, so as to achieve the purpose of restarting the application and reducing the application memory size.

[0090] In this way, in the case of relatively tight memory management, the corresponding processing method can be selected according to the running state of the application to achieve the purpose of reducing the application memory size, and the impact of memory management on the normal use of the application can be reduced.

[0091] In some embodiments, after determining the M intra-group correlation coefficients corresponding to the M preset time periods between the application memory change data and the first memory anomaly data according to the M third data segments and the M fourth data segments, the method may further include:

[0092] In the case that the M intra-group correlation coefficients do not meet the preset conditions, starting from the time when the application changes from running in the foreground to running in the background, the continuous duration of the application running in the background is counted;

[0093] In the case that the continuous duration is greater than or equal to the duration threshold, the application process of the application is terminated.

[0094] In this embodiment, if the M intra-group correlation coefficients do not meet the preset conditions, it can be considered that although there is a risk of response failure of the application due to the application memory size reaching the virtual machine heap memory limit, the urgency is relatively low. At this time, starting from the time when the application changes from running in the foreground to running in the background, the continuous duration of the application running in the background is counted. In the case that the continuous duration is greater than or equal to the duration threshold, the application process of the application is terminated. For example, the application process is terminated only when the application has been running in the background for 5 minutes and has not entered the application again.

[0095] In other words, if the application is running in the foreground or the continuous duration of running in the background is relatively short, the target processing of the application can be temporarily not performed. In this way, the impact of memory management on the normal use of the application can be further reduced.

[0096] In some embodiments, the preset conditions may include:

[0097] Among the M intra-group correlation coefficients, the ratio of the first quantity to the total quantity is greater than or equal to the preset ratio, and the first quantity is the number of intra-group correlation coefficients greater than or equal to the preset threshold.

[0098] In this embodiment, the preset conditions may include that among the M intra-group correlation coefficients, the ratio of the first quantity to the total quantity is greater than or equal to the preset ratio, and the first quantity is the number of intra-group correlation coefficients greater than or equal to the preset threshold.

[0099] The preset ratio and the preset threshold can be set according to actual requirements and are not specifically limited here. For example, the preset ratio can be 2 / 3 and the preset threshold can be 0.61.

[0100] In other words, among the within-group correlation coefficients of M groups, if at least 2 / 3 of the within-group correlation coefficients are greater than or equal to 0.61, it can be considered that the within-group correlation coefficients of M groups meet the preset conditions. If less than 2 / 3 of the within-group correlation coefficients are greater than or equal to 0.61, it can be considered that the within-group correlation coefficients of M groups do not meet the preset conditions.

[0101] In this way, when confirming the consistency between the subsequent behavior of the application memory change data and the first memory anomaly data, the error factor can be considered by setting the preset ratio, further improving the accuracy of memory management.

[0102] In some embodiments, after matching the application memory change data with the memory anomaly behavior library, the method may further include:

[0103] When the first memory anomaly data does not exist in the memory anomaly behavior library and the application memory size is greater than or equal to the virtual machine heap memory limit, the application memory change data is stored in the memory anomaly behavior library as memory anomaly data.

[0104] In this embodiment, the application memory of the application program may have various different trends of change over a period of time, such as stable type, fluctuating upward type, sudden upward or sudden downward, etc. By recording and comparing the change in the application memory size over a period of time, it is determined whether there is a memory anomaly behavior. It can be understood that when the application memory size reaches the virtual machine heap memory limit, it can be considered that there is a memory anomaly during this time period.

[0105] In some examples, this time period is the time period when the application program is running in the foreground and does not include the time when the application program is running in the background.

[0106] The application memory change data of the application program during the application running time period can be obtained. If the application memory size in the application memory change data is greater than or equal to the virtual machine heap memory limit and no first memory anomaly data with consistency is matched in the memory anomaly behavior library, the application memory change data can be stored in the memory anomaly behavior library as memory anomaly data.

[0107] Exemplarily, if the running time T of the application reaches the limit when the application memory size reaches limit, the application memory change data within the running time T of the application can be saved and recorded as memory exception data. The first type of memory exception data is denoted as BD1. If it is not the same memory exception after comparison with the trend of BD1 and limit is encountered again, then the newly added memory exception data is denoted as BD2. If it is not repeated after comparison with BT1 and BT2 respectively and limit is encountered again, then the added memory exception data is denoted as BD3. The addition of other memory exception data follows the same pattern.

[0108] In this way, a memory exception behavior library storing different types of memory exception data can be established and continuously updated, laying a foundation for subsequent timely and effective management of the application memory and reducing the risk of response failures in the application due to the application memory size reaching the virtual machine heap memory limit.

[0109] To facilitate understanding of the memory management method provided in the above embodiments, the following uses a specific scenario embodiment to illustrate the above memory management method. Figure 4 It is a schematic flowchart of a scenario embodiment of the memory management method provided in the embodiment of the present application.

[0110] This scenario embodiment may specifically include the following steps:

[0111] Step 401, start the application.

[0112] Step 402, determine whether the application memory size reaches the memory threshold. If so, execute step 403; if not, end.

[0113] Step 403, perform ICC comparison between the application memory change data and all memory exception data one by one.

[0114] Step 404, determine whether there is first memory exception data. If so, execute step 405; if not, execute step 406.

[0115] Step 405, if running in the foreground, release the application memory; if running in the background, end the application process.

[0116] Step 406, determine whether the application memory size reaches the virtual machine heap memory limit. If so, execute step 407; if not, end.

[0117] Step 407, add it as memory exception data.

[0118] For the memory management method provided in the embodiment of the present application, the execution subject may be a memory management device. In the embodiment of the present application, taking the memory management device executing the memory management method as an example, the memory management device provided in the embodiment of the present application is described.

[0119] As shown Figure 5 in the figure, the memory management device 500 may include:

[0120] A recording module 501, configured to record the application memory change data of the application program based on the obtained application memory size;

[0121] A matching module 502, configured to match the application memory change data with the memory abnormal behavior library when the application memory size is greater than or equal to the memory threshold, and determine the first memory abnormal data; wherein, the memory threshold is less than the virtual machine heap memory limit, and the memory abnormal behavior library includes multiple memory abnormal data, the memory abnormal data represents the application memory change data when the application memory size reaches the virtual machine heap memory limit, and the first memory abnormal data is any memory abnormal data in the multiple memory abnormal data that satisfies the consistency condition with the application memory change data;

[0122] A processing module 503, configured to perform target processing on the application program according to the application memory size and the first memory abnormal data.

[0123] In the embodiments of the present application, the memory management method can store the application memory change data whose final application memory size reaches the virtual machine heap memory limit as memory abnormal data in the memory abnormal behavior library. On this basis, the application memory size of the application program during continuous operation can be obtained in real time and recorded to obtain the application memory change data of the application program. When the application memory size is greater than or equal to the memory threshold, it can be considered at this time that there is a possibility that the application memory size reaches the virtual machine heap memory limit. Based on this, the application memory change data can be matched with the memory abnormal behavior library to determine the first memory abnormal data that is consistent with the application memory change data, that is, the situation where the application memory size in the application memory change data reaches the virtual machine heap memory limit can be predicted according to the first memory abnormal data, so that the application program can be timely subjected to target processing to reduce the application memory size of the application program. In this way, the application memory can be managed in a timely and effective manner, and the risk of response failure of the application program caused by the application memory size reaching the virtual machine heap memory limit can be reduced.

[0124] In some embodiments, the matching module 502 may include:

[0125] A first determination unit, configured to determine the within-group correlation coefficient between the application memory change data and the multiple memory abnormal data when the application memory size is greater than or equal to the memory threshold;

[0126] A second determination unit, configured to determine the first memory abnormal data from the multiple memory abnormal data according to the within-group correlation coefficient.

[0127] In this way, the consistency between the application memory change data and multiple memory anomaly data can be measured according to the within-group correlation coefficient, so as to accurately determine the first memory anomaly data. Furthermore, the application memory can be managed in a timely and effective manner based on the accurate first memory anomaly data, reducing the risk of response failures in the application program caused by the application memory size reaching the virtual machine heap memory limit.

[0128] In some embodiments, the first determination unit may further be configured to:

[0129] When the application memory size is greater than or equal to the memory threshold, obtain N first data segments corresponding to N consecutive historical time periods before the first moment from the application memory change data; wherein, the first moment is the moment when the application memory size is greater than or equal to the memory threshold, and N is an integer greater than 1;

[0130] For the i-th memory anomaly data in the memory anomaly behavior library, obtain N second data segments corresponding to N consecutive historical time periods before the second moment; wherein, the second moment is the moment when the application memory size in the i-th memory anomaly data reaches the memory threshold, and i is a positive integer;

[0131] Determine N within-group correlation coefficients corresponding to N historical time periods between the application memory change data and the i-th memory anomaly data according to the N first data segments and the N second data segments of the i-th memory anomaly data;

[0132] When the N within-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the i-th memory anomaly data are all greater than or equal to the preset threshold, determine the i-th memory anomaly data as the first memory anomaly data;

[0133] When at least one of the N within-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the i-th memory anomaly data is less than the preset threshold, for the (i + 1)-th memory anomaly data in the memory anomaly behavior library, obtain N second data segments corresponding to N consecutive historical time periods before the second moment;

[0134] Determine N within-group correlation coefficients corresponding to N historical time periods between the application memory change data and the (i + 1)-th memory anomaly data according to the N first data segments and the N second data segments of the (i + 1)-th memory anomaly data.

[0135] In this way, taking the first moment and the second moment as references, the application memory change data and the memory exception data can be segmented, and the within-group correlation coefficients between the application memory change data and multiple memory exception data can be calculated segment by segment. On the one hand, determining the first memory exception data based on the segmented within-group correlation coefficients can reduce the impact of data errors on the consistency result and improve the accuracy of determining the first memory exception data. On the other hand, it can reduce the amount of data for calculating the within-group correlation coefficients and save computing power resources.

[0136] In some embodiments, the processing module 503 can also be used to:

[0137] When the application is running in the foreground, obtain M third data segments corresponding to M consecutive preset time periods after the first moment from the application memory change data, where M is an integer greater than 1;

[0138] Obtain M fourth data segments corresponding to M consecutive preset time periods after the second moment from the first memory exception data;

[0139] Determine M within-group correlation coefficients corresponding to M preset time periods between the application memory change data and the first memory exception data according to the M third data segments and the M fourth data segments;

[0140] When the M within-group correlation coefficients meet the preset conditions, perform target processing on the application.

[0141] In this way, when the application is running in the foreground, it is possible to continue to confirm the consistency between the subsequent behavior of the application memory change data and the first memory exception data, and perform target processing on the application when the consistency is relatively high. In this way, the necessity of memory management can be ensured, and while not affecting the normal use of the application, the application memory can be managed in a timely and effective manner, reducing the risk of response failures of the application caused by the application memory size reaching the virtual machine heap memory limit.

[0142] In some embodiments, the processing module 503 can also be used to:

[0143] When the M within-group correlation coefficients meet the preset conditions, obtain the running state of the application;

[0144] When the running state indicates that the application is still running in the foreground, release the application memory of the application;

[0145] When the running state indicates that the application changes from running in the foreground to running in the background, end the application process of the application.

[0146] In this way, in the case of tight memory management, the corresponding processing method can be selected according to the running state of the application to achieve the purpose of reducing the application memory size, and the impact of memory management on the normal use of the application can be reduced.

[0147] In some embodiments, the processing module 503 can also be used for:

[0148] In the case where the correlation coefficients within M groups do not meet the preset conditions, starting from when the application changes from running in the foreground to running in the background, the continuous duration of the application running in the background is counted;

[0149] In the case where the continuous duration is greater than or equal to the duration threshold, the application process of the application is ended.

[0150] In this way, the impact of memory management on the normal use of the application can be further reduced.

[0151] In some embodiments, the preset conditions may include:

[0152] Among the correlation coefficients within M groups, the ratio of the first quantity to the total quantity is greater than or equal to the preset ratio, and the first quantity is the number of correlation coefficients within the group that are greater than or equal to the preset threshold.

[0153] In this way, when confirming the consistency between the subsequent behavior of the application memory change data and the first memory exception data, the error factor can be considered by setting the preset ratio, and the accuracy of memory management can be further improved.

[0154] In some embodiments, the memory management device 500 may further include:

[0155] A storage module, configured to store the application memory change data as memory exception data in the memory exception behavior library when the first memory exception data does not exist in the memory exception behavior library and the application memory size is greater than or equal to the virtual machine heap memory limit.

[0156] In this way, a memory exception behavior library storing different types of memory exception data can be established, and the memory exception behavior library can be continuously updated, laying a foundation for subsequent timely and effective management of the application memory and reducing the risk of response failures of the application caused by the application memory size reaching the virtual machine heap memory limit.

[0157] The memory management device in the embodiments of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than terminals. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a handheld computer, a vehicle-mounted electronic device, a Mobile Internet Device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. It can also be a server, a Network Attached Storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc. The embodiments of the present application do not make specific limitations.

[0158] The memory management device in the embodiments of the present application can be a device with an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems. The embodiments of the present application do not make specific limitations.

[0159] The memory management device provided by the embodiments of the present application can implement Figures 1 to 4 each process implemented by the method embodiments. To avoid repetition, it will not be elaborated here.

[0160] Optionally, as Figure 6 shown, the embodiments of the present application further provide an electronic device 600, including a processor 601 and a memory 602. A program or instruction that can run on the processor 601 is stored on the memory 602. When the program or instruction is executed by the processor 601, it implements each step of the above-mentioned memory management method embodiment and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.

[0161] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0162] Figure 7 is a schematic diagram of the hardware structure of the electronic device provided by the embodiments of the present application.

[0163] The electronic device 700 includes, but is not limited to, components such as a radio frequency unit 701, a network module 702, an audio output unit 703, an input unit 704, a sensor 705, a display unit 706, a user input unit 707, an interface unit 708, a memory 709, and a processor 710.

[0164] Those skilled in the art can understand that the electronic device 700 may further include a power source (such as a battery) for supplying power to each component. The power source can be logically connected to the processor 710 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. Figure 7 The structure of the electronic device shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0165] Among them, the processor 710 can be used to:

[0166] Based on the obtained application memory size, record the application memory change data of the application program.

[0167] When the application memory size is greater than or equal to the memory threshold, match the application memory change data with the memory abnormal behavior library to determine the first memory abnormal data; wherein, the memory threshold is less than the virtual machine heap memory limit, the memory abnormal behavior library includes multiple memory abnormal data, the memory abnormal data represents the application memory change data when the application memory size reaches the virtual machine heap memory limit, and the first memory abnormal data is any memory abnormal data in the multiple memory abnormal data that satisfies the consistency condition with the application memory change data.

[0168] Perform target processing on the application program according to the application memory size and the first memory abnormal data.

[0169] In the embodiments of the present application, the memory management method can store the application memory change data whose final application memory size reaches the virtual machine heap memory limit as memory exception data in the memory exception behavior library. On this basis, the application memory size during the continuous operation of the application program can be obtained in real time and recorded to obtain the application memory change data of the application program. When the application memory size is greater than or equal to the memory threshold, it can be considered at this time that there is a possibility that the application memory size reaches the virtual machine heap memory limit. Based on this, the application memory change data can be matched with the memory exception behavior library to determine the first memory exception data that is consistent with the application memory change data, that is, the situation where the application memory size in the application memory change data reaches the virtual machine heap memory limit can be predicted according to the first memory exception data, so that the application program can be timely subjected to target processing to reduce the application memory size of the application program. In this way, the application memory can be managed in a timely and effective manner, and the risk of response failures of the application program caused by the application memory size reaching the virtual machine heap memory limit can be reduced.

[0170] In some embodiments, the processor 710 may also be used for:

[0171] When the application memory size is greater than or equal to the memory threshold, determine the within-group correlation coefficient between the application memory change data and multiple memory exception data;

[0172] According to the within-group correlation coefficient, determine the first memory exception data from multiple memory exception data.

[0173] In this way, the within-group correlation coefficient can be used to measure the consistency between the application memory change data and multiple memory exception data, so that the accurate first memory exception data can be determined. Furthermore, the application memory can be managed in a timely and effective manner based on the accurate first memory exception data, and the risk of response failures of the application program caused by the application memory size reaching the virtual machine heap memory limit can be reduced.

[0174] In some embodiments, the processor 710 may also be used for:

[0175] When the application memory size is greater than or equal to the memory threshold, obtain N first data segments corresponding to N consecutive historical time periods before the first moment from the application memory change data; wherein, the first moment is the moment when the application memory size is greater than or equal to the memory threshold, and N is an integer greater than 1;

[0176] For the i-th memory exception data in the memory exception behavior library, obtain N second data segments corresponding to N consecutive historical time periods before the second moment; wherein, the second moment is the moment when the application memory size in the i-th memory exception data reaches the memory threshold, and i is a positive integer;

[0177] Determine the N within-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the i-th memory exception data based on the N first data segments and the N second data segments of the i-th memory exception data;

[0178] When the N within-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the i-th memory exception data are all greater than or equal to a preset threshold, determine the i-th memory exception data as the first memory exception data;

[0179] When there is at least one within-group correlation coefficient less than the preset threshold among the N within-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the i-th memory exception data, for the (i + 1)-th memory exception data in the memory exception behavior library, obtain the N second data segments corresponding one by one to the consecutive N historical time periods before the second moment;

[0180] Determine the N within-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the (i + 1)-th memory exception data based on the N first data segments and the N second data segments of the (i + 1)-th memory exception data.

[0181] In this way, taking the first moment and the second moment as benchmarks, the application memory change data and the memory exception data can be segmented to calculate the within-group correlation coefficients between the application memory change data and multiple memory exception data segment by segment. On the one hand, determining the first memory exception data based on the segmented within-group correlation coefficients can reduce the impact of data errors on the consistency result and improve the accuracy of determining the first memory exception data. On the other hand, it can reduce the amount of data for calculating the within-group correlation coefficients and save computing power resources.

[0182] In some embodiments, the processor 710 can also be used for:

[0183] When the application is running in the foreground, obtain the M third data segments corresponding one by one to the consecutive M preset time periods after the first moment from the application memory change data, where M is an integer greater than 1;

[0184] Obtain the M fourth data segments corresponding one by one to the consecutive M preset time periods after the second moment from the first memory exception data;

[0185] Determine the M within-group correlation coefficients corresponding to the M preset time periods between the application memory change data and the first memory exception data based on the M third data segments and the M fourth data segments;

[0186] When the M within-group correlation coefficients meet the preset conditions, perform target processing on the application.

[0187] In this way, when the application is running in the foreground, it is possible to continue to confirm the consistency between the subsequent behavior of the application memory change data and the first memory exception data, and perform target processing on the application when the consistency is relatively high. In this way, the necessity of memory management can be ensured, and while not affecting the normal use of the application, the application memory can be managed in a timely and effective manner, reducing the risk of response failures of the application caused by the application memory size reaching the virtual machine heap memory limit.

[0188] In some embodiments, the processor 710 can also be used for:

[0189] When the correlation coefficients within M groups meet the preset conditions, obtain the running state of the application;

[0190] When the running state indicates that the application is still running in the foreground, release the application memory of the application;

[0191] When the running state indicates that the application changes from running in the foreground to running in the background, end the application process of the application.

[0192] In this way, in a situation where memory management is relatively urgent, the corresponding processing method can be selected according to the running state of the application to reduce the application memory size, and the impact of memory management on the normal use of the application can be reduced.

[0193] In some embodiments, the processor 710 can also be used for:

[0194] When the correlation coefficients within M groups do not meet the preset conditions, starting from the application changing from running in the foreground to running in the background, count the continuous duration of the application running in the background;

[0195] When the continuous duration is greater than or equal to the duration threshold, end the application process of the application.

[0196] In this way, the impact of memory management on the normal use of the application can be further reduced.

[0197] In some embodiments, the preset conditions may include:

[0198] Among the correlation coefficients within M groups, the ratio of the first quantity to the total quantity is greater than or equal to the preset ratio, and the first quantity is the number of correlation coefficients within the group that are greater than or equal to the preset threshold.

[0199] In this way, when confirming the consistency between the subsequent behavior of the application memory change data and the first memory exception data, the error factor can be considered by setting the preset ratio, further improving the accuracy of memory management.

[0200] In some embodiments, the processor 710 can also be used for:

[0201] When there is no first memory exception data in the memory exception behavior library and the application memory size is greater than or equal to the virtual machine heap memory limit, the application memory change data is stored in the memory exception behavior library as memory exception data.

[0202] In this way, a memory exception behavior library storing different types of memory exception data can be established, and the memory exception behavior library can be continuously updated, laying a foundation for subsequent timely and effective management of the application memory and reducing the risk of response failures in the application program caused by the application memory size reaching the virtual machine heap memory limit.

[0203] It should be understood that in the embodiments of the present application, the input unit 704 may include a graphics processing unit (GPU) 7041 and a microphone 7042. The graphics processing unit 7041 processes the image data of static pictures or videos obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 706 may include a display panel 7061, and the display panel 7061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 707 includes at least one of a touch panel 7071 and other input devices 7072. The touch panel 7071 is also called a touch screen. The touch panel 7071 may include two parts: a touch detection device and a touch controller. The other input devices 7072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be elaborated here.

[0204] The memory 709 can be used to store software programs and various data. The memory 709 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data. Among them, the first storage area may store an operating system, application programs or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 709 may include volatile memory or non-volatile memory, or the memory 709 may include both volatile and non-volatile memory. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synch link dynamic random access memory (SLDRAM), and a direct rambus random access memory (DRRAM). The memory 709 in the embodiments of the present application includes but is not limited to these and any other suitable types of memory.

[0205] The processor 710 may include one or more processing units; optionally, the processor 710 integrates an application processor and a modem processor. Among them, the application processor mainly processes operations related to the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above modem processor may not be integrated into the processor 710 either.

[0206] The embodiments of the present application also provide a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, it implements each process of the above embodiment of the memory management method and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.

[0207] Among them, the processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media such as computer read-only memory ROM, random access memory RAM, magnetic disks, or optical discs, etc.

[0208] Another embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement each process of the above embodiment of the memory management method and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0209] It should be understood that the chip mentioned in the embodiments of the present application may also be referred to as a system-on-chip, system chip, chip system, or system-on-chip, etc.

[0210] The embodiments of the present application provide a computer program product. The program product is stored in a storage medium and is executed by at least one processor to implement each process of the above embodiment of the memory management method and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0211] It should be noted that in this article, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including that element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in a reverse order according to the functions involved. For example, the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0212] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence or the part that contributes to the prior art, can be embodied in the form of a computer software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to enable a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present application.

[0213] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific implementation manners. The above specific implementation manners are merely illustrative rather than restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them belong to the protection scope of the present application.

Claims

1. A memory management method, characterized in that, The method includes: Based on the obtained application memory size, record the application memory change data of the application program; When the application memory size is greater than or equal to the memory threshold, match the application memory change data with the memory abnormal behavior library to determine the first memory abnormal data; wherein, the memory threshold is less than the virtual machine heap memory limit, the memory abnormal behavior library includes multiple memory abnormal data, the memory abnormal data represents the application memory change data when the application memory size reaches the virtual machine heap memory limit, and the first memory abnormal data is the memory abnormal data that satisfies the consistency condition with the application memory change data among the multiple memory abnormal data; According to the application memory size and the first memory abnormal data, perform target processing on the application program.

2. The method according to claim 1, characterized in that, The step of, when the application memory size is greater than or equal to the memory threshold, matching the application memory change data with the memory abnormal behavior library to determine the first memory abnormal data includes: When the application memory size is greater than or equal to the memory threshold, determine the intra-group correlation coefficient between the application memory change data and the multiple memory abnormal data; According to the intra-group correlation coefficient, determine the first memory abnormal data from the multiple memory abnormal data.

3. The method according to claim 2, wherein The step of, when the application memory size is greater than or equal to the memory threshold, determining the intra-group correlation coefficient between the application memory change data and the multiple memory abnormal data includes: When the application memory size is greater than or equal to the memory threshold, obtain N first data segments corresponding to N consecutive historical time periods before the first moment from the application memory change data; wherein, the first moment is the moment when the application memory size is greater than or equal to the memory threshold, and N is an integer greater than 1; For the i-th memory abnormal data in the memory abnormal behavior library, obtain N second data segments corresponding to N consecutive historical time periods before the second moment; wherein, the second moment is the moment when the application memory size in the i-th memory abnormal data reaches the memory threshold, and i is a positive integer; According to the N first data segments and the N second data segments of the i-th memory abnormal data, determine the N intra-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the i-th memory abnormal data; When the N intra-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the i-th memory abnormal data are all greater than or equal to the preset threshold, determine the i-th memory abnormal data as the first memory abnormal data; When at least one of the N intra-group correlation coefficients corresponding to the N historical time periods between the application memory change data and the i-th memory abnormal data is less than the preset threshold, for the (i + 1)-th memory abnormal data in the memory abnormal behavior library, obtain N second data segments corresponding to N consecutive historical time periods before the second moment; Determine N intra-group correlation coefficients corresponding to N historical time periods between the application memory change data and the (i + 1)-th memory exception data according to the N first data segments and the N second data segments of the (i + 1)-th memory exception data.

4. The method according to claim 3, characterized in that The performing target processing on the application program according to the application memory size and the first memory exception data includes: When the application program is running in the foreground, obtain M third data segments corresponding one by one to M consecutive preset time periods after the first moment from the application memory change data, where M is an integer greater than 1; Obtain M fourth data segments corresponding one by one to M consecutive preset time periods after the second moment from the first memory exception data; Determine M intra-group correlation coefficients corresponding to M preset time periods between the application memory change data and the first memory exception data according to the M third data segments and the M fourth data segments; When the M intra-group correlation coefficients meet the preset conditions, perform target processing on the application program.

5. The method according to claim 4, characterized in that, The performing target processing on the application program when the M intra-group correlation coefficients meet the preset conditions includes: When the M intra-group correlation coefficients meet the preset conditions, obtain the running state of the application program; When the running state indicates that the application program is still running in the foreground, release the application memory of the application program; When the running state indicates that the application program changes from running in the foreground to running in the background, end the application process of the application program.

6. The method according to claim 4, characterized in that, After determining M intra-group correlation coefficients corresponding to M preset time periods between the application memory change data and the first memory exception data according to the M third data segments and the M fourth data segments, the method further includes: When the M intra-group correlation coefficients do not meet the preset conditions, start from when the application program changes from running in the foreground to running in the background, and count the continuous duration for which the application program enters the background; When the continuous duration is greater than or equal to the duration threshold, end the application process of the application program.

7. The method according to any one of claims 4 to 6, characterized in that The preset conditions include: Among the M intra-group correlation coefficients, the ratio of the first quantity to the total quantity is greater than or equal to a preset ratio, where the first quantity is the number of intra-group correlation coefficients greater than or equal to the preset threshold.

8. The method according to claim 1, wherein After matching the application memory change data with the memory exception behavior library, the method further includes: When the first memory exception data does not exist in the memory exception behavior library and the application memory size is greater than or equal to the virtual machine heap memory limit, store the application memory change data as memory exception data in the memory exception behavior library.

9. A memory management device, characterized in that, The device includes: A recording module, configured to record the application memory change data of the application program based on the obtained application memory size; A matching module, configured to match the application memory change data with a memory abnormal behavior library when the application memory size is greater than or equal to a memory threshold, so as to determine first memory abnormal data; wherein, the memory threshold is less than the virtual machine heap memory limit, the memory abnormal behavior library includes a plurality of memory abnormal data, the memory abnormal data represents application memory change data when the application memory size reaches the virtual machine heap memory limit, and the first memory abnormal data is any one of the plurality of memory abnormal data that meets a consistency condition with the application memory change data; A processing module, configured to perform target processing on the application program according to the application memory size and the first memory abnormal data.

10. An electronic device, characterized in that, It includes a processor and a memory, the memory stores programs or instructions that can run on the processor, and when the programs or instructions are executed by the processor, the steps of the method according to any one of claims 1-8 are implemented.

11. A readable storage medium, characterized in that, Programs or instructions are stored on the readable storage medium, and when the programs or instructions are executed by a processor, the steps of the method according to any one of claims 1-8 are implemented.