Memory reclamation methods, electronic devices, storage media, software products and chips

By performing differentiated memory reclamation based on application type, the impact of frequent memory reclamation on the lifespan of storage devices is resolved, resulting in a longer lifespan for storage devices and an improved user experience.

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

Patent Information

Application Number
CN202510631737.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Frequent memory reclamation can shorten the lifespan of storage devices.

Method used

Based on the application's usage data, determine the application type (such as popular applications, ordinary applications, high-frequency applications, low-frequency applications, etc.), and perform differentiated reclamation of the application's memory space according to the reclamation data corresponding to the application type.

Benefits of technology

This reduces the read/write operations on storage devices, extends their lifespan, and ensures a better user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114718A_ABST
    Figure CN123114718A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of mobile terminals, in particular to a memory recycling method, an electronic device, a storage medium, a program product and a chip. In the method, the electronic device can determine the application type of an application according to the use data of the application, for example, a hotspot application, a common application, a high-frequency application, a low-frequency application, a high-frequency hotspot application, a low-frequency common application and the like, and then recycle the memory space corresponding to the application according to the recycling data corresponding to the application type. In this way, the memory space corresponding to the application is recycled differently according to the use data of the application, frequent memory recycling can be avoided, and the service life of the storage device can be prolonged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of mobile terminal technology, and in particular to a memory recycling method, electronic device, storage medium, program product, and chip. Background Technology

[0002] With the widespread application of data compression and disk persistence technology, the operating system can allocate memory for running applications, such as anonymous pages, to store application-related data. Furthermore, the operating system can reclaim memory using this technology, for example, compressing data in anonymous pages and transferring it to a storage device (such as a disk), and then reallocating the freed-up memory to other applications that need it, thus making full use of limited memory.

[0003] To make full use of memory, the operating system can perform frequent memory reclamation. However, since storage devices have a limited lifespan—for example, the number of read / write operations a storage device can perform is fixed—frequent memory reclamation will affect the lifespan of the storage device. Summary of the Invention

[0004] This application provides a memory reclamation method, electronic device, storage medium, program product, and chip to solve the problem of frequent memory reclamation affecting the lifespan of storage devices.

[0005] In a first aspect, embodiments of this application provide a memory reclamation method applied to an electronic device, comprising: acquiring first usage data of a first application; determining a first application type of the first application based on the first usage data; and, if the first application type is a first type, reclaiming memory in a first memory space corresponding to the first application based on the first reclamation data; or, if the first application type is a second type, reclaiming memory in a first memory space corresponding to the first application based on the second reclamation data; wherein the first reclamation data and the second reclamation data are different.

[0006] Based on the above scheme, by determining the first application type according to the user's usage habits of the first application during the first sampling period, such as a popular application, a normal application, or a high-frequency application, different data reclamation (e.g., amount of reclamation data or number of reclamations) is used to reclaim memory corresponding to the first application based on its application type. This avoids the problem of frequent memory reclamation affecting the lifespan of storage devices. By adopting a scheme of differentiated memory reclamation based on the application type, the memory pressure on electronic devices can be reduced while simultaneously reducing the read / write operations of storage devices, thereby extending the lifespan of storage devices and improving the user experience.

[0007] In some implementations of the first aspect, the first usage data includes the first usage duration and / or the first usage frequency within the first sampling period.

[0008] In some implementations, the electronic device can acquire the first usage duration and / or first usage frequency of the first application within a first sampling period, and use the first usage duration and / or first usage frequency of the first application within the first sampling period as first usage data. The first sampling period can be a period pre-stored by the electronic device, such as a day, a week, or a month, and this application embodiment does not limit this.

[0009] Furthermore, the first sampled data can represent a user's usage habits of the first application within the first sampling period. For example, if the first usage duration exceeds the preset usage duration, the first sampled data can indicate that the user uses the first application for an extended period within the first sampling period; similarly, if the first usage frequency exceeds the preset usage frequency, the first sampled data can indicate that the user frequently uses the first application within the first sampling period; and furthermore, if both the first usage duration and the first usage frequency exceed the preset usage frequency, the first sampled data can indicate that the user frequently uses the first application for an extended period within the first sampling period.

[0010] In some implementations of the first aspect, the method further includes: obtaining second usage data of the first application, the second usage data including second usage duration and / or second usage frequency within a second sampling period, the second sampling period being later than the first sampling period; determining the second application type of the first application based on the second usage data; and, if the second application type is the first type, reclaiming the second memory space corresponding to the first application based on third reclamation data, wherein the third reclamation data is different from the first reclamation data.

[0011] Based on the above scheme, by determining the first application type (e.g., popular, common, or frequently used) according to the user's usage habits of the first application during the first sampling period, different amounts of data or frequency of memory reclamation are applied to the first memory corresponding to the first application. Furthermore, by dynamically adjusting the amount of data reclaimed from the memory space corresponding to the application based on the user's usage habits in different sampling periods, the memory pressure on electronic devices can be further reduced while ensuring a good user experience.

[0012] In some implementations of the first aspect, the method further includes: obtaining third usage data of the first application, the third usage data including third usage duration and / or third usage frequency within a third sampling period, the third sampling period being later than the first sampling period; determining the third application type of the first application based on the third usage data; and, if the third application type is the second type, reclaiming the third memory space corresponding to the first application based on fourth reclamation data, wherein the fourth reclamation data is different from the first reclamation data.

[0013] Based on the above scheme, by determining the first application type (e.g., popular, common, or frequently used) according to the user's usage habits of the first application during the first sampling period, different amounts of data or frequency of memory reclamation are applied to the first memory space corresponding to the first application. Furthermore, dynamically adjusting the reclamation data for the application's memory space when the user's usage habits change further reduces the memory pressure on electronic devices while ensuring a good user experience.

[0014] In some implementations of the first aspect, the first application type of the first application is determined based on the first usage data, including: when the first usage duration is greater than the preset usage duration, the first application type of the first application is determined to be a first type; when the first usage duration is less than or equal to the preset usage duration, the first application type of the first application is determined to be a second type.

[0015] In some implementations of the first aspect, the first application type of the first application is determined based on the first usage data, including: when the first usage frequency is greater than the preset usage frequency, the first application type of the first application is determined to be a first type; when the first usage frequency is less than or equal to the preset usage frequency, the first application type of the first application is determined to be a second type.

[0016] In some implementations of the first aspect, the first application type of the first application is determined based on the first usage data, including: when the first usage duration is greater than the preset usage duration and the first usage frequency is greater than the preset usage frequency, the first application type of the first application is determined to be a first type; when the first usage duration is less than or equal to the preset usage duration and the first usage frequency is less than or equal to the preset usage frequency, the first application type of the first application is determined to be a second type.

[0017] In some implementations of the first aspect, determining the first application type of the first application based on the first usage data includes: determining the first application type of the first application as the first type when the first usage duration is less than or equal to the preset usage duration and the first usage frequency is greater than the preset usage frequency.

[0018] In some implementations of the first aspect, the first type includes any one of the following: hot application type, high-frequency application type, or high-frequency hot application type; the second type includes any one of the following: ordinary application type, low-frequency application type, or low-frequency ordinary application type.

[0019] In some implementations of the first aspect, the third recycled data is greater than the first recycled data when the second usage duration is greater than the first usage duration, or when the second usage frequency is greater than the first usage frequency.

[0020] In some implementations of the first aspect, the first recycled data and the second recycled data include any one of the following: the number of recyclings and the amount of recycled data; the first recycled data and the second recycled data satisfy recycling conditions, wherein the recycling conditions include at least one of the following: the number of recyclings is less than or equal to a recycling number threshold; or, the amount of recycled data is less than or equal to a recycling data amount threshold.

[0021] In a second aspect, embodiments of this application provide an electronic device, including: a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the one or more processors of the electronic device, for executing the memory reclamation method mentioned in the first aspect or any one of the first aspects.

[0022] Thirdly, embodiments of this application provide a readable storage medium storing instructions that, when executed on an electronic device, cause the electronic device to perform the memory reclamation method mentioned in the first aspect or any of the first aspects.

[0023] Fourthly, embodiments of this application provide a computer program product, which includes computer instructions that, when executed by an electronic device, enable the electronic device to perform a memory reclamation method as described in the first aspect or any of the first aspects.

[0024] Fifthly, embodiments of this application provide a chip including a processor coupled to a memory for executing computer programs or instructions stored in the memory, such that the chip implements the memory reclamation method mentioned in the first aspect or any one of the first aspects.

[0025] It is understood that the specific implementation methods and beneficial effects of the second to fifth aspects mentioned above can refer to the relevant descriptions of the memory reclamation methods in the first aspect or any of the various implementation methods provided by the first aspect, and will not be repeated here. Attached Figure Description

[0026] Figure 1 According to an embodiment of this application, a schematic diagram of the structure of a first electronic device is shown;

[0027] Figure 2 According to an embodiment of this application, a schematic diagram of the structure of a second electronic device is shown;

[0028] Figure 3 According to an embodiment of this application, a flowchart of a first memory reclamation method is shown;

[0029] Figure 4 According to an embodiment of this application, a flowchart of a second memory reclamation method is shown;

[0030] Figure 5 According to an embodiment of this application, a flowchart of a third memory reclamation method is shown;

[0031] Figure 6 According to an embodiment of this application, a schematic diagram of the structure of a third electronic device is shown;

[0032] Figure 7 According to an embodiment of this application, a schematic diagram of the hardware structure of an electronic device is shown. Detailed Implementation

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

[0034] It is understood that the memory reclamation method mentioned in the embodiments of this application can be applied to electronic devices. In some implementations, electronic devices can be referred to as terminals, user equipment (UE), mobile stations (MS), mobile terminals (MT), etc. For example, electronic devices can be mobile phones, tablets, computers with wireless transceiver capabilities, smart TVs, wearable devices, virtual reality (VR) terminal devices, augmented reality (AR) terminal devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, and other similar devices.

[0035] It is understandable that the operating system can reclaim memory through data compression and disk persistence technology, and redistribute the freed memory to other applications that need it, thereby making full use of limited memory resources.

[0036] The following section introduces some memory reclamation methods.

[0037] like Figure 1 The diagram shows a schematic representation of the structure of a first type of electronic device. This electronic device may include a software architecture and a hardware architecture. The software architecture may include an application layer, a system service layer, and a kernel layer. The hardware architecture may include a storage device.

[0038] In some implementations, the application layer can include application packages of a series of applications. Examples include application packages for news applications, video applications, and game applications.

[0039] The system service layer can provide services to applications in the application layer. For example, the system service layer may include an anonymous page swapping restriction module. This module can be used to detect whether the memory in an electronic device meets the reclamation conditions. For instance, the module can detect whether the available memory in the electronic device is less than a preset memory capacity. If the available memory is found to be less than the preset capacity, the module can determine that the memory in the electronic device meets the memory reclamation conditions.

[0040] The kernel layer is the layer between the software architecture and the hardware structure, and it is responsible for managing system resources, scheduling processes, and providing hardware interfaces. For example, when the memory in an electronic device meets the reclamation criteria, the kernel layer can compress the data in anonymous pages and transfer it to the storage device.

[0041] Storage devices can include multiple swap partitions. For example, an anonymous swap partition.

[0042] In some implementations, the kernel layer can compress the data in anonymous pages and transfer it to the anonymous swap partition in the storage device when the memory in the electronic device meets the reclamation conditions, so as to alleviate the memory pressure in the electronic device and ensure the normal operation of the electronic device.

[0043] Currently, operating systems not only reclaim anonymous pages through data compression and disk persistence technology, but also reclaim memory for graphics processing unit (GPU) memory and direct memory access (DMA) memory.

[0044] like Figure 2 The diagram illustrates the structure of a second type of electronic device. This electronic device may include a software architecture and a hardware architecture. The software architecture may include an application layer, a system service layer, and a kernel layer. The hardware architecture may include a storage device.

[0045] In some implementations, the application layer can include application packages of a series of applications. Examples include application packages for news applications, video applications, and game applications.

[0046] The system service layer can provide services to applications in the application layer. For example, the system service layer can provide a service to detect whether the memory in an electronic device meets the conditions for reclamation.

[0047] The kernel layer is the layer between the software architecture and the hardware structure, and it is responsible for managing system resources, scheduling processes, and providing hardware interfaces. For example, when the memory in an electronic device meets the reclamation criteria, the kernel layer can transfer data from memory to storage devices.

[0048] Storage devices may include multiple swap partitions. For example, swap partition 1 (i.e., the anonymous swap partition mentioned above), swap partition 2, and swap partition 3.

[0049] In some implementations, the kernel layer can compress and transfer data from anonymous pages to swap partition 1 in the storage device, transfer data from DMA memory to swap partition 2, and transfer data from GPU memory to swap partition 3, provided that the memory in the electronic device meets the reclamation conditions. This can alleviate memory pressure in the electronic device and ensure its normal operation.

[0050] However, because the amount of data in DMA memory and GPU memory is relatively large, the amount of data reclaimed each time is also large, resulting in more read and write operations during each memory reclamation, which further affects the lifespan of the storage device.

[0051] To address the aforementioned problems, this application provides a memory reclamation method. In this method, the electronic device can determine the application type based on application usage data, such as popular applications, normal applications, high-frequency applications, low-frequency applications, high-frequency popular applications, and low-frequency normal applications. Then, based on the reclamation data corresponding to the application type, the memory space corresponding to the application is reclaimed. Thus, by reclaiming the memory space corresponding to the application based on its usage data, frequent memory reclamation can be avoided, thereby extending the lifespan of the storage device.

[0052] The memory reclamation method mentioned in the embodiments of this application will be described in detail below.

[0053] like Figure 3 The diagram illustrates a flowchart of a first memory reclamation method. This memory reclamation method can be executed by an electronic device, and in some implementations, it may include:

[0054] S301: Obtain the first usage data of the first application.

[0055] It is understood that the first application can be any application on the electronic device, such as a payment application, news application, video application, or game application. The first usage data can include the first usage duration and the first usage frequency.

[0056] In some implementations, the electronic device can acquire the first usage duration and / or first usage frequency of the first application within a first sampling period, and use the first usage duration and / or first usage frequency of the first application within the first sampling period as first usage data. The first sampling period can be a period pre-stored by the electronic device, such as a day, a week, or a month, and this application embodiment does not limit this.

[0057] Furthermore, the first sampled data can represent a user's usage habits of the first application within the first sampling period. For example, if the first usage duration exceeds the preset usage duration, the first sampled data can indicate that the user uses the first application for an extended period within the first sampling period; similarly, if the first usage frequency exceeds the preset usage frequency, the first sampled data can indicate that the user frequently uses the first application within the first sampling period; and furthermore, if both the first usage duration and the first usage frequency exceed the preset usage frequency, the first sampled data can indicate that the user frequently uses the first application for an extended period within the first sampling period.

[0058] S302: Based on the first usage data, determine the first application type of the first application.

[0059] It is understood that after acquiring the first usage data of the first application, the electronic device can determine the first application type of the first application based on the first usage data. The first application type can be either a first type or a second type. The first type can be a hot application type, a high-frequency application type, or a high-frequency hot application type. The second type can be a normal application type, a low-frequency application type, or a low-frequency normal application type. It is understood that the first application type can also be other types, and this application embodiment does not specifically limit it.

[0060] In some implementations, if the first usage duration exceeds a preset usage duration, the electronic device can determine that the first application type of the first application is a first type. The first type can be a popular application type. If the first usage duration is less than or equal to the preset usage duration, the electronic device can determine that the first application type of the first application is a second type. The second type can be a regular application.

[0061] In other implementations, if the first usage frequency is greater than a preset usage frequency, the electronic device can determine that the first application type of the first application is a first type. Here, the first type can be a high-frequency application type. If the first usage frequency is less than or equal to the preset usage frequency, the electronic device can determine that the first application type of the first application is a second type. Here, the second type can be a low-frequency application type.

[0062] In other implementations, if the first usage duration is greater than a preset usage duration and the first usage frequency is greater than a preset usage frequency, the electronic device can determine that the first application type of the first application is a first type. Here, the first type can be a high-frequency, frequently used application type. If the first usage duration is less than or equal to a preset usage duration and the first usage frequency is less than or equal to a preset usage frequency, the electronic device can determine that the first application type of the first application is a second type. Here, the second type can be a low-frequency, ordinary application type.

[0063] S303: If the first application type is the first type, perform memory reclamation on the first memory space corresponding to the first application based on the first reclamation data.

[0064] It is understood that after determining the first application type corresponding to the first application, the electronic device can determine the recycling data corresponding to the first application type based on the correspondence between application types and recycling data, and reclaim memory from the first memory space corresponding to the first application based on the recycling data. The recycling data may include the first recycling data. The first memory space may include at least one of anonymous page memory, GPU memory, and DMA memory.

[0065] It can be understood that the first data to be recycled can be the amount of recycled data. The amount of recycled data (also known as the recycling ratio) can represent the percentage of the total memory capacity of the electronic device that is recycled daily, and the amount of recycled data is less than or equal to the recycling data threshold (also known as the maximum daily swap-out amount). In some implementations, the first data to be recycled may include the amount of recycled data corresponding to anonymous page memory, the amount of recycled data corresponding to GPU memory, and the amount of recycled data corresponding to DMA memory, and the sum of the amount of recycled data corresponding to anonymous page memory, GPU memory, and DMA memory is less than or equal to the recycling data threshold. The amount of recycled data corresponding to anonymous page memory, GPU memory, and DMA memory can be the same, or they can be different.

[0066] It is understandable that the first reclamation data can be the daily reclamation count, which is less than or equal to a reclamation count threshold (also known as the maximum daily reclamation count for a single application). In some implementations, the first reclamation data may include the reclamation counts corresponding to anonymous page memory, GPU memory, and DMA memory, and the sum of these three counts is less than or equal to the reclamation count threshold. The reclamation counts corresponding to anonymous page memory, GPU memory, and DMA memory can be the same, or they can be different.

[0067] It is understandable that the first reclamation data can also include the amount of reclamation data and the number of daily reclamations. The amount of reclamation data can represent the percentage of the total memory capacity of the electronic device that is reclaimed daily, and the amount of reclamation data is less than or equal to a reclamation data amount threshold; the number of reclamations is less than or equal to a reclamation count threshold. In some implementations, the first reclamation data may include the amount of reclamation data corresponding to anonymous page memory, the amount of reclamation data corresponding to GPU memory, the amount of reclamation data corresponding to DMA memory, the number of reclamations corresponding to anonymous page memory, the number of reclamations corresponding to GPU memory, and the number of reclamations corresponding to DMA memory. Specifically, the sum of the amount of reclamation data corresponding to anonymous page memory, the amount of reclamation data corresponding to GPU memory, and the amount of reclamation data corresponding to DMA memory is less than or equal to the reclamation data threshold; the sum of the number of reclamations corresponding to anonymous page memory, the number of reclamations corresponding to GPU memory, and the number of reclamations corresponding to DMA memory is less than or equal to the reclamation count threshold.

[0068] In other implementations, the amount of data reclaimed may include not only the amount of data reclaimed corresponding to anonymous page memory, GPU memory, and DMA memory mentioned above, but also the amount of data reclaimed corresponding to anonymous page memory and GPU memory; or it may include the amount of data reclaimed corresponding to GPU memory and DMA memory; or it may include the amount of data reclaimed corresponding to anonymous page memory and DMA memory. This application does not impose specific limitations on the embodiments.

[0069] It is understood that the correspondence between application type and recycled data can include: a correspondence between application type and recycled data volume, for example, a correspondence between the first type and the recycled data volume corresponding to anonymous page memory, a correspondence between the first type and the recycled data volume corresponding to GPU memory, and a correspondence between the first type and the recycled data volume corresponding to DMA memory. The correspondence between application type and recycled data volume can also include a correspondence between application type and the number of recycling cycles, and further include a correspondence between application type and both the recycled data volume and the number of recycling cycles. This application does not impose specific limitations on the embodiments.

[0070] In some implementations, when the first application type is a first type (such as a hot application type, a high-frequency application type, or a high-frequency hot application type), the electronic device can reclaim the anonymous page memory corresponding to the first application based on the amount of reclaimed data corresponding to the anonymous page memory (also known as anonymous page data write-to-disk), reclaim the GPU memory corresponding to the first application based on the amount of reclaimed data corresponding to the GPU memory (also known as GPU texture data write-to-disk), and reclaim the DMA memory corresponding to the first application based on the amount of reclaimed data corresponding to the DMA memory (also known as DMAbuf data write-to-disk).

[0071] For example, if the amount of reclaimed data corresponding to anonymous page memory, GPU memory, and DMA memory is the same, and if the first usage data indicates that the user's first usage time for the first application within a week is 30 minutes (greater than a preset usage time threshold), the electronic device can determine that the first application type is a popular application type. Therefore, the electronic device can reclaim 10% of the GPU memory corresponding to the first application based on the amount of reclaimed data corresponding to GPU memory. Furthermore, the electronic device can reclaim 10% of the DMA memory corresponding to the first application based on the amount of reclaimed data corresponding to DMA memory.

[0072] For example, if the amount of data to be reclaimed in anonymous page memory, GPU memory, and DMA memory differs, and if the first usage data indicates that the user's first usage time for the first application within a week is 30 minutes (greater than a preset usage time threshold), the electronic device can determine that the first application type is a popular application type. Therefore, the electronic device can reclaim 10% of the GPU memory corresponding to the first application based on the amount of data to be reclaimed in GPU memory. Furthermore, the electronic device can reclaim 15% of the DMA memory corresponding to the first application based on the amount of data to be reclaimed in DMA memory.

[0073] In other implementations, when the first application type is a first type (such as a hot application type, a high-frequency application type, or a high-frequency hot application type), the electronic device can reclaim the anonymous page memory corresponding to the first application based on the number of reclamation cycles corresponding to the anonymous page memory, reclaim the GPU memory corresponding to the first application based on the number of reclamation cycles corresponding to the GPU memory, and reclaim the DMA memory corresponding to the first application based on the number of reclamation cycles corresponding to the DMA memory.

[0074] For example, if the number of garbage collections for anonymous page memory, GPU memory, and DMA memory are the same, and if the first usage data indicates that the user uses the first application 50 times within a week (greater than the preset usage frequency), the electronic device can determine that the first application type is a high-frequency application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on the 15 garbage collections for GPU memory. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on the 15 garbage collections for DMA memory.

[0075] For example, if the number of garbage collections for anonymous page memory, GPU memory, and DMA memory is the same, and if the first usage data indicates that the user's first usage time for the first application within a week is less than 30 minutes (less than or equal to the preset usage time threshold), and indicates that the user's first usage frequency for the first application within a week is 50 times (greater than the preset usage frequency), specifically, for example, the user uses the payment application frequently but with short usage times each time, the electronic device can determine that the first application type is a high-frequency application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on the 25 garbage collections for GPU memory. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on the 25 garbage collections for DMA memory.

[0076] For example, if the number of garbage collection cycles for anonymous page memory, GPU memory, and DMA memory differs, and if the first usage data indicates that the user uses the first application 50 times within a week (greater than the preset usage frequency), the electronic device can determine that the first application type is a high-frequency application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on the GPU memory reclamation cycle of 10. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on the DMA memory reclamation cycle of 15.

[0077] For example, if the number of garbage collections for anonymous page memory, GPU memory, and DMA memory differs, and if the first usage data indicates that the user's first usage time for the first application within a week is less than 30 minutes (less than or equal to the preset usage time threshold), and indicates that the user's first usage frequency for the first application within a week is 50 times (greater than the preset usage frequency), specifically, for example, the user uses the payment application frequently but with short usage times each time, the electronic device can determine that the first application type is a high-frequency application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on the GPU memory garbage collection count of 20. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on the DMA memory garbage collection count of 25.

[0078] In other implementations, when the first application type is a first type (such as a hot application type, a high-frequency application type, or a high-frequency hot application type), the electronic device can reclaim the anonymous page memory corresponding to the first application based on the amount of data reclaimed and the number of reclaims corresponding to the anonymous page memory, reclaim the GPU memory corresponding to the first application based on the amount of data reclaimed and the number of reclaims corresponding to the GPU memory, and reclaim the DMA memory corresponding to the first application based on the amount of data reclaimed and the number of reclaims corresponding to the DMA memory.

[0079] For example, if the amount of data reclaimed from anonymous page memory, GPU memory, and DMA memory is the same, but the number of reclamation cycles for anonymous page memory, GPU memory, and DMA memory are different, and if the first usage data indicates that the user's first usage time for the first application within a week is 30 minutes (greater than a preset usage time threshold), the electronic device can determine that the first application type is a popular application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on 10% of the reclaimed data from GPU memory and 20 reclamation cycles. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on 10% of the reclaimed data from DMA memory and 25 reclamation cycles.

[0080] For example, if the amount of data reclaimed from anonymous page memory, GPU memory, and DMA memory differs, but the number of reclamation cycles for anonymous page memory, GPU memory, and DMA memory is the same, and if the first usage data indicates that the user's first usage time for the first application within a week is 30 minutes (greater than a preset usage time threshold), the electronic device can determine that the first application type is a popular application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on 10% of the reclaimed data from GPU memory and 20 reclamation cycles. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on 20% of the reclaimed data from DMA memory and 20 reclamation cycles.

[0081] S304: When the first application type is the second type, memory reclamation is performed on the first memory space corresponding to the first application based on the second reclamation data; wherein, the first reclamation data and the second reclamation data are different.

[0082] In some implementations, after determining the second application type corresponding to the first application, the electronic device can determine the recycling data corresponding to the second application type based on the correspondence between application types and recycling data, and then reclaim memory from the first memory space corresponding to the first application based on the recycling data corresponding to the second application type. The recycling data may include the second recycling data.

[0083] It is understandable that the second reclamation data can also be the amount of reclamation data, which can represent the percentage of the total memory capacity of the electronic device that is reclaimed daily, and the amount of reclamation data is less than or equal to a reclamation data threshold. In some implementations, the second reclamation data may include the amount of reclamation data corresponding to anonymous page memory, the amount of reclamation data corresponding to GPU memory, and the amount of reclamation data corresponding to DMA memory, and these amounts are less than or equal to the reclamation data threshold. The amount of reclamation data corresponding to anonymous page memory, GPU memory, and DMA memory can be the same, or they can be different.

[0084] It is understandable that the second garbage collection data can also be the daily garbage collection count, which is less than or equal to a garbage collection count threshold. In some other implementations, the second garbage collection data may include the garbage collection count corresponding to anonymous page memory, the garbage collection count b2 corresponding to GPU memory, and the garbage collection count corresponding to DMA memory, and these three counts are less than or equal to the garbage collection count threshold. The garbage collection counts corresponding to anonymous page memory, GPU memory, and DMA memory can be the same, or they can be different.

[0085] It is understandable that the second reclamation data may also include the amount of data reclaimed and the number of daily reclamations. The amount of data reclaimed can represent the percentage of the total memory capacity in the electronic device that is reclaimed daily, and the amount of data reclaimed is less than or equal to a reclamation data amount threshold; the number of reclamations is less than or equal to a reclamation count threshold. In some implementations, the second reclamation data may include the amount of data reclaimed corresponding to anonymous page memory, the amount of data reclaimed corresponding to GPU memory, the amount of data reclaimed corresponding to DMA memory, the number of reclamations corresponding to anonymous page memory, the number of reclamations corresponding to GPU memory, and the number of reclamations corresponding to DMA memory. Specifically, the sum of the amount of data reclaimed corresponding to anonymous page memory, the amount of data reclaimed corresponding to GPU memory, and the amount of data reclaimed corresponding to DMA memory is less than or equal to the reclamation data threshold; the sum of the number of reclamations corresponding to anonymous page memory, the number of reclamations corresponding to GPU memory, and the number of reclamations corresponding to DMA memory is less than or equal to the reclamation count threshold.

[0086] In other implementations, the amount of data reclaimed can include not only the amount of data reclaimed corresponding to anonymous page memory, GPU memory, and DMA memory mentioned above, but also the amount of data reclaimed corresponding to anonymous page memory and GPU memory; it can also include the amount of data reclaimed corresponding to GPU memory and DMA memory; or it can include the amount of data reclaimed corresponding to anonymous page memory and DMA memory. This application does not impose specific limitations on the embodiments.

[0087] It is understandable that the difference between the first and second garbage collection data means that, when the applications are of different types, the amount of garbage collection data and / or the number of garbage collections corresponding to the same memory may be different.

[0088] In some implementations, when the first application type is the second type, the electronic device can reclaim the anonymous page memory corresponding to the first application based on the amount of reclaimed data corresponding to the anonymous page memory, reclaim the GPU memory corresponding to the first application based on the amount of reclaimed data corresponding to the GPU memory, and reclaim the DMA memory corresponding to the first application based on the amount of reclaimed data corresponding to the DMA memory. Specifically, the amount of reclaimed data corresponding to the anonymous page memory in the first reclaimed data can be less than the amount of reclaimed data corresponding to the anonymous page memory in the second reclaimed data, the amount of reclaimed data corresponding to the GPU memory in the first reclaimed data can be less than the amount of reclaimed data corresponding to the GPU memory in the second reclaimed data, and the amount of reclaimed data corresponding to the DMA memory in the first reclaimed data can be less than the amount of reclaimed data corresponding to the DMA memory in the second reclaimed data.

[0089] For example, if the amount of reclaimed data corresponding to anonymous page memory, GPU memory, and DMA memory is the same, and if the first usage data indicates that the user's first usage time for the first application within a week is less than 30 minutes (less than or equal to a preset usage time threshold), the electronic device can determine that the first application type is a normal application type. Therefore, the electronic device can reclaim 25% of the GPU memory corresponding to the first application based on the amount of reclaimed data corresponding to GPU memory. Furthermore, the electronic device can reclaim 25% of the DMA memory corresponding to the first application based on the amount of reclaimed data corresponding to DMA memory.

[0090] For example, if the amount of data to be reclaimed in anonymous page memory, GPU memory, and DMA memory differs, and if the first usage data indicates that the user's first usage time for the first application within a week is less than 30 minutes (less than or equal to a preset usage time threshold), the electronic device can determine that the first application type is a normal application. Therefore, the electronic device can reclaim 20% of the GPU memory corresponding to the first application based on the amount of data to be reclaimed in GPU memory. Furthermore, the electronic device can reclaim 25% of the DMA memory corresponding to the first application based on the amount of data to be reclaimed in DMA memory.

[0091] In other implementations, when the first application type is the second type, the electronic device can reclaim the anonymous page memory corresponding to the first application based on the number of reclamation cycles corresponding to anonymous page memory, the GPU memory corresponding to the first application based on the number of reclamation cycles corresponding to GPU memory, and the DMA memory corresponding to the first application based on the number of reclamation cycles corresponding to DMA memory. Specifically, the amount of reclaimed data corresponding to anonymous page memory in the first reclamation data can be less than the amount of reclaimed data corresponding to anonymous page memory in the second reclamation data, the amount of reclaimed data corresponding to GPU memory in the first reclamation data can be less than the amount of reclaimed data corresponding to GPU memory in the second reclamation data, and the amount of reclaimed data corresponding to DMA memory in the first reclamation data can be less than the amount of reclaimed data corresponding to DMA memory in the second reclamation data.

[0092] For example, if the amount of data to be reclaimed in anonymous page memory, GPU memory, and DMA memory is the same, and if the first usage data indicates that the user uses the first application less than 50 times within a week (less than or equal to the preset usage frequency), the electronic device can determine that the first application type is a low-frequency application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on the 25 reclamation counts for GPU memory. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on the 25 reclamation counts for DMA memory.

[0093] For example, if the amount of data to be reclaimed for anonymous page memory, GPU memory, and DMA memory differs, and if the first usage data indicates that the user's first use frequency for the first application is less than 50 times within a week (less than or equal to the preset usage frequency), the electronic device can determine that the first application type is a low-frequency application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on the GPU memory reclamation count of 20. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on the DMA memory reclamation count of 25.

[0094] It can be understood that S303 and S304 are two parallel branches, that is, the execution order of the above method can be S301, S302 and S303, or S301, S302 and S304. This application embodiment does not make specific limitations.

[0095] In this embodiment, the type of the first application is determined based on the user's usage habits of the first application during the first sampling period. This could be a popular application, a common application, or a frequently used application. Therefore, based on the different application types, the first memory corresponding to the first application is reclaimed using different amounts of data or the number of reclamation cycles. This differentiated memory reclamation, compared to frequent memory reclamation, reduces the memory pressure on electronic devices, lowers the read / write operations of storage devices, extends the lifespan of storage devices, and ensures a better user experience.

[0096] like Figure 4 The diagram illustrates a flowchart of a second memory reclamation method. This memory reclamation method can be executed by an electronic device, and in some implementations, it may include:

[0097] S401: Obtain the first usage data of the first application.

[0098] It is understandable that S401 is essentially the same as S301. The specific implementation of S401 can be referred to S301. To avoid repetition, it will not be elaborated here.

[0099] S402: Based on the first usage data, determine the first application type of the first application.

[0100] It is understandable that S402 is essentially the same as S302. The specific implementation of S402 can be referred to S302. To avoid repetition, it will not be elaborated here.

[0101] S403: If the first application type is the first type, perform memory reclamation on the first memory space corresponding to the first application based on the first reclamation data.

[0102] It is understandable that the first recycled data can also be referred to as the initial daily swap-out amount corresponding to the first memory space. Furthermore, S403 is essentially the same as S303, and the specific implementation of S403 can be found in S303. To avoid repetition, it will not be elaborated here.

[0103] S404: If the first application type is the second type, perform memory reclamation on the first memory space corresponding to the first application based on the second reclamation data; wherein the first reclamation data and the second reclamation data are different.

[0104] It is understandable that the second recycling data can also be referred to as the initial daily swap-out amount corresponding to the first memory space. Furthermore, S404 is essentially the same as S304, and the specific implementation of S404 can be found in S304. To avoid repetition, it will not be elaborated here.

[0105] S405: Obtain second usage data of the first application, the second usage data including first usage duration and / or second usage frequency within a second sampling period, the second sampling period being later than the first sampling period.

[0106] In some implementations, the electronic device can acquire the second usage duration and / or second usage frequency of the first application within a second sampling period, and use the second usage duration and / or second usage frequency of the first application within the second sampling period as second usage data. The second sampling period can be a pre-stored period by the electronic device, such as a day, a week, or a month, etc., and this application embodiment does not specifically limit it.

[0107] It is understandable that the second sampling period is later than the first sampling period, that is, the first sampling period is the previous historical period of the second sampling period.

[0108] S406: Based on the second usage data, determine the second application type of the first application.

[0109] It is understandable that S406 is essentially the same as S302. The specific implementation of S406 can be referred to S302. To avoid repetition, it will not be elaborated here.

[0110] S407: If the second application type is the first type, reclaim the second memory space corresponding to the first application based on the third reclamation data.

[0111] It can be understood that the second memory space corresponding to the first application can refer to the memory space corresponding to the first application after the second memory space corresponding to the first application has been reclaimed based on the first or second reclamation data, and after the user uses the first application during the second sampling period.

[0112] It is understandable that in some implementations, when the second usage duration is longer than the first usage duration, the third reclaimed data can be greater than the first reclaimed data. That is, if the user's usage duration of the first application is longer in the second sampling period than in the first sampling period, then the electronic device can adjust the amount of reclaimed data for the memory space corresponding to the first application.

[0113] For example, for a smartphone with a total memory capacity of 256G, the DMA memory reclamation data (also known as the initial daily DMA memory swap-out amount) corresponding to the game application is 10G. If the user uses the game application for a longer period in the second sampling period, the electronic device can adjust the DMA memory reclamation data corresponding to the game application to 20G to further reduce the memory pressure on the electronic device.

[0114] The recycled data (also known as the initial daily swap-out amount of GPU memory) for game applications is 10GB. If the user uses the game application for a longer period in the second sampling period, the electronic device can adjust the recycled data for the GPU memory of the game application to 20GB to further reduce the memory pressure on the electronic device.

[0115] In some implementations, if the second usage frequency is greater than the first usage frequency, the third reclaimed data can be greater than the first reclaimed data. That is, if the user uses the first application more frequently in the second sampling period than in the first sampling period, the electronic device can adjust the number of times the memory space corresponding to the first application is reclaimed.

[0116] Similarly, when the second application type is the second type, the electronic device can reclaim the second memory space corresponding to the first application based on the fourth reclamation data. If the second usage duration is greater than the first usage duration, the fourth reclamation data can be greater than the second reclamation data; or, if the second usage frequency is greater than the first usage frequency, the fourth reclamation data can be greater than the second reclamation data.

[0117] It is understandable that, given that the first application type corresponding to the first application in the first sampling period is determined to be a first type, the electronic device can also acquire third usage data of the first application in the third sampling period, such as third usage duration and / or third usage frequency, wherein the third sampling period is later than the first sampling period. Furthermore, the electronic device can determine the third application type corresponding to the first application in the third sampling period based on the third usage data. If the third application type is a second type, the electronic device can reclaim the third memory space corresponding to the first application based on fourth reclamation data, wherein the fourth reclamation data is different from the first reclamation data.

[0118] For example, if the first usage data indicates that a user used the first application 50 times in the previous week (first sampling period) (greater than a preset usage frequency), the electronic device can determine that the first application type is a high-frequency application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on the GPU memory reclamation count of 15. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on the DMA memory reclamation count of 15.

[0119] If the third usage data indicates that the user uses the first application less than 50 times (less than or equal to the preset usage frequency) in the following week (third sampling period), the electronic device can determine that the third application type corresponding to the first application is a low-frequency application type. Therefore, the electronic device can reclaim the GPU memory corresponding to the first application based on the GPU memory reclamation count of 25. Furthermore, the electronic device can reclaim the DMA memory corresponding to the first application based on the DMA memory reclamation count of 25.

[0120] In this embodiment, the type of the first application is determined based on the user's usage habits of the first application during the first sampling period. This type may be a popular application, a common application, or a frequently used application. Therefore, based on the different application types, different amounts of data or the number of times the memory corresponding to the first application is reclaimed for differentiated memory reclamation. Furthermore, by dynamically adjusting the amount of data reclaimed from the memory space corresponding to the application based on the user's usage habits in different sampling periods, the memory pressure on the electronic device can be further reduced while ensuring a good user experience.

[0121] like Figure 5 The diagram illustrates a third memory reclamation method. This memory reclamation method can be executed by an electronic device, and in some implementations, it may include:

[0122] S501: Periodically and dynamically adjust the collected data.

[0123] It is understood that electronic devices can acquire first usage data of an application within a first sampling period and second usage data of an application within a second sampling period, and determine the application type corresponding to the application based on the first and second usage data, and dynamically adjust the recycling data corresponding to the application based on the application type.

[0124] In some implementations, regardless of whether the amounts of reclaimed data corresponding to anonymous page memory, GPU memory, and DMA memory in the first garbage collection are the same or different, the amount of reclaimed data corresponding to anonymous page memory in the first garbage collection can be represented as x1%, the amount of reclaimed data corresponding to GPU memory can be represented as y1%, and the amount of reclaimed data corresponding to DMA memory can be represented as z1%. Furthermore, regardless of whether the amounts of reclaimed data corresponding to anonymous page memory, GPU memory, and DMA memory in the second garbage collection are the same or different, the amount of reclaimed data corresponding to anonymous page memory in the second garbage collection can be represented as x2%, the amount of reclaimed data corresponding to GPU memory can be represented as y2%, and the amount of reclaimed data corresponding to DMA memory can be represented as z2%.

[0125] In this way, the electronic device can adjust the amount of data reclaimed for anonymous page memory from x1% to x3%, the amount of data reclaimed for GPU memory from y1% to y3%, and the amount of data reclaimed for DMA memory from z1% to z3. The number of reclamations for anonymous page memory can be adjusted from a1 to a3, the amount of data reclaimed for GPU memory from b1 to b3, and the number of reclamations for DMA memory from c1 to c3.

[0126] S502: Application is switched to background and frozen.

[0127] It is understandable that when an application is switched from the foreground to the background and is in a frozen state, the electronic device can obtain the corresponding recycling data of the application.

[0128] S503: Triggers data write-to-disk.

[0129] In some implementations, electronic devices can trigger GPU texture data write-to-disk, trigger DMAbuf data write-to-disk, and trigger anonymous page data write-to-disk.

[0130] S504: Determine if the maximum daily turnover volume has been reached. If the maximum daily turnover volume has not been reached, proceed to S505; if the maximum daily turnover volume has been reached, end the process.

[0131] It is understandable that electronic devices can determine whether the sum of the amount of data to be reclaimed (x1%) corresponding to anonymous page memory, the amount of data to be reclaimed (y1%) corresponding to GPU memory, and the amount of data to be reclaimed (z1%) corresponding to DMA memory is greater than the data reclamation threshold S1 (also known as the maximum daily swap-out amount). If the data reclamation threshold S1 is not reached, the device can further determine whether the sum of the number of reclamations (a1) corresponding to anonymous page memory, the number of reclamations (b1) corresponding to GPU memory, and the number of reclamations (c1) corresponding to DMA memory is greater than the reclamation count threshold S2 (also known as the maximum daily swap-out count for a single application). If the reclamation count threshold S2 is not reached, memory reclamation is triggered.

[0132] S505: Determine if the maximum number of daily replacements for a single application has been reached. If the maximum number of daily replacements for a single application has not been reached, proceed to S506; if the maximum daily replacement count has been reached, end the process.

[0133] It is understandable that if the sum of the amount of data reclaimed (x1%) corresponding to anonymous page memory, the amount of data reclaimed (y1%) corresponding to GPU memory, and the amount of data reclaimed (z1%) corresponding to DMA memory is less than or equal to the data reclamation threshold S1, the electronic device can further determine whether the sum of the number of reclamation attempts (a1) corresponding to anonymous page memory, the number of reclamation attempts (b1) corresponding to GPU memory, and the number of reclamation attempts (c1) corresponding to DMA memory is greater than the reclamation attempt threshold S2 (also known as the maximum number of swaps out per application per day). If the reclamation attempt threshold S2 is not reached, memory reclamation is triggered.

[0134] S506: Triggers memory reclamation.

[0135] In this embodiment of the application, when the application is switched to the background and is in a frozen state, the memory space reclamation data corresponding to the application can be dynamically adjusted according to the user's usage habits of the application in different sampling periods, which can further reduce the memory pressure of electronic devices while ensuring user experience.

[0136] It is understood that the memory reclamation method mentioned in the embodiments of this application can be applied to electronic devices. For example... Figure 6 The diagram shows a schematic representation of the structure of the third type of electronic device.

[0137] The electronic device may include a software architecture and a hardware structure. The software architecture may include an application layer, a system service layer, and a kernel layer. The hardware structure may include a storage device.

[0138] In some implementations, the application layer can include application packages of a series of applications. Examples include application packages for news applications, video applications, and game applications.

[0139] The system service layer can provide services to applications in the application layer. For example, the system service layer can provide a service to detect whether the memory in an electronic device meets the conditions for reclamation. In some implementations, the system service layer may include a dynamic management strategy module and a differentiated reclamation module. The dynamic management strategy module can be used to adjust the reclamation data for the memory space corresponding to an application based on the user's usage habits of the application in different sampling periods. The differentiated reclamation module can be used to determine different reclamation data for the memory space corresponding to an application based on the application type.

[0140] The kernel layer is the layer between the software architecture and the hardware structure, and it is responsible for managing system resources, scheduling processes, and providing hardware interfaces. For example, when the memory in an electronic device meets the reclamation criteria, the kernel layer can transfer data from memory to storage devices.

[0141] Storage devices may include multiple swap partitions. For example, swap partition 1 (i.e., the anonymous swap partition mentioned above), swap partition 2, and swap partition 3.

[0142] In some implementations, the kernel layer can compress and transfer data from anonymous pages to swap partition 1 in the storage device, transfer data from DMA memory to swap partition 2, and transfer data from GPU memory to swap partition 3, provided that the memory in the electronic device meets the reclamation conditions. This can alleviate memory pressure in the electronic device and ensure its normal operation.

[0143] It is understood that the memory reclamation method mentioned in the embodiments of this application can be applied to electronic devices. The hardware structure of the electronic device will be described below.

[0144] Figure 7 A schematic diagram of the hardware structure of an electronic device is shown. It is understood that the structure illustrated in this embodiment 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 illustrated, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of both.

[0145] like Figure 7As shown, the electronic device may include a processor 710, an external memory interface 720, an internal memory 721, a universal serial bus (USB) interface 730, a charging management module 740, a power management module 7041, a battery 742, antenna 1, antenna 2, a mobile communication module 750, a wireless communication module 760, an audio module 770, a speaker 770A, a receiver 770B, a microphone 770C, a headphone jack 770D, a sensor module 780, buttons 790, a motor 791, an indicator 792, a camera 793, a display screen 794, and a subscriber identification module (SIM) card interface 795, etc. The sensor module 780 may include a pressure sensor 780A, a gyroscope sensor 780B, a barometric pressure sensor 780C, a magnetic sensor 780D, an accelerometer sensor 780E, a distance sensor 780F, a proximity sensor 780G, a fingerprint sensor 780H, a temperature sensor 780J, a touch sensor 780K, an ambient light sensor 780L, a bone conduction sensor 780M, etc.

[0146] The processor 710 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.

[0147] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.

[0148] The processor 710 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 710 is a cache memory. This memory can store instructions or data that the processor 710 has just used or that are used repeatedly. If the processor 710 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 710, and thus improves the efficiency of the system.

[0149] In some embodiments, the processor 710 may include one or more interfaces. Interfaces may include integrated circuit interfaces, integrated circuit built-in audio interfaces, pulse code modulation (PCM) interfaces, universal asynchronous receiver / transmitter (UART) interfaces, mobile industry processor interfaces (MIPI), general-purpose input / output (GPIO) interfaces, subscriber identity module (SIM) interfaces, and / or universal serial bus (USB) interfaces, etc.

[0150] It is understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are merely illustrative and do not constitute a limitation on the structure of the electronic device. In other embodiments of this application, the electronic device may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0151] In some implementations, the power management module 7041 can supply power to the audio module 770 so that the audio module 770 can switch from a power-down, non-operating state to a power-on, operating state.

[0152] Electronic devices implement display functions through a GPU, a display screen 794, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 794 and the application processor. The GPU performs mathematical and geometric calculations and is used for graphics rendering. The processor 710 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0153] Electronic devices can achieve shooting functions through ISP, camera 793, video codec, GPU, display 794 and application processor.

[0154] The external memory interface 720 can be used to connect external memory cards, such as Micro SD cards, to expand the storage capacity of electronic devices. The external memory card communicates with the processor 710 through the external memory interface 720 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0155] Internal memory 721 can be used to store executable program code, including instructions. Internal memory 721 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of the electronic device (such as audio data, phonebook, etc.). Furthermore, internal memory 721 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 710 executes various functional applications and data processing of the electronic device by running instructions stored in internal memory 721 and / or instructions stored in memory located within the processor.

[0156] Electronic devices can implement audio functions through audio modules 770, speakers 770A, receivers 770B, microphones 770C, headphone jacks 770D, and application processors. Examples include music playback and recording.

[0157] This application provides a computer program product that, when run on a device, causes the device to execute the technical solutions described in the above embodiments. Its implementation principle and technical effects are similar to those of the related embodiments described above, and will not be repeated here.

[0158] This application provides a readable storage medium containing instructions that, when executed on a device, cause the device to perform the technical solutions described in the above embodiments. The implementation principle and technical effects are similar and will not be repeated here.

[0159] This application provides a chip for executing instructions. When the chip is running, it executes the technical solutions described in the above embodiments. Its implementation principle and technical effects are similar and will not be repeated here.

[0160] It is understood that the various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. Embodiments of this application can be implemented as computer programs or program code executable on a programmable system, the programmable system including at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.

[0161] Program code can be applied to input instructions to execute the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application-specific integrated circuit (ASIC), or a microprocessor.

[0162] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.

[0163] It should be noted that in the examples and description of this patent, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the aforementioned element.

[0164] Although this application has been illustrated and described with reference to certain embodiments thereof, those skilled in the art will understand that various changes in form and detail may be made thereto without departing from the scope of this application.

Claims

1. A memory reclamation method, characterized in that, Applied to electronic devices, including: Obtain the first usage data of the first application; Based on the first usage data, the first application type of the first application is determined; If the first application type is a first type, memory reclamation is performed on the first memory space corresponding to the first application based on the first reclamation data; or If the first application type is the second type, memory reclamation is performed on the first memory space corresponding to the first application based on the second reclamation data; The first recovered data and the second recovered data are different.

2. The method according to claim 1, characterized in that, The first usage data includes the first usage duration and / or the first usage frequency within the first sampling period.

3. The method according to claim 2, characterized in that, The method further includes: Acquire second usage data of the first application, the second usage data including second usage duration and / or second usage frequency within a second sampling period, the second sampling period being later than the first sampling period; Based on the second usage data, the second application type of the first application is determined; When the second application type is the first type, the second memory space corresponding to the first application is reclaimed based on the third reclamation data, wherein the third reclamation data is different from the first reclamation data.

4. The method according to claim 2, characterized in that, The method further includes: Obtain third usage data of the first application, the third usage data including third usage duration and / or third usage frequency within a third sampling period, the third sampling period being later than the first sampling period; Based on the third usage data, the third application type of the first application is determined; When the third application type is the second type, the third memory space corresponding to the first application is reclaimed based on the fourth reclamation data, wherein the fourth reclamation data is different from the first reclamation data.

5. The method according to claim 2, characterized in that, The step of determining the first application type of the first application based on the first usage data includes: If the first usage duration is longer than the preset usage duration, the first application type of the first application is determined to be the first type; If the first usage duration is less than or equal to the preset usage duration, the first application type of the first application is determined to be the second type.

6. The method according to claim 2, characterized in that, The step of determining the first application type of the first application based on the first usage data includes: If the first usage frequency is greater than the preset usage frequency, the first application type of the first application is determined to be the first type; If the first usage frequency is less than or equal to the preset usage frequency, the first application type of the first application is determined to be the second type.

7. The method according to claim 2, characterized in that, The step of determining the first application type of the first application based on the first usage data includes: If the first usage duration is greater than the preset usage duration and the first usage frequency is greater than the preset usage frequency, then the first application type of the first application is determined to be the first type. If the first usage duration is less than or equal to the preset usage duration, and the first usage frequency is less than or equal to the preset usage frequency, the first application type of the first application is determined to be the second type.

8. The method according to any one of claims 4 to 7, characterized in that, The first type includes any one of the following: hot application type, high-frequency application type, or high-frequency hot application type; The second type includes any one of the following: general application type, low-frequency application type, or low-frequency general application type.

9. The method according to claim 3, characterized in that, If the second usage duration is greater than the first usage duration, or if the second usage frequency is greater than the first usage frequency, the third recycled data is greater than the first recycled data.

10. The method according to any one of claims 1 to 9, characterized in that, The first and second recovered data include any one of the following: number of recoveries and amount of recovered data; The first and second recovered data satisfy the recovery conditions, wherein, The recycling conditions include at least one of the following: The number of recycling attempts is less than or equal to the recycling attempt threshold; or, the amount of data recycled is less than or equal to the data recycling amount threshold.

11. An electronic device, characterized in that, Includes: a memory for storing instructions executed by one or more processors of the electronic device. And a processor, which is one or more processors of the electronic device, for performing the memory reclamation method according to any one of claims 1 to 10.

12. A readable storage medium, characterized in that, The readable storage medium stores instructions that, when executed on an electronic device, cause the electronic device to perform the memory reclamation method according to any one of claims 1 to 10.

13. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by an electronic device, enable the electronic device to perform the memory reclamation method as described in any one of claims 1 to 10.

14. A chip, characterized in that, The chip includes a processor coupled to a memory for executing computer programs or instructions stored in the memory, such that the chip implements the memory reclamation method according to any one of claims 1 to 10.