Memory reclamation methods, media, electronic devices, and application products

By configuring memory reclamation parameters for applications and selectively compressing anonymous pages, the problem of high CPU resource consumption during anonymous page reclamation is solved, improving system performance and user experience.

CN123068052APending Publication Date: 2026-11-10HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510591618.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-08
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

In existing technologies, anonymous page reclamation requires a compression scan of all anonymous pages, resulting in high CPU resource consumption. This can cause stuttering, especially under high load, and negatively impact the user experience.

Method used

By configuring memory reclamation parameters for each application, the amount of anonymous pages that need to be compressed and those that do not can be reclaimed is determined. Only anonymous pages that need to be compressed are compressed, thus avoiding unnecessary CPU resource consumption.

Benefits of technology

It effectively reduces CPU resource consumption, avoids lag caused by CPU resource contention under high load, and improves system performance and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123068052A_ABST
    Figure CN123068052A_ABST
Patent Text Reader

Abstract

This application relates to the field of computer technology, and in particular to a memory reclamation method, medium, electronic device, and program product. In this method, each application in memory is configured with memory reclamation parameters, which determine the number of anonymous pages to be compressed and uncompressed within the anonymous pages to be reclaimed by the application. During memory reclamation, the number of compressible and uncompressed anonymous pages within the reclaimable anonymous pages of the application can be obtained according to the memory reclamation parameters. Compressible anonymous pages are then compressed, while uncompressable anonymous pages are left uncompressed. Based on this approach, anonymous pages can be selectively left uncompressed conveniently and efficiently, saving CPU power consumption during compression and avoiding the problems of high time costs and high CPU resource consumption in deciding which anonymous pages to leave uncompressed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a memory reclamation method, medium, electronic device, and program product. Background Technology

[0002] An anonymous page is a special type of memory page. When an application (APP) is running, an electronic device can dynamically allocate anonymous pages to it for storing temporary data. As more and more applications run, the electronic device's memory resources may become insufficient. The electronic device can reclaim anonymous pages in memory to reduce their memory footprint, thus achieving memory reclamation. For example, zram memory compression technology can be used to compress memory data and reclaim some anonymous pages for use in the swap partition, thereby reducing their memory usage. When the anonymous page is needed again, it can be decompressed to obtain the required page.

[0003] However, compressing anonymous pages in memory is inherently a resource-intensive process that consumes a significant amount of central processing unit (CPU) resources. Therefore, when reclaiming anonymous pages, selective compression can be performed, meaning some anonymous pages can be left uncompressed to reduce the time and power consumption associated with compressing them.

[0004] In some existing embodiments, electronic devices can periodically use CPU resources to perform compression scans on anonymous pages in memory to obtain the compression ratio of each anonymous page. The compression ratio is the ratio of the size of the compressed anonymous page to the size of the anonymous page before compression. Then, based on the compression ratio of each anonymous page, a decision is made on which anonymous pages should not be compressed during memory reclamation. A high compression ratio indicates that the compressed size is still large compared to the uncompressed size, meaning the memory savings from compression are relatively small. In this case, anonymous pages with high compression ratios can be left uncompressed during memory reclamation.

[0005] However, this method requires compressing and scanning all anonymous pages to obtain the compression ratio, and the time cost of determining which anonymous pages to leave uncompressed is significant, consuming substantial CPU resources. Especially for electronic devices under high CPU load, memory reclamation may occupy CPU resources for extended periods, potentially leading to insufficient CPU resources for critical threads, resulting in lag and negatively impacting user experience. Summary of the Invention

[0006] In view of this, this application provides a memory reclamation method, medium, electronic device, and program product to solve the problems of high time cost and high CPU resource consumption required to determine uncompressed anonymous pages.

[0007] In a first aspect, a memory reclamation method is provided, applied to an electronic device. The method includes: running a first application, the first application corresponding to a first memory reclamation parameter, the first memory reclamation parameter being used to determine the number of anonymous pages to be compressed and uncompressed in the reclaimable anonymous pages of the first application; determining, based on the first memory reclamation parameter, a first number of anonymous pages that can be compressed and a second number of anonymous pages that cannot be compressed in the reclaimable anonymous pages of the first application, the sum of the first number and the second number being the number of anonymous pages that can be reclaimed by the first application; compressing the first number of anonymous pages in the reclaimable anonymous pages of the first application for memory reclamation, and uncompressing the second number of anonymous pages for memory reclamation.

[0008] Understandably, the first memory reclamation parameter can be a compression ratio, a non-compression ratio, a number of compressed pages, or a number of uncompressed pages, etc. This first memory reclamation parameter determines the number of anonymous pages to be compressed and uncompressed within the anonymous pages to be reclaimed by the first application. Therefore, when reclaiming anonymous pages from the first application, the first memory reclamation parameter can be used to determine the first number of compressible anonymous pages and the second number of uncompressible anonymous pages within the reclaimable anonymous pages of the first application. This allows for the compression of compressible anonymous pages within the reclaimable anonymous pages of the first application, while uncompressible anonymous pages are not compressed, thus achieving memory reclamation.

[0009] Understandably, using memory reclamation parameters allows for convenient and efficient selective non-compression of anonymous pages. This not only saves CPU power during compression but also avoids the time-consuming and CPU-intensive problem of deciding which anonymous pages to leave uncompressed based on compression ratios. In particular, it prevents stuttering under high load conditions where the reclamation thread occupies the CPU for extended periods, preventing the CPU from allocating resources to critical threads. Furthermore, it avoids the performance gains from not compressing anonymous pages in critical scenarios when users use many applications within a short period under high load, as the compression ratio cannot be obtained in a short time due to the inability to perform targeted non-compression processing.

[0010] In one possible implementation of the first aspect described above, the first memory reclamation parameter indicates a first initial number of compressible anonymous pages among the anonymous pages reclaimable by the first application; determining the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the anonymous pages reclaimable by the first application based on the first memory reclamation parameter includes: using the number of anonymous pages corresponding to the first initial number as the first number; determining the second number based on the number of anonymous pages reclaimable by the first application and the first number; or, the first memory reclamation parameter indicates a second initial number of uncompressed anonymous pages among the anonymous pages reclaimable by the first application; determining the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the anonymous pages reclaimable by the first application based on the first memory reclamation parameter includes: using the number of anonymous pages corresponding to the second initial number as the second number; determining the first number based on the anonymous pages that the first application needs to reclaim memory for and the second number.

[0011] For example, the first initial quantity is the initial compression ratio, and the second initial quantity is the initial uncompressed ratio. Based on the initial compression ratio or the initial uncompressed ratio, and the amount of anonymous pages that can be reclaimed by the first application, the amount of anonymous pages that need to be compressed and the amount of anonymous pages that do not need to be compressed can be quickly determined.

[0012] In one possible implementation of the first aspect described above, the first memory reclamation parameter indicates a first initial number of compressible anonymous pages among the anonymous pages reclaimable by the first application; determining the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the anonymous pages reclaimable by the first application based on the first memory reclamation parameter includes: determining the first initial number based on the first memory reclamation parameter; determining the first number based on the electronic device's state information and the first initial number; determining the second number based on the anonymous pages requiring memory reclamation by the first application and the first number; or, the first memory reclamation parameter indicates a second initial number of uncompressed anonymous pages among the anonymous pages reclaimable by the first application; determining the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the anonymous pages reclaimable by the first application based on the first memory reclamation parameter includes: determining the second initial number based on the first memory reclamation parameter; determining the second number based on the electronic device's state information and the second initial number; determining the first number based on the anonymous pages requiring memory reclamation by the first application and the second number.

[0013] For example, the first initial quantity is the initial compression ratio, and the second initial quantity is the initial uncompressed ratio. The initial compression ratio or the initial uncompressed ratio is adjusted based on the status information to obtain the adjusted compression ratio or uncompressed ratio. The number of anonymous pages corresponding to the adjusted compression ratio is used as the first quantity. Alternatively, the number of anonymous pages corresponding to the adjusted uncompressed ratio is used as the second quantity.

[0014] Understandably, the electronic device's state information will change during the first application's operation. At this point, determining the first and second quantities based on the electronic device's state information and either a first or second initial quantity ensures that the obtained first and second quantities better reflect the actual situation of the current electronic device. This means that determining the amount of anonymous pages that need to be compressed or not compressed is more real-time.

[0015] In one possible implementation of the first aspect described above, the state information of the electronic device includes the CPU load of the electronic device; determining the first quantity based on the state information of the electronic device and the first initial quantity includes: determining the CPU load; when the CPU load is higher than or equal to the first CPU load threshold, taking the number of anonymous pages corresponding to the first initial quantity as the first quantity; when the CPU load is lower than the first CPU load threshold, determining the first quantity as the number of anonymous pages reclaimable by the first application; or, determining the second quantity based on the state information of the electronic device and the second initial quantity includes: determining the CPU load; when the CPU load is higher than or equal to the first CPU load threshold, taking the number of anonymous pages corresponding to the second initial quantity as the second quantity; when the CPU load is lower than the first CPU load threshold, determining the second quantity as 0.

[0016] Understandably, when the CPU load is higher than or equal to the first CPU load threshold, indicating a high CPU load, the first quantity can be used as the number of anonymous pages corresponding to the first initial quantity, or the second quantity can be used as the number of anonymous pages corresponding to the second initial quantity. This means compressing the portion of the anonymous pages that the first application can reclaim. When the CPU load is lower than the first CPU load threshold, the first quantity is determined as the number of anonymous pages that the first application can reclaim, meaning all of the anonymous pages that the first application can reclaim are compressed. In this case, it can be ensured that the uncompressed anonymous page behavior only takes effect when the system load is high, thereby reducing the impact of uncompressed behavior on device lifespan and alleviating CPU load to some extent. It can also improve the supply of resources for critical foreground threads in the system.

[0017] In one possible implementation of the first aspect described above, the state information of the electronic device includes the CPU load of the electronic device. Determining the first quantity based on the state information of the electronic device and the first initial quantity includes: determining the CPU load; when the CPU load is higher than or equal to a second CPU load threshold, obtaining the first quantity by decreasing the first initial quantity, wherein the first quantity is greater than or equal to 0; or when the CPU load is lower than the second CPU load threshold, obtaining the first quantity by increasing the first initial quantity; or, determining the second quantity based on the state information of the electronic device and the second initial quantity includes: determining the CPU load; when the CPU load is higher than or equal to the second CPU load threshold, obtaining the second quantity by increasing the second initial quantity; or when the CPU load is lower than the second CPU load threshold, obtaining the second quantity by decreasing the second initial quantity, wherein the second quantity is greater than or equal to 0.

[0018] Understandably, for CPU load, when the CPU load is higher than or equal to the second CPU load threshold, it indicates that the current CPU load is high and CPU resources are strained. For example, the first initial quantity is the initial compression ratio. Decreasing the initial compression ratio uses the number of anonymous pages corresponding to the reduced compression ratio as the first quantity. This reduces the number of compressed anonymous pages, meaning the number of uncompressed anonymous pages increases. Similarly, the second initial quantity is the initial uncompressed ratio. Increasing the initial uncompressed ratio uses the number of anonymous pages corresponding to the increased uncompressed ratio as the second quantity. This also increases the number of uncompressed anonymous pages, meaning the number of compressed anonymous pages decreases. In this case, the first and second quantities, dynamically adjusted based on the CPU load, are more adaptable to the current state of the electronic device.

[0019] In one possible implementation of the first aspect described above, the state information of the electronic device includes the CPU load of the electronic device. Determining the first quantity based on the state information of the electronic device and the first initial quantity includes: determining the CPU load; if the CPU load is higher than or equal to a first CPU load threshold, and if the CPU load is higher than or equal to a second CPU load threshold, then the first quantity is obtained by reducing the first initial quantity, the first quantity is greater than or equal to 0, and the second CPU load threshold is greater than the first CPU load threshold; or if the CPU load is lower than the first CPU load threshold, the first quantity is determined to be the number of anonymous pages reclaimable by the first application; or determining the second quantity based on the state information of the electronic device and the second initial quantity includes: determining the CPU load; if the CPU load is higher than or equal to the first CPU load threshold, and if the CPU load is higher than or equal to the second CPU load threshold, then the second quantity is obtained by increasing the second initial quantity, and the second CPU load threshold is greater than the first CPU load threshold; or if the CPU load is lower than the first CPU load threshold, the second quantity is determined to be 0.

[0020] For example, the first initial quantity is the initial compression ratio. When the CPU load is higher than or equal to a first CPU load threshold, and further determined to be higher than or equal to a second CPU load threshold, the initial compression ratio is adjusted, and the anonymous page count corresponding to the adjusted compression ratio is used as the first quantity. Alternatively, the second initial quantity is the initial uncompressed ratio. When the CPU load is higher than or equal to a first CPU load threshold, and further determined to be higher than or equal to a second CPU load threshold, the initial uncompressed ratio is adjusted, and the anonymous page count corresponding to the adjusted uncompressed ratio is used as the second quantity. This method effectively saves CPU power consumption while ensuring that some anonymous pages are not compressed, and it can be applied to various scenarios.

[0021] In one possible implementation of the first aspect described above, the state information of the electronic device includes the memory availability parameter of the electronic device; determining the first quantity based on the state information of the electronic device and the first initial quantity includes: determining the memory availability parameter; when the memory availability parameter is higher than or equal to the first memory parameter threshold, obtaining the first quantity by reducing the first initial quantity, wherein the first quantity is greater than or equal to 0, or when the memory availability parameter is lower than the first memory parameter threshold, obtaining the first quantity by increasing the first initial quantity; or determining the second quantity based on the state information of the electronic device and the second initial quantity includes: determining the memory availability parameter; when the memory availability parameter is higher than or equal to the first memory parameter threshold, obtaining the second quantity by increasing the second initial quantity, or when the memory availability parameter is lower than the first memory parameter threshold, obtaining the second quantity by reducing the second initial quantity, wherein the second quantity is greater than or equal to 0.

[0022] Understandably, regarding memory availability, smaller available memory indicates a greater need for memory space, meaning more anonymous pages need to be compressed. When the available memory parameter is higher than or equal to the first memory parameter threshold, available memory is relatively sufficient. The first quantity can be obtained by reducing the first initial quantity, or the second quantity can be obtained by increasing the second initial quantity; that is, the amount of compression decreases, and the amount of uncompressed pages increases. Conversely, when the available memory parameter is lower than the first memory parameter threshold, available memory is relatively tight. The first quantity can be obtained by increasing the first initial quantity, or the second quantity can be obtained by decreasing the second initial quantity; that is, the amount of compression increases, and the amount of uncompressed pages decreases, resulting in more anonymous pages being compressed to increase available memory.

[0023] Understandably, when the status information includes memory availability parameters, the first or second initial quantity can be adjusted using only the memory availability parameters, or it can be adjusted in conjunction with CPU load. For example, if the CPU load is higher than or equal to a second CPU load threshold, and the memory availability parameters are lower than a first memory parameter threshold, then while increasing the second initial quantity based on the memory availability parameters, the second initial quantity should also be decreased based on the CPU load to obtain a second adjusted quantity. The anonymous page count corresponding to the second adjusted quantity is then used as the second quantity.

[0024] In one possible implementation of the first aspect above, before determining the first number of compressible anonymous pages among the reclaimable anonymous pages of the first application based on the first memory reclamation parameter, the method further includes: determining the first memory reclamation parameter based on the characteristics of the first application and the correspondence between the characteristics of the application and the memory reclamation parameter.

[0025] Understandably, determining the first memory reclamation parameter based on the characteristics of the first application and the correspondence between the application's characteristics and the memory reclamation parameter is a more scientific approach.

[0026] In one possible implementation of the first aspect above, the characteristics of the application include: the frequency of application use, and / or the application priority.

[0027] Understandably, application usage frequency is based on user habits and the characteristics of the application, and application priority is also related to user usage. The primary memory reclamation parameter derived from application usage frequency or priority is more consistent with the application's runtime state.

[0028] In one possible implementation of the first aspect above, the applications in the electronic device include: applications with a first frequency and applications with a second frequency; the correspondence between the characteristics of the applications and the memory reclamation parameters includes: the first frequency corresponds to the first memory reclamation parameter, and the second frequency corresponds to the second memory reclamation parameter.

[0029] It is understandable that the first frequency corresponds to the first memory reclamation parameter, and the second frequency corresponds to the second memory reclamation parameter. That is, the anonymous page compression ratio corresponding to the application is different depending on the frequency of use. This method is reasonable and scientific.

[0030] In one possible implementation of the first aspect above, the applications in the electronic device include: applications with a first priority and applications with a second priority; the correspondence between the characteristics of the applications and the memory reclamation parameters includes: the first priority corresponds to the first memory reclamation parameter, and the second priority corresponds to the second memory reclamation parameter.

[0031] Understandably, application priority is related to its most recent usage time, importance, and other state information. The first priority corresponds to the first memory reclamation parameter, and the second priority corresponds to the second memory reclamation parameter. That is, different priorities result in different anonymous page compression amounts for the applications, a reasonable and scientific approach.

[0032] In one possible implementation of the first aspect described above, the priority of applications in the electronic device is determined based on the application's state information.

[0033] In one possible implementation of the first aspect above, the application's state information includes at least one of the application's usage time and importance.

[0034] In one possible implementation of the first aspect above, before determining the first number of compressible anonymous pages among the reclaimable anonymous pages of the first application based on the first memory reclamation parameter, the method further includes: determining that the first application switches from a first state to a second state, and that the system free memory of the electronic device is lower than a free memory reclamation threshold, or that the available memory of the electronic device is lower than an available memory reclamation threshold.

[0035] Understandably, when the system idle memory of an electronic device is lower than the idle memory reclamation threshold, or when the available memory of the electronic device is lower than the available memory reclamation threshold, memory is scarce and memory reclamation is necessary.

[0036] In a second aspect, a readable storage medium is provided, which includes one or more programs that, when executed on an electronic device, cause the electronic device to implement any of the memory reclamation methods provided in the first aspect and one possible implementation thereof.

[0037] Thirdly, an electronic device is provided, comprising: at least one memory for storing one or more programs; and at least one processor for executing the one or more programs to cause the electronic device to implement any of the memory reclamation methods provided in the first aspect and a possible implementation thereof.

[0038] Fourthly, a program product is provided that, when executed on an electronic device, enables the electronic device to implement any of the memory reclamation methods provided in the first aspect and one possible implementation of the first aspect.

[0039] Fifthly, a chip is provided that, when executed on an electronic device, enables the electronic device to implement any of the memory reclamation methods provided in the first aspect and one possible implementation of the first aspect.

[0040] It should be noted that the beneficial effects of the second to fifth aspects mentioned above can be referred to the content of the first aspect, and will not be repeated here. Attached Figure Description

[0041] Figure 1A According to some embodiments of this application, a schematic diagram of a user using a mobile phone 100 is shown;

[0042] Figure 1B According to some embodiments of this application, a schematic diagram of multiple anonymous pages is shown;

[0043] Figure 1C According to some embodiments of this application, a schematic diagram of memory-to-disk anonymous page swapping is shown;

[0044] Figure 2A According to some embodiments of this application, another schematic diagram of multiple anonymous pages is shown;

[0045] Figure 2B According to some embodiments of this application, a schematic flowchart of a memory reclamation method is shown;

[0046] Figure 3 According to some embodiments of this application, a schematic diagram of a memory reclamation method for obtaining a first non-compression ratio based on the frequency of application use is shown.

[0047] Figure 4 According to some embodiments of this application, a schematic diagram of a memory reclamation method for obtaining a second non-compression ratio based on priority is shown;

[0048] Figure 5 According to some embodiments of this application, a schematic diagram of a software architecture is shown;

[0049] Figure 6 According to some embodiments of this application, a hardware schematic diagram of a mobile phone 100 is shown. Detailed Implementation

[0050] The illustrative embodiments of this application include, but are not limited to, a memory reclamation method, a medium, an electronic device, and a program product.

[0051] For ease of description, the technical solution of this application is described below with reference to the accompanying drawings.

[0052] For example, Figure 1A According to some embodiments of this application, a schematic diagram of a user using a mobile phone 100 is shown. When the mobile phone 100 is running, multiple anonymous pages exist in memory, for example, such as... Figure 1BThe image shows multiple anonymous pages. Due to limited memory resources, the phone 100 can perform memory reclamation to reduce the memory footprint of anonymous pages and improve memory utilization efficiency.

[0053] For example, taking memory reclamation using ZRAM memory compression technology as an example, when the phone 100 performs memory reclamation, it will... Figure 1B The anonymous pages in box K1 shown are compressed and stored as follows: Figure 1C In the swap partition shown, when swap partition space is insufficient or memory is extremely tight, data in the swap partition can be swapped out to storage devices outside of memory (e.g., such as...). Figure 1C The anonymous page is located on the disk shown in the image. When you need to access the anonymous page again, if it is in the swap partition in memory, you can directly decompress the anonymous page in the swap partition. If the anonymous page is on a storage device outside of memory, you need to swap the anonymous page into the swap partition in memory and then decompress it before using it.

[0054] As described in the background section, since anonymous page compression consumes a large amount of CPU resources, the anonymous pages in the mobile phone 100 can be selectively compressed, that is, some anonymous pages are not compressed, thereby reducing the power consumption of the CPU when performing memory compression.

[0055] In some embodiments, the mobile phone 100 can periodically perform compression scans on each anonymous page in memory to obtain the compression ratio of each anonymous page, and then decide which anonymous pages to leave uncompressed based on the compression ratio. For example, taking memory reclamation using ZRAM memory compression technology as an example, in this case, the anonymous pages can be... Figure 1B For the anonymous pages in box K1 shown, based on the compression ratio of each anonymous page, the anonymous pages with the highest compression ratio are selected not to be compressed.

[0056] However, electronic devices require significant CPU resources to periodically perform compression scans of anonymous pages in memory to obtain the compression ratio of each anonymous page. This results in a high time cost and CPU resource consumption for deciding which anonymous pages to leave uncompressed based on the compression ratio. Especially for electronic devices under high CPU load, when memory reclamation occupies CPU resources for an extended period, it can cause the CPU to prioritize resources for critical threads, leading to lag and impacting the user experience.

[0057] by Figure 1A Taking the mobile phone 100 as an example, if the mobile phone 100 is playing a video and the current CPU load is high, it needs to use CPU resources to perform a long compression scan of each anonymous page in memory to decide which anonymous pages to not compress. At this time, it is easy to affect the supply of CPU resources to the video application, resulting in the currently playing video being stuttered and affecting the user's video viewing experience.

[0058] Therefore, to address the aforementioned issues, this application proposes a memory reclamation method. In this method, each application in memory is configured with memory reclamation parameters. These parameters determine the number of anonymous pages to be compressed and uncompressed within the anonymous pages to be reclaimed by the application. Thus, when reclaiming anonymous pages for a particular application, the number of compressible or uncompressed anonymous pages within the reclaimable anonymous pages can be determined based on the memory reclamation parameters. Compressible anonymous pages are then compressed, while uncompressable anonymous pages are left uncompressed, thereby achieving memory reclamation.

[0059] For example, assuming the memo application has 8kb of reclaimable anonymous pages, and according to the memory reclamation parameters, the amount of anonymous pages that can be compressed is 7.2kb, and the amount of anonymous pages that cannot be compressed is 0.8kb. In this case, the 7.2kb of anonymous pages that can be reclaimed by the memo application will be compressed, and the 0.8kb of anonymous pages will not be compressed.

[0060] Understandably, using memory reclamation parameters allows for convenient and efficient selective non-compression of anonymous pages. This not only saves CPU power during compression but also avoids the time-consuming and CPU-intensive problem of deciding which anonymous pages to leave uncompressed based on compression ratios. In particular, it prevents stuttering under high load conditions where the reclamation thread occupies the CPU for extended periods, preventing the CPU from allocating resources to critical threads. Furthermore, it avoids the performance loss in critical scenarios when users use many applications within a short period under high load, as the compression ratio cannot be obtained in a short time due to the inability to perform targeted non-compression processing. Understandably, this method has real-time requirements.

[0061] Understandably, memory reclamation parameters may include, but are not limited to, the initial compression ratio of compressible anonymous pages in the application's reclaimable anonymous pages, the initial uncompressed ratio of uncompressed anonymous pages in the application's reclaimable anonymous pages, the initial number of compressed anonymous pages in the application's reclaimable anonymous pages, the initial number of uncompressed anonymous pages in the application's reclaimable anonymous pages, the initial compressed size in megabytes of the application's reclaimable anonymous pages, and the initial uncompressed size in megabytes of the application's reclaimable anonymous pages.

[0062] In some embodiments, the amount of anonymous pages corresponding to the memory reclamation parameters can be used as the number of compressible or non-anonymous pages among the anonymous pages reclaimable by the application. For example, if the memory reclamation parameters are the initial compression ratio of the anonymous pages that can be compressed among the anonymous pages reclaimable by the application, then the amount of anonymous pages corresponding to the initial compression ratio is used as the amount of anonymous pages that can be compressed among the anonymous pages reclaimable by the application. As another example, if the memory reclamation parameters are the initial uncompressed ratio of the anonymous pages that are not compressed among the anonymous pages reclaimable by the application, then the amount of anonymous pages corresponding to the initial uncompressed ratio is used as the amount of uncompressed anonymous pages among the anonymous pages reclaimable by the application.

[0063] In other embodiments, memory reclamation parameters can be adjusted based on electronic device status information (e.g., CPU load and memory usage) to determine the number of anonymous pages that can be compressed or not compressed from the reclaimable anonymous pages. Specific adjustment methods are described below. Figure 2B The details are elaborated in S202, and will not be repeated here.

[0064] In some implementations, memory reclamation parameters can be determined based on the characteristics of the application and the correspondence between these characteristics and memory reclamation parameters. The application characteristics can be the frequency of application use or the application's priority. The frequency of application use is determined by the duration or frequency of application use, while the application's priority is determined by the application's status information (e.g., usage time, importance, etc.).

[0065] Memory reclamation parameters vary depending on the frequency of application use; they can also differ depending on the application's priority. Specifically, memory reclamation parameters can be determined solely based on application frequency, solely based on application priority, or a combination of both.

[0066] (1) Determine memory reclamation parameters based on frequency

[0067] In some implementations, applications running on electronic devices can be categorized according to their frequency of use, with each category corresponding to different memory reclamation parameters.

[0068] For example, consider the memory reclamation parameter as either the initial compression ratio of compressible anonymous pages within the application's reclaimable anonymous pages, or the initial uncompressed ratio of uncompressed anonymous pages within the application's reclaimable anonymous pages. For categories with higher frequency of occurrence, the corresponding initial uncompressed ratio is lower, and the initial compression ratio is higher.

[0069] For example, taking the setting of two categories corresponding to the frequency of application use as an example, an initial uncompression ratio is configured for applications in category 1 and category 2 respectively. Category 1 represents frequently used applications, and category 2 represents less frequently used applications. The initial uncompression ratio of category 1 is less than that of category 2. When the phone is running at 100%, applications can be sorted according to their usage duration and frequency (where frequency takes precedence over duration). The top 50% of the most frequently used applications (hereinafter referred to as "first hot applications") are configured as category 1, and the bottom 50% of the least frequently used applications (hereinafter referred to as "first cold applications") are configured as category 2. At this time, the first hot applications and the first cold applications each have a corresponding initial uncompression ratio, and the initial uncompression ratio of the first hot applications is less than that of the first cold applications. If... Figure 2A The Notes app is used frequently and belongs to the category of high usage frequency; the Gallery app is used infrequently and belongs to the category of low usage frequency. In this case, the initial uncompressed ratio of the Notes app will be lower than that of the Gallery app.

[0070] Understandably, each user has different usage habits, meaning that the frequency of use of each application varies over historical periods. Since anonymous pages are sometimes stored on off-memory storage devices (e.g., disks) during recycling, the frequency of swapping anonymous pages in and out of off-memory storage also varies. For frequently used applications, the initial uncompressed ratio is lower, which helps reduce read / write operations on off-memory storage devices during frequent use and also reduces the amount of storage on off-memory storage devices. This avoids the excessive impact of frequent swapping in and out of off-memory storage devices on their lifespan, thus preventing a shortened lifespan.

[0071] (2) Determine memory reclamation parameters based on priority

[0072] In some embodiments, a priority value corresponding to the application priority can be obtained, wherein the priority and the priority value have opposite polarities, and a corresponding memory reclamation parameter can be configured for the priority value.

[0073] For example, consider the initial compression ratio of compressible anonymous pages within the application's reclaimable anonymous pages, or the initial uncompressed ratio of uncompressed anonymous pages within the application's reclaimable anonymous pages. Higher priority values ​​correspond to lower initial uncompressed ratios and lower initial compression ratios. For instance, suppose the initial uncompressed ratio for priority values ​​0-300 is 15%, and the initial uncompressed ratio for priority values ​​301-600 is 10%. If the application's priority value is 400, falling within the priority range of 301-600, then the corresponding initial uncompressed ratio is 10%.

[0074] Understandably, application priority is related to its state, such as the time of most recent use and its importance. During memory reclamation, lower-priority applications are prioritized, for example, those that haven't been used for a long time. Lower priority applications have a lower non-compression ratio, resulting in less space usage on external devices (like disks) and less impact on device lifespan. Furthermore, since non-compression is also performed during memory reclamation, CPU load is reduced.

[0075] (3) Determine memory reclamation parameters based on usage frequency and priority.

[0076] In some embodiments, application frequency and application priority can be divided into different subcategories. Then, the subcategories in the two groups of categories are combined in pairs to form a new merged category, and corresponding memory reclamation parameters are configured for the new merged category.

[0077] For example, a compression ratio or no compression ratio can be configured for a new merge category. Assuming there are subcategories based on frequency of use (11, ..., 1n) and subcategories based on priority (21, ..., 2n), the resulting merge categories would be (subcategory 11, subcategory 21), ..., (subcategory 1n, subcategory 2n). Each category in the merge category can then be configured with a no compression ratio. The no compression ratio can be determined based on the application's current frequency and priority, and can be used for subsequent memory reclamation.

[0078] Understandably, the initial number of compressed pages, initial number of uncompressed pages, initial compressed megabytes, and initial uncompressed megabytes are determined based on usage frequency or priority. This can be determined in the same way as the method described above for determining the initial uncompressed ratio based on usage frequency or priority. The principle is basically the same, so it will not be elaborated here.

[0079] It should be noted that the memory reclamation method provided in this application can be applied to any electronic device, including but not limited to user equipment (UE), mobile station (MS), and mobile terminal (MT). For example, electronic devices can be mobile phones, smart TVs, wearable devices, tablets, desktop computers, laptops, virtual reality (VR) devices, augmented reality (AR) devices, terminals in industrial control, self-driving, remote medical surgery, smart grids, transportation safety, smart cities, smart homes, and so on. This application does not limit the specific form of the electronic device.

[0080] Figure 2B According to some embodiments of this application, a flowchart of a memory reclamation method is shown. The method uses an electronic device as the execution entity, and the specific process includes:

[0081] S201, run the first application. The first application corresponds to the first memory reclamation parameter. The first memory reclamation parameter is used to determine the amount of anonymous pages that can be reclaimed by the first application and the amount of anonymous pages that will not be compressed.

[0082] In some embodiments, the first memory reclamation parameter may be a first initial number of anonymous pages that can be compressed among the anonymous pages reclaimable by the first application, or a second initial number of anonymous pages that cannot be compressed among the anonymous pages reclaimable by the first application. In some implementations, the memory reclamation parameter may be determined based on the characteristics of the application and the correspondence between the application characteristics and the memory reclamation parameter. The characteristics of the application may include the frequency of application use over a period of time and / or the application's priority.

[0083] For example, when the first initial quantity is the initial compression ratio mentioned above and the second initial quantity is the initial non-compression ratio mentioned above, the method for determining the first memory reclamation parameter is the same as the description above of obtaining the initial compression ratio or the initial non-compression ratio based on the frequency of use and / or the priority of the application, and will not be repeated here.

[0084] S202, based on the first memory reclamation parameters, determine the first number of anonymous pages that can be compressed and the second number of anonymous pages that cannot be compressed among the anonymous pages that can be reclaimed by the first application, and the sum of the first number and the second number is the number of anonymous pages that can be reclaimed by the first application.

[0085] In some embodiments, when the first memory reclamation parameter corresponds to the first initial quantity, the number of anonymous pages corresponding to the first initial quantity is taken as the first quantity, and the second quantity can be determined based on the number of anonymous pages that the first application can reclaim and the first quantity; when the first memory reclamation parameter corresponds to the second initial quantity, the number of anonymous pages corresponding to the second initial quantity is taken as the second quantity of uncompressed anonymous pages among the anonymous pages that the first application can reclaim, and the first quantity can be determined based on the number of anonymous pages that the first application can reclaim and the second quantity.

[0086] For example, the first initial quantity is the initial compression ratio. Assuming that the number of anonymous pages that the first application can reclaim is 8kb, and the first initial quantity is 90%, then the first quantity is 90% of the number of anonymous pages that the first application can reclaim, which is 7.2kb. The second quantity is 0.8kb.

[0087] For example, the second initial quantity is the initial uncompressed ratio. Suppose the number of anonymous pages that the first application can reclaim is 8kb, and the second initial quantity is 10%. In this case, the second quantity is 10% of the number of anonymous pages that the first application can reclaim, which is 0.8kb, and the first quantity is 7.2kb.

[0088] In other embodiments, when the first memory reclamation parameter corresponds to a first initial quantity, the first quantity of compressible anonymous pages among the reclaimable anonymous pages of the first application can be obtained by dynamically adjusting the parameter based on the electronic device's state information (e.g., current CPU load, memory usage). A second quantity can then be obtained based on the first quantity. Conversely, when the first memory reclamation parameter corresponds to a second initial quantity, the second quantity of uncompressible anonymous pages among the reclaimable anonymous pages of the first application can be obtained by dynamically adjusting the parameter based on the electronic device's state information. The first quantity can then be obtained based on the second quantity. It is understandable that dynamically adjusting the memory reclamation parameter based on the electronic device's state information, and then performing memory reclamation based on the adjusted result, makes the electronic device's memory reclamation more consistent with the system's current state and more real-time.

[0089] The following explanation uses the status information of an electronic device, including CPU load and memory status, as an example. When making adjustments based on CPU load and memory status, you can consider either the current CPU load or memory status, or you can consider both.

[0090] (1) Determine the first quantity and the second quantity based on the CPU load and the first initial quantity or the second initial quantity.

[0091] In some implementations, when the first memory reclamation parameter corresponds to the first initial quantity, the current CPU load is determined, and the CPU load is compared with the first CPU load threshold. When the CPU load is higher than or equal to the first CPU load threshold (i.e., the CPU load is high), the number of anonymous pages corresponding to the first initial quantity is taken as the first quantity, and the second quantity is determined based on the number of anonymous pages that the first application can reclaim and the first quantity. When the CPU load is lower than the first CPU load threshold (i.e., the CPU load is low), the first quantity is determined to be the number of anonymous pages that the first application can reclaim, that is, the second quantity is determined to be 0.

[0092] Furthermore, when the first memory reclamation parameter corresponds to the second initial quantity, the current CPU load is determined, and the CPU load is compared with the first CPU load threshold. When the CPU load is higher than or equal to the first CPU load threshold (i.e., the CPU load is high), the number of anonymous pages corresponding to the second initial quantity is taken as the second quantity, and the first quantity is determined based on the number of anonymous pages that the first application can reclaim and the second quantity. When the CPU load is lower than the first CPU load threshold (i.e., the CPU load is low), the first quantity is determined to be the number of anonymous pages that the first application can reclaim, that is, the second quantity is determined to be 0.

[0093] For example, using a first initial quantity as the initial compression ratio, assuming the first initial quantity is 90%, and the number of anonymous pages that the first application can reclaim is 8kb, when the CPU load is higher than or equal to a first CPU load threshold, the first quantity is 90% of the anonymous pages that the first application can reclaim, which is 7.2kb, and the second quantity is 0.8kb. When the CPU load is lower than the first CPU load threshold, the first quantity is 8kb, and the second quantity is 0.

[0094] For example, using a second initial quantity as the initial uncompressed ratio, assuming the second initial quantity is 10%, and the number of reclaimable anonymous pages in the first application is 8kb, when the CPU load is higher than or equal to the first CPU load threshold, the second quantity is 10% of the anonymous pages reclaimable by the first application, which is 0.8kb, and the first quantity is 7.2kb. When the CPU load is lower than the first CPU load threshold, the first quantity is 8kb, and the second quantity is 0.

[0095] Understandably, theoretically, the greater the memory reclamation benefit when anonymous pages are not compressed under high system load, the better. When CPU resources are plentiful, there's no need to conserve CPU resources for compression and decompression; compressing anonymous pages allows for more efficient memory utilization. By not compressing anonymous pages under high CPU load and compressing them under low load, the benefits and drawbacks of not compressing anonymous pages can be balanced, maximizing the benefits as quickly as possible. This also avoids the negative impacts on memory and external memory device lifespan, overall system memory status, and input / output (I / O) interface pressure (used for swapping in and out anonymous pages) during periods of low CPU idle time.

[0096] In other implementations, when the first memory reclamation parameter corresponds to a first initial quantity, the CPU load and a second CPU load threshold are compared. If the CPU load is higher than or equal to the second CPU load threshold, a first adjustment quantity is obtained by decreasing the first initial quantity, and the anonymous page quantity corresponding to the first adjustment quantity is used as the first quantity. If the CPU load is lower than or equal to the second CPU load threshold, the first initial quantity is not adjusted, and the anonymous page quantity corresponding to the first initial quantity is used as the first quantity. Alternatively, when the CPU load is lower than or equal to the second CPU load threshold, the first adjustment quantity can be obtained by increasing the first initial quantity, and the anonymous page quantity corresponding to the first adjustment quantity can be used as the first quantity.

[0097] Furthermore, when the first memory reclamation parameter corresponds to the second initial quantity, the CPU load is compared with the second CPU load threshold. If the CPU load is higher than or equal to the second CPU load threshold, the second initial quantity is increased to obtain the second adjustment quantity, and the anonymous page quantity corresponding to the second adjustment quantity is used as the second quantity. If the CPU load is lower than or equal to the second CPU load threshold, the second initial quantity is not adjusted, and the anonymous page quantity corresponding to the second initial quantity is used as the first quantity. Alternatively, when the CPU load is lower than or equal to the second CPU load threshold, the second initial quantity can be decreased to obtain the second adjustment quantity, and the anonymous page quantity corresponding to the second adjustment quantity is used as the second quantity.

[0098] For example, a pre-configured adjustment value corresponding to the CPU load (hereinafter referred to as "first adjustment value") is set. Assuming the first adjustment value is 5%, the first initial quantity is 90%, and the number of anonymous pages that the first application can reclaim is 8kb, if the current CPU load is greater than the second CPU load threshold, the first initial quantity is reduced by 5%, resulting in a first adjustment value of 85%. Then, the first quantity of the first application is the number of anonymous pages corresponding to the first adjustment value, which is 6.8kb. If the current CPU load is less than the second CPU load threshold, the first initial quantity is not adjusted, and the first quantity of the first application is 7.2kb.

[0099] For example, if the second initial quantity is 10%, the first adjustment value is 5%, and the number of anonymous pages that the first application can reclaim is 8kb, if the current CPU load is greater than the second CPU load threshold, the second initial quantity is increased by 5%, resulting in a second adjustment quantity of 15%. Then, the second quantity of the first application is the number of anonymous pages corresponding to the second adjustment quantity, which is 1.2kb. If the current CPU load is less than the second CPU load threshold, the second initial quantity is not adjusted.

[0100] Understandably, a higher CPU load indicates a shortage of CPU resources. Adjusting the load based on the CPU load is more suitable for the current state of the electronic device.

[0101] Furthermore, in some implementations, when the first memory reclamation parameter corresponds to a first initial quantity, if the CPU load is higher than or equal to a first CPU load threshold, and if the CPU load is higher than or equal to a second CPU load threshold (where the second CPU load threshold is greater than the first CPU load threshold), then the first initial quantity is reduced to obtain a first adjusted quantity. The anonymous page count corresponding to the first adjusted quantity is taken as the first quantity, and the first quantity is greater than or equal to 0. If the CPU load is lower than the second CPU load threshold, then the first initial quantity is not adjusted, and the anonymous page count corresponding to the adjustment of the first initial quantity is taken as the first quantity. Moreover, if the CPU load is lower than the first CPU load threshold, the first quantity is determined to be the number of anonymous pages that the first application can reclaim.

[0102] Furthermore, when the first memory reclamation parameter corresponds to the second initial quantity, if the CPU load is higher than or equal to the first CPU load threshold, and if the CPU load is higher than or equal to the second CPU load threshold (where the second CPU load threshold is greater than the first CPU load threshold), the second initial quantity is increased to obtain the second adjustment quantity, and the anonymous page quantity corresponding to the second adjustment quantity is used as the second quantity; if the CPU load is lower than the second CPU load threshold, the second initial quantity is not adjusted, and the anonymous page quantity corresponding to the second initial quantity is used as the second quantity.

[0103] For example, if the first adjustment value is 5%, the first initial quantity is 90%, and the number of recyclable anonymous pages for the first application is 8kb, and if the current CPU load is higher than the first CPU load threshold and the CPU load is also higher than the second CPU load threshold, the first initial quantity is reduced by 5%, resulting in a first adjustment quantity of 85%, and the first quantity is 6.8kb. If the current CPU load is lower than the second CPU load threshold, the first initial quantity is not adjusted, and the first quantity for the first application is 7.2kb.

[0104] For example, if the second initial quantity is 10%, the first adjustment value is 5%, and the number of anonymous pages that the first application can reclaim is 8kb, if the current CPU load is higher than the first CPU load threshold and the CPU load is also higher than the second CPU load threshold, the second initial quantity is increased by 5%, resulting in a second adjustment quantity of 15%. Then, the second quantity of the first application is the number of anonymous pages corresponding to the second adjustment quantity, which is 1.2kb. If the current CPU load is lower than the second CPU load threshold, the second initial quantity is not adjusted.

[0105] Understandably, when the CPU load is higher than or equal to the first CPU load threshold, indicating a high CPU load, a portion of the reclaimable anonymous pages in the first application are left uncompressed according to the first uncompressed ratio. When the CPU load is lower than the first CPU load threshold, indicating a low CPU load, all reclaimable anonymous pages in the first application are compressed. This ensures that the uncompressed anonymous page behavior only takes effect when the system load is high, saving CPU computing power and the power consumption of the reclamation thread. Furthermore, it reduces the impact of uncompressed behavior on the lifespan of various devices and the application's warm-up time, and also alleviates some CPU load. In addition, the supply of critical foreground thread resources improves. Moreover, dynamic adjustments based on the relationship between the current CPU and the second CPU load threshold make it applicable to different scenarios.

[0106] (2) Determine the first quantity and the second quantity based on the available memory parameter and the first initial quantity or the second initial quantity.

[0107] Understandably, when it comes to memory, if the available memory is smaller, the initial value needs to be reduced so that more anonymous pages are compressed, thereby increasing the available memory.

[0108] In some embodiments, the first memory parameter corresponds to a first initial quantity. To determine the current available memory parameter, when the available memory parameter is higher than or equal to the first memory parameter threshold, a first adjustment quantity is obtained by reducing the first initial quantity. The anonymous page quantity corresponding to the first adjustment quantity is used as the first quantity. If the first quantity is greater than or equal to 0, or if the first initial quantity is not adjusted, the anonymous page quantity corresponding to the first initial quantity is used as the first quantity. When the available memory parameter is lower than the first memory parameter threshold, the first adjustment quantity is obtained by increasing the first initial quantity. The anonymous page quantity corresponding to the first adjustment quantity is used as the first quantity.

[0109] Furthermore, the first memory parameter corresponds to the second initial quantity. When the available memory parameter is higher than or equal to the first memory parameter threshold, the second adjustment quantity is obtained by increasing the second initial quantity, and the anonymous page quantity corresponding to the second adjustment quantity is used as the second quantity; alternatively, the second initial quantity is not adjusted, and the anonymous page quantity corresponding to the second initial quantity is used as the second quantity. When the available memory parameter is lower than the first memory parameter threshold, the second adjustment quantity is obtained by decreasing the second initial quantity, and the anonymous page quantity corresponding to the second adjustment quantity is used as the second quantity.

[0110] For example, an adjustment value (hereinafter referred to as "second adjustment value") corresponding to the memory availability can be configured in advance. The second adjustment value is 2%, the first initial quantity is 90%, and the number of anonymous pages that the first application can reclaim is 8kb. When the available memory parameter is lower than the first memory parameter threshold, the first initial quantity is increased by 2%, resulting in a first adjustment value of 92%. Then, the first quantity corresponding to the first application is finally 7.36kb.

[0111] For example, if the second adjustment value is 2%, the second initial quantity is 10%, and the number of anonymous pages that the first application can reclaim is 8kb, and the available memory parameter is lower than the first memory parameter threshold, the second initial quantity is reduced by 2%, resulting in a second adjustment quantity of 8%. Then, the second quantity corresponding to the first application is finally 0.64kb.

[0112] It is understandable that the first or second initial quantity can be adjusted by considering only one of the current CPU load and memory status, or the first or second initial quantity can be adjusted by considering both CPU load and memory status.

[0113] For example, the initial quantity for the first application is 10%, the number of reclaimable anonymous pages for the first application is 8kb, the first adjustment value is 5%, and the second adjustment value is 2%. Assume that currently only the CPU load is compared with the first CPU load threshold, and it is determined that the current CPU load is greater than the first CPU load threshold, i.e., the CPU is currently under high load, requiring some anonymous pages to be compressed while others remain uncompressed. Then, the relationship between the available memory parameter and the first memory parameter threshold is further determined. When the available memory parameter is less than the first memory parameter threshold, the second initial quantity is reduced based on the available memory parameter to obtain the second adjustment quantity, which is 8%. The number of anonymous pages corresponding to this second adjustment quantity is used as the second quantity.

[0114] For example, suppose we only compare the CPU load with the second CPU load threshold, and determine that the current CPU load is greater than the second CPU load threshold, and that the available memory parameter is less than the first memory parameter threshold. That is, we need to increase the second initial value by 5% based on the first adjustment value, and we also need to decrease the second initial quantity by 2% based on the second adjustment value. After adjusting the second initial quantity based on the first adjustment value and the second adjustment value, we get the second adjusted quantity, which is 13%. The anonymous page quantity corresponding to the second adjusted quantity is taken as the second quantity.

[0115] For example, suppose the current CPU load is compared with both a first CPU load threshold and a second CPU load threshold. If the CPU load is determined to be higher than the first CPU load threshold, it indicates that some anonymous pages need to be compressed, while others should not be compressed. Furthermore, if the current CPU load is determined to be greater than the second CPU load threshold and the available memory parameter is less than the first memory parameter threshold, then a second adjustment quantity is obtained by increasing the second initial quantity based on the CPU load and decreasing the second initial quantity based on the available memory parameter. That is, the second initial quantity is increased by 5% based on the first adjustment value and decreased by 2% based on the second adjustment value, resulting in a final second adjustment quantity of 13%, or 1.04kb.

[0116] Understandably, the initial quantity is determined by considering application usage frequency, CPU load, and memory usage to comprehensively assess the overall system load, ensuring that the CPU resources saved by not compressing the system play a crucial role. Furthermore, the resulting initial quantity is a dynamic value that can change due to variations in these factors, thus better reflecting the current system status.

[0117] S203, compress a first number of anonymous pages in the first application's reclaimable anonymous pages for memory reclamation, and do not compress a second number of anonymous pages in the first application's reclaimable anonymous pages for memory reclamation.

[0118] In some embodiments, after obtaining the number of anonymous pages to be compressed and the number of anonymous pages not to be compressed, the first number of anonymous pages is compressed and the second number of anonymous pages are not compressed, and both are recycled to the swap partition in memory.

[0119] Understandably, initial or secondary memory reclamation parameters derived from application usage frequency, or based on priority, can be applied to various memory reclamation scenarios. For example, memory reclamation parameters related to application usage frequency can be used in scenarios requiring proactive memory reclamation, such as when an application is frozen in the background on an electronic device; in this case, the electronic device uses memory reclamation parameters corresponding to the application's usage frequency. Similarly, priority-related memory reclamation parameters can be used in low-memory reclamation scenarios where memory is insufficient, such as when the electronic device's system free memory is below the free memory reclamation threshold, or when the electronic device's available memory is below the available memory reclamation threshold; in this case, the electronic device uses memory reclamation parameters corresponding to the priority level.

[0120] To further understand, the following will be combined with... Figure 3 and Figure 4 The flowchart shown illustrates this point by using a memory reclamation parameter to indicate the second initial number of anonymous pages that can be reclaimed by the application without compression, and this second initial number being the initial uncompressed ratio. Figure 3 The memory reclamation method process is illustrated by taking the first initial uncompressed ratio (i.e., the first memory reclamation parameter) obtained based on the frequency of use of the first application, and the first initial uncompressed ratio adjusted based on CPU load and memory status to obtain the final first uncompressed ratio (i.e., the second adjustment quantity). Figure 4 The memory reclamation method process is specifically illustrated by taking the second initial non-compression ratio (i.e., the first memory reclamation parameter) obtained based on the priority of the first application, and the second non-compression ratio (i.e., the second adjustment amount) obtained based on the second initial non-compression ratio.

[0121] Figure 3 According to some embodiments of this application, a schematic flowchart of a memory reclamation method for obtaining a first non-compression ratio based on application usage frequency is shown. The execution entity of this process is an electronic device, and the specific process is as follows:

[0122] S301, Active Recycling.

[0123] It is understandable that electronic devices run many applications during operation, and each application may have different states. For example, an application may be displayed in the foreground, an application may be in the background and not frozen, and an application may be in the background and frozen.

[0124] In some embodiments, when an application is frozen in the background, it will not request new memory resources. When a background application is frozen, memory can be actively reclaimed to save memory space.

[0125] For example, a phone with a 100-inch screen will at least run apps like Notes and Gallery, and each app's corresponding anonymous page will exist in memory. (Reference) Figure 2A The diagram illustrates the corresponding anonymous pages for both the Notes app and the Gallery app. The memory contains at least the anonymous pages for both apps. Assuming the Notes app is switched to the background and then frozen after a period of time, memory can be actively reclaimed.

[0126] S302, determine whether the CPU load is higher than or equal to the first CPU load threshold. If so, proceed to S303 to obtain the first initial uncompression ratio corresponding to the usage frequency of the first application; otherwise, proceed to S308 to set the first uncompression ratio corresponding to the first application to 0.

[0127] In some embodiments, the electronic device is pre-configured with a first CPU load threshold. The load sensing module in the electronic device can actively sense the system load, such as the CPU load. If the current CPU load is higher than or equal to the set first CPU load threshold, the process proceeds to S303 to obtain the first initial uncompression ratio corresponding to the usage frequency of the first application. If the current CPU load is lower than the set first CPU load threshold, the process proceeds to S308 to set the first uncompression ratio to 0.

[0128] S303, obtain the first initial uncompression ratio corresponding to the frequency of use of the first application.

[0129] In some embodiments, the electronic device can pre-configure an application list and a corresponding initial uncompression ratio list. The application list contains applications of various categories, categorized by usage frequency. Each category corresponds to an initial uncompression ratio, meaning each application has a corresponding initial uncompression ratio in the initial uncompression ratio list. Usage frequency is related to the application's usage duration and frequency. After determining the category of a first application based on its usage frequency, the initial uncompression ratio corresponding to that category is the first initial uncompression ratio for the first application, denoted as z.

[0130] For example, if we set two categories corresponding to the frequency of application use, then the application categories corresponding to the frequency of use are "Hottest Application" and "Coldest Application". The Hottest Application and the Coldest Application each have a corresponding initial uncompression ratio value, and the initial uncompression ratio of the Hottest Application is less than that of the Coldest Application.

[0131] Specifically, electronic devices may include a hot / cold application sensing module to identify the popularity of applications. During the system boot phase, a function is called to initialize the hot / cold application sensing module. The system has a built-in hot / cold application list, where half of the applications are considered the most popular and half the most unpopular. A timer is triggered to periodically update the hot / cold application list based on the user's historical application usage information. The hot / cold application type depends on the frequency and duration of the user's use of the application, with frequency taking precedence over duration. Different uncompression ratios defined for hot / cold applications in the configuration file can be parsed to obtain an initial uncompression ratio list. At this point, each hot / cold application in the hot / cold application list has a corresponding initial uncompression ratio. During memory reclamation, the first application obtains the initial uncompression ratio corresponding to its hot / cold category as its first initial uncompression ratio, which is used to subsequently determine the first uncompression ratio for the first application.

[0132] S304, obtain the first adjustment value corresponding to the CPU load.

[0133] In some embodiments, the load sensing module determines whether the current CPU load is higher than the second CPU load threshold. The second CPU load threshold is greater than the first CPU load threshold. When the current CPU load is higher than the second CPU load threshold, a first adjustment value is obtained, assuming it is a.

[0134] S305, obtain the second adjustment value corresponding to the memory status.

[0135] In some embodiments, the load sensing module obtains the available memory status at this time. If the available memory is lower than the first memory parameter threshold, it obtains a second adjustment value, assuming it is b.

[0136] S306, calculate the final first uncompression ratio corresponding to the first application based on the first initial uncompression ratio, the first adjustment value, and the second adjustment value.

[0137] In some embodiments, the first uncompressed ratio can be obtained by subtracting the first adjustment value from the first initial uncompressed ratio and adding the second adjustment value, i.e., z+ab.

[0138] S307 sends the first uncompression ratio corresponding to the first application to the kernel.

[0139] S308, set the first uncompression ratio corresponding to the first application to 0.

[0140] In some embodiments, the first uncompression ratio corresponding to the first application is set to 0, that is, the second quantity is 0, and the first quantity is the number of anonymous pages that can be recycled in the first application.

[0141] S309, when controlling memory reclamation based on the first uncompressed ratio corresponding to the first application, the amount of uncompressed anonymous pages of the first application is controlled.

[0142] In some embodiments, based on a first uncompressed ratio, the number of uncompressed anonymous pages in the recyclable anonymous pages of the first application (i.e., a second number) and the number of compressed anonymous pages in the recyclable anonymous pages of the first application (i.e., a first number) can be obtained, thereby determining the uncompressed anonymous pages and the compressible anonymous pages in the recyclable anonymous pages of the first application.

[0143] S310, Recycle anonymous pages.

[0144] In some embodiments, when the kernel performs anonymous page reclamation, it skips the compression process for uncompressed anonymous pages and reclaims them into the swap partition in memory. Conversely, it compresses anonymous pages that require compression before reclaiming them into the swap partition. When the swap partition is insufficient, data can be swapped to disk.

[0145] It is understood that the execution order of steps S301 to S310 described above is only an example. In other embodiments, other execution orders may be used, and some steps may be split or combined. This is not limited here. For example, steps S303, S304, and S305 can be processed in any order, regardless of their specific sequence.

[0146] Understandably, the purpose of dynamically adjusting the uncompressed ratio of anonymous pages in the anonymous page reclamation process is to alleviate the CPU load caused by compression, ensure the supply of resources for critical threads, and improve user experience. When using zram technology to reclaim anonymous pages, after selectively compressing the reclaimed anonymous pages according to the uncompressed ratio, and in conjunction with the anonymous page write-to-disk function, the uncompressed anonymous pages can be promptly written to the disk. This avoids occupying too much space in memory, causing significant memory pressure, and thus triggering multiple scans of applications in memory, degrading application startup time.

[0147] Figure 4 According to some embodiments of this application, a schematic flowchart of a memory reclamation method for obtaining a second non-compression ratio based on priority is shown. The execution subject of this process is an electronic device, and the specific process is as follows:

[0148] S401, first application launch.

[0149] Understandably, when the first application is launched for the first time, it runs with priority.

[0150] S402, Application state switching.

[0151] It is understandable that during the operation of an application, there may be times when the application can switch from the first state to the second state.

[0152] For example, the first application can open in the foreground or switch between the foreground and background after startup.

[0153] S403, update the second initial uncompression ratio corresponding to the first application according to the priority of the first application.

[0154] In some embodiments, when there is a state transition of an application in an electronic device, the priority of each application in the electronic device will change.

[0155] For example, when the first application switches from the background to the foreground, its priority increases and its priority value decreases; conversely, when it switches from the foreground to the background, its priority decreases and its priority value increases. Furthermore, the priorities of other applications may also change. Because priorities change, the initial uncompressed ratio during recycling will also change. At this point, the second initial uncompressed ratio corresponding to the first application will be updated based on the first application's priority.

[0156] Understandably, during low-priority memory reclamation, applications with high priority values ​​are reclaimed first. Therefore, applications with lower priority values, such as those recently used by users, are initially less likely to be compressed.

[0157] S404, the system's free memory is below the free memory reclamation threshold or the available memory is below the available memory reclamation threshold, triggering the reclamation of anonymous pages.

[0158] Understandably, when the system's free memory is lower than the free memory reclamation threshold or the available memory is lower than the available memory reclamation threshold, it indicates that the current memory resources are tight. In this low memory reclamation scenario, electronic devices need to reclaim memory to save memory space.

[0159] S405, traverse the memory cgroup linked list to reclaim anonymous pages.

[0160] In some embodiments, the memory control group list is traversed one by one to reclaim application memory.

[0161] S406, the amount of uncompressible material during the recycling of the first application is controlled by the second uncompressible ratio of the first application, wherein the second uncompressible ratio is the second initial uncompressible ratio.

[0162] In some embodiments, the amount of uncompressed data when the first application is recycled can be determined based on the second uncompressed ratio (i.e., the second quantity), and the amount of compressed data when the first application is recycled (i.e., the first quantity) can be obtained based on the number of recyclable anonymous pages of the first application and the amount of uncompressed data when the first application is recycled.

[0163] S407, Recycle anonymous pages.

[0164] It is understood that the execution order of steps S401 to S407 above is only an example. In other embodiments, other execution orders may be used, and some steps may be split or combined. This is not limited here.

[0165] Understandably, the embodiments of this application have already decided on the non-compression ratio before the anonymous pages are reclaimed. Therefore, the decision-making cost of determining not to compress anonymous pages is low and there is no waste of CPU resources.

[0166] Figure 5 According to some embodiments of this application, a schematic diagram of the software system architecture of a mobile phone 100 is shown.

[0167] like Figure 5 As shown, the software system architecture can be divided into four layers, from top to bottom: application layer 510, framework layer 520, kernel layer 530, and storage driver and device layer 540.

[0168] The application layer 510 includes various applications for users, such as calendar, gallery, and memo.

[0169] The framework layer 520 provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. For example... Figure 5 As shown, the framework layer 520 can detect changes in the application state caused by user operations. For example, when an application switches between foreground and background, or when an application freezes after a certain period of time after switching to the background. Furthermore, when memory reclamation is required, it determines the non-compression ratio of each application based on changes in application behavior, and then sends the non-compression ratio of each application to the kernel layer 530.

[0170] Specifically, when the framework layer 520 performs proactive garbage collection, it does so based on application usage frequency, CPU load, and memory usage, according to... Figure 2B The method shown in S202 determines the uncompressed ratio (referred to as "third uncompressed ratio") for each application in this recycling. The third uncompressed ratio of each application is then sent to the kernel layer 530.

[0171] Furthermore, when an application state transition occurs, the priority of each application in the framework layer 520 can also be updated. At this time, the uncompressed ratio of the corresponding priority of each application will also be updated, resulting in the updated uncompressed ratio (referred to as the "fourth uncompressed ratio"). The framework layer 520 obtains the fourth uncompressed ratio (referred to as the "fourth uncompressed ratio") of each application, and when it determines that low memory reclamation is required, it obtains the fourth uncompressed ratio of each application and sends it to the kernel layer 530.

[0172] In some implementations of this application, the framework layer 520 may include a hot / cold application identification module, a load awareness module, etc. Specifically, during the boot-up phase, the mobile phone 100 can call an initialization function to complete the initialization actions of the corresponding hot / cold application identification module and load awareness module. Every 24 hours after boot-up, the hot / cold application identification module will update the first hot / cold application and its corresponding initial uncompressed ratio based on the collected user's historical application usage information. Each time an application is frozen, the active recycling process is triggered, which calls the load awareness module to obtain the current CPU load information and decides whether to enable the uncompressed function for this active recycling, i.e., whether the uncompressed ratio needs to be set to 0. When uncompressed is required, the initial uncompressed ratio corresponding to the application usage frequency of each application, the adjustment ratio corresponding to the CPU load, and the adjustment ratio corresponding to the memory status are obtained from the hot / cold application identification module and the load awareness module. The final third uncompressed ratio corresponding to each application in the active recycling scenario is calculated and passed to the kernel layer 530. Furthermore, during application state switching, the fourth uncompressed ratio corresponding to each application in low memory reclamation scenarios is updated in real time based on the initial uncompressed ratio corresponding to the application's priority, and this fourth uncompressed ratio is then passed to the kernel layer 530. Understandably, in both active and low memory reclamation scenarios, the uncompressed ratio of each application can be dynamically adjusted, allowing some cold data to be stored in the memory swap partition without compression during memory reclamation. This reduces the CPU load generated by the compression and decompression processes and minimizes the negative impact of uncompressed anonymous pages on memory and the lifespan of external storage devices.

[0173] Kernel layer 530 is the layer between hardware and software. The memory control group in kernel layer 530 can set the proportion of uncompressed anonymous pages in each application based on the received third or fourth uncompressed ratio. It calculates the amount of uncompressed pages based on the third or fourth uncompressed ratio, isolates the anonymous pages that do not need compression, and then reclaims the isolated and compressed anonymous pages into the memory swap partition. After the swap-out condition is triggered, the uncompressed anonymous pages are finally written to disk using the file system (Unix file system, UFS) in storage driver and device layer 540, and stored in the disk swap space. Understandably, although some anonymous pages are not compressed, this does not cause a prolonged impact on memory.

[0174] Figure 6 According to some embodiments of this application, a structural schematic diagram of a mobile phone 100 is shown. When the electronic device is a terminal device, it may adopt the same or similar structure as the mobile phone 100.

[0175] like Figure 6 As shown, the mobile phone 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 01, an antenna 02, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0176] It should be noted that the structure of the mobile phone 100 shown in the embodiments of this application does not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than shown, or combine some components, or split some components, or have different component arrangements. The components shown can be implemented in hardware, software, or a combination of software and hardware.

[0177] In some embodiments of this application, a readable storage medium is provided, which includes one or more programs. When executed on an electronic device, the one or more programs cause the electronic device to implement any of the above-described memory reclamation methods. For example, the above-described methods can be implemented. Figure 2B , Figure 3 as well as Figure 4 The memory reclamation method shown.

[0178] In some embodiments of this application, an electronic device is provided, comprising: at least one memory for storing one or more programs; and at least one processor for executing the one or more programs to enable the electronic device to implement any of the memory reclamation methods described above. For example, the above can be implemented. Figure 2B , Figure 3 as well as Figure 4 The memory reclamation method shown.

[0179] In some embodiments of this application, a program product is provided that, when executed on an electronic device, enables the electronic device to implement any of the aforementioned memory reclamation methods. For example, the above-described methods can be implemented. Figure 2B , Figure 3 as well as Figure 4 The memory reclamation method shown.

[0180] In some embodiments of this application, a chip is provided that, when executed on an electronic device, enables the electronic device to implement any of the above-described memory reclamation methods. For example, the above-described methods can be implemented. Figure 2B , Figure 3 as well as Figure 4 The memory reclamation method shown.

[0181] It should be noted that in the embodiments of this application, "or" describes the relationship between related objects, indicating that there can be two relationships. For example, A or B can mean either A or B, where A or B can be singular or plural.

[0182] It should be noted that the term "connection" used in the embodiments of this application describes the connection relationship between two objects and can represent two kinds of connection relationships. For example, the connection between A and B can represent two situations: A is directly connected to B, and A is connected to B through C.

[0183] It should be noted that in the embodiments of this application, terms such as "for example," "in some embodiments," "in another embodiment," and "exemplarily" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as an "example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the term "example" is intended to present concepts in a concrete manner.

[0184] It should be noted that the terms "first" and "second" used in the embodiments of this application are only used for descriptive purposes and should not be construed as indicating or implying relative importance or order. The term "equal to" in the embodiments of this application can be used with "higher than" to apply to technical solutions adopted when "higher than," and can also be used with "lower than" to apply to technical solutions adopted when "lower than." It should be noted that when "equal to" is used with "higher than," it is not used with "lower than," and vice versa.

[0185] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Furthermore, the inclusion of structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.

[0186] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.

Claims

1. A memory reclamation method, characterized in that, Applied to electronic devices, the method includes: Run the first application, which corresponds to the first memory reclamation parameter. The first memory reclamation parameter is used to determine the amount of anonymous pages that can be reclaimed by the first application and the amount of anonymous pages that are not compressed. Based on the first memory reclamation parameters, determine the first number of anonymous pages that can be compressed and the second number of anonymous pages that cannot be compressed among the anonymous pages that can be reclaimed by the first application. The sum of the first number and the second number is the number of anonymous pages that can be reclaimed by the first application. The first number of anonymous pages among the recyclable anonymous pages of the first application are compressed for memory reclamation, while the second number of anonymous pages are not compressed for memory reclamation.

2. The method according to claim 1, characterized in that, The first memory reclamation parameter indicates the first initial number of anonymous pages that can be compressed among the anonymous pages that the first application can reclaim; The step of determining the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the reclaimable anonymous pages of the first application based on the first memory reclamation parameters includes: The number of anonymous pages corresponding to the first initial quantity is taken as the first quantity; The second quantity is determined based on the number of recyclable anonymous pages in the first application and the first quantity; or, The first memory reclamation parameter indicates a second initial number of uncompressed anonymous pages among the anonymous pages reclaimable by the first application; The step of determining the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the reclaimable anonymous pages of the first application based on the first memory reclamation parameters includes: The number of anonymous pages corresponding to the second initial quantity is taken as the second quantity; The first quantity is determined based on the number of anonymous pages that can be reclaimed by the first application and the second quantity.

3. The method according to claim 1, characterized in that, The first memory reclamation parameter indicates the first initial number of anonymous pages that can be compressed among the anonymous pages that the first application can reclaim; The step of determining the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the reclaimable anonymous pages of the first application based on the first memory reclamation parameters includes: The first initial quantity is determined based on the first memory reclamation parameters; The first quantity is determined based on the status information of the electronic device and the first initial quantity; The second quantity is determined based on the number of recyclable anonymous pages in the first application and the first quantity; or, The first memory reclamation parameter indicates a second initial number of uncompressed anonymous pages among the anonymous pages reclaimable by the first application; The step of determining the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the reclaimable anonymous pages of the first application based on the first memory reclamation parameters includes: The second initial quantity is determined based on the first memory reclamation parameters; The second quantity is determined based on the status information of the electronic device and the second initial quantity; The first quantity is determined based on the number of anonymous pages that can be reclaimed by the first application and the second quantity.

4. The method according to claim 3, characterized in that, The status information of the electronic device includes the CPU load of the electronic device; Determining the first quantity based on the status information of the electronic device and the first initial quantity includes: Determine the CPU load; When the CPU load is higher than or equal to the first CPU load threshold, the number of anonymous pages corresponding to the first initial number will be used as the first number. When the CPU load is lower than the first CPU load threshold, the first quantity is determined to be the number of anonymous pages that the first application can reclaim; or, Determining the second quantity based on the status information of the electronic device and the second initial quantity includes: Determine the CPU load; When the CPU load is higher than or equal to the first CPU load threshold, the number of anonymous pages corresponding to the second initial number will be used as the second number. When the CPU load is lower than the first CPU load threshold, the second quantity is determined to be 0.

5. The method according to claim 3, characterized in that, The status information of the electronic device includes the CPU load of the electronic device. Determining the first quantity based on the status information of the electronic device and the first initial quantity includes: Determine the CPU load; When the CPU load is higher than or equal to the second CPU load threshold, the first quantity is obtained by reducing the first initial quantity, and the first quantity is greater than or equal to 0; or When the CPU load is lower than the second CPU load threshold, the first quantity is obtained by increasing the first initial quantity. or, Determining the second quantity based on the status information of the electronic device and the second initial quantity includes: Determine the CPU load; When the CPU load is higher than or equal to the second CPU load threshold, the second quantity is obtained by increasing the second initial quantity; or When the CPU load is lower than the second CPU load threshold, the second quantity is obtained by reducing the second initial quantity, and the second quantity is greater than or equal to 0.

6. The method according to claim 3, characterized in that, The status information of the electronic device includes the CPU load of the electronic device. Determining the first quantity based on the status information of the electronic device and the first initial quantity includes: Determine the CPU load; When the CPU load is higher than or equal to a first CPU load threshold, if the CPU load is higher than or equal to a second CPU load threshold, then the first quantity is obtained by reducing the first initial quantity, the first quantity is greater than or equal to 0, and the second CPU load threshold is greater than the first CPU load threshold; or When the CPU load is lower than a first CPU load threshold, the first quantity is determined to be the number of anonymous pages that the first application can reclaim; or Determining the second quantity based on the status information of the electronic device and the second initial quantity includes: Determine the CPU load; When the CPU load is higher than or equal to a first CPU load threshold, if the CPU load is higher than or equal to a second CPU load threshold, then the second quantity is obtained by increasing the second initial quantity, where the second CPU load threshold is greater than the first CPU load threshold; or When the CPU load is lower than the first CPU load threshold, the second quantity is determined to be 0.

7. The method according to any one of claims 3 to 6, characterized in that, The status information of the electronic device includes the available memory parameters of the electronic device; Determining the first quantity based on the status information of the electronic device and the first initial quantity includes: Determine the available memory parameters; When the available memory parameter is higher than or equal to the first memory parameter threshold, the first quantity is obtained by reducing the first initial quantity, where the first quantity is greater than or equal to 0, or When the available memory parameter is lower than the first memory parameter threshold, the first quantity is obtained by increasing the first initial quantity; or Determining the second quantity based on the status information of the electronic device and the second initial quantity includes: Determine the available memory parameters; When the available memory parameter is higher than or equal to the first memory parameter threshold, the second quantity is obtained by increasing the second initial quantity, or When the available memory parameter is lower than the first memory parameter threshold, the second quantity is obtained by reducing the second initial quantity, and the second quantity is greater than or equal to 0.

8. The method according to any one of claims 1 to 7, characterized in that, Before determining, based on the first memory reclamation parameters, the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the reclaimable anonymous pages of the first application, the method further includes: The first memory reclamation parameters are determined based on the characteristics of the first application and the correspondence between the application's characteristics and the memory reclamation parameters.

9. The method according to claim 8, characterized in that, The characteristics of the application include: the frequency of application use, and / or the application priority.

10. The method according to claim 9, characterized in that, The applications in the electronic device include: applications with a first degree of frequency and applications with a second degree of frequency; The correspondence between the characteristics of the application and the memory reclamation parameters includes: the first frequency corresponds to the first memory reclamation parameter, and the second frequency corresponds to the second memory reclamation parameter.

11. The method according to claim 9 or 10, characterized in that, The applications in the electronic device include: applications with first priority and applications with second priority; The correspondence between the application's characteristics and memory reclamation parameters includes: the first priority corresponds to the first memory reclamation parameter, and the second priority corresponds to the second memory reclamation parameter.

12. The method according to claim 11, characterized in that, The priority of applications in the electronic device is determined based on the application's status information.

13. The method according to claim 12, characterized in that, The application's status information includes at least one of the following: application usage time and importance level.

14. The method according to any one of claims 1 to 13, characterized in that, Before determining, based on the first memory reclamation parameters, the first number of compressible anonymous pages and the second number of uncompressed anonymous pages among the reclaimable anonymous pages of the first application, the method further includes: It is determined that the first application switches from a first state to a second state, and the system idle memory of the electronic device is lower than the idle memory reclamation threshold, or the available memory of the electronic device is lower than the available memory reclamation threshold.

15. A readable storage medium, characterized in that, The readable storage medium includes one or more programs that, when executed on an electronic device, cause the electronic device to implement the memory reclamation method according to any one of claims 1 to 14.

16. An electronic device, characterized in that, include: Memory, used to store one or more programs; At least one processor is configured to execute the one or more programs to cause the electronic device to implement the memory reclamation method of any one of claims 1 to 14.

17. A program product, characterized in that, When the program product is executed on an electronic device, it causes the electronic device to implement the memory reclamation method according to any one of claims 1 to 14.