Anonymous page reclaiming method and electronic device

By avoiding anonymous big page splitting during anonymous page reclamation and directly compressing or swapping them out, the problem of increased performance overhead in mixed big page scenarios is solved, improving memory management efficiency and user experience.

WO2025260683A1PCT designated stage Publication Date: 2025-12-26HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/142300
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-06-19
Filing Date
2024-12-25
Publication Date
2025-12-26

AI Technical Summary

Technical Problem

In hybrid big-page scenarios, anonymous page reclamation can lead to increased performance overhead, especially under high memory pressure. The splitting and compaction of anonymous big pages can cause additional memory load and performance overhead.

Method used

By avoiding splitting anonymous large pages during anonymous page reclamation and directly compressing or swapping them out to storage space, the performance overhead caused by large page splitting is avoided. Different anonymous page reclamation strategies are used to balance reclamation efficiency and performance overhead in different memory scenarios.

Benefits of technology

It reduces the performance overhead of memory management, improves system smoothness and real-time response, ensures user experience, and leverages the performance advantages of mixed big-page scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024142300_26122025_PF_FP_ABST
    Figure CN2024142300_26122025_PF_FP_ABST
Patent Text Reader

Abstract

An anonymous page reclaiming method and an electronic device. In the method, an electronic device can use an anonymous page reclaiming mode of "compressing an anonymous huge page and an anonymous standard page into a temporary cache area in a memory space, and then swapping out the compressed anonymous huge page and the compressed anonymous standard page in the temporary cache area to a storage space"; or an anonymous page reclaiming mode of "directly swapping out an anonymous huge page into a storage space, and then compressing an anonymous standard page into a temporary cache area in a memory space, and swapping out the compressed anonymous standard page in the temporary cache area to the storage space"; or an anonymous page reclaiming mode of "directly swapping out an anonymous huge page and an anonymous standard page to a storage space". These anonymous page reclaiming modes can reduce performance overhead, thereby improving memory management performance in a hybrid huge page scenario.
Need to check novelty before this filing date? Find Prior Art

Description

An anonymous page recycling method and electronic device

[0001] Cross-reference to Related Applications

[0002] This application claims priority to the Chinese Patent Application No. 202410799112.1, filed on June 19, 2024, and entitled "An anonymous page recycling method and electronic device", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD

[0003] The present application relates to the field of computer storage, and in particular, to an anonymous page recycling method and electronic device. BACKGROUND

[0004] The memory management adopts a paging memory management mechanism. The physical memory corresponding to an application program is divided into a plurality of fixed-size pages, which can also be referred to as "standard pages", "small pages", etc. For example, the size of a standard page of an electronic device such as a mobile phone is generally 4 kilobytes (KB), which can also be referred to as 4K. A huge page, also referred to as huge page memory, refers to a physical page that is multiple times larger than a standard page, such as a 16K huge page, a 32K huge page, a 64K huge page, a 128K huge page, etc.

[0005] In order to improve the flexibility of memory management, a standard page or a huge page can be selected according to a specific situation to implement dynamic allocation of memory. By dynamically allocating huge pages and standard pages of different memory granularities, the efficiency of memory management can be improved. When the memory pressure is large, the situation of memory shortage can be alleviated by triggering anonymous page recycling. However, in a scenario in which different memory granularities of huge pages and standard pages are used, i.e., a mixed huge page scenario, the recycling of anonymous huge pages usually needs to be first split into standard pages, then compressed to a temporary cache area of memory, and finally swapped from a random access memory (RAM) to a read-only memory (ROM), resulting in additional memory load and performance overhead. SUMMARY

[0006] The present application provides an anonymous page recycling method and electronic device to provide a scheme for anonymous page recycling in a mixed huge page scenario, which can reduce performance overhead.

[0007] In a first aspect, the application provides a first anonymous page recycling method, which can be executed by an electronic device. The method includes: the anonymous page includes an anonymous large page and an anonymous standard page, the size of the anonymous large page is N times the size of the anonymous standard page, N is a positive integer greater than 1, and the method includes: compressing the anonymous large page and the anonymous standard page to a temporary cache area in the memory space; and swapping the compressed anonymous large page and the compressed anonymous standard page in the temporary cache area to a storage space.

[0008] In the method, by not splitting the anonymous large page and directly compressing it, the increase in performance overhead caused by large page splitting can be reduced, thereby the performance advantage of the hybrid large page scenario can be exerted to a greater extent, the fluency and real-time response of the system are ensured, and the user experience is ensured.

[0009] In a possible scenario, the size of the anonymous standard page is 4K, and N is M power of 2, M being a positive integer greater than 1.

[0010] In this scenario, the hybrid large page scenario of the anonymous standard page and the anonymous large page can improve the memory management performance and reduce the memory management overhead.

[0011] In a possible scenario, the size of the anonymous standard page is 4K, and the size of the anonymous large page is 64K.

[0012] In this scenario, by using the 64K anonymous large page, the overhead of memory management can be reduced, and the performance of memory management can be improved.

[0013] In a possible scenario, the step of compressing the anonymous large page and the anonymous standard page to a temporary cache area in the memory space specifically includes: in response to detecting an anonymous page recycling event, compressing the anonymous large page and the anonymous standard page to a temporary cache area in the memory space.

[0014] In this scenario, by executing the anonymous page recycling method when detecting an anonymous page recycling event, different anonymous page recycling strategies can be configured in different scenarios, so as to balance the recycling efficiency and performance overhead.

[0015] In a possible scenario, the anonymous page recycling event includes one or more of the following: being in a memory overload scenario, the memory occupancy rate being greater than a preset threshold, an application being backgrounded, a high-load application being started, and a user actively triggering memory space release.

[0016] In this scenario, when it is determined that there is a large pressure on the memory and insufficient computing power, the splitting of the anonymous large page in the anonymous page recycling process can be abandoned, so that the effect of reducing the performance overhead can be obtained, the fluency and real-time response of the system are ensured, and the user experience is ensured.

[0017] In a possible scenario, the memory overload scenario is detected including: determining that the memory space is in the memory overload scenario when it is determined that the remaining memory space is less than the memory space threshold; and / or determining that the memory space is in the memory overload scenario when it is determined that the number of large pages is greater than the large page number threshold; wherein the large page includes an anonymous large page and a file large page.

[0018] In this scenario, when the remaining memory space is small, that is, the occupied memory space is large, it can be determined that it is in the memory overload scenario, at this time, it is necessary to try to reduce the operation that may cause the increase of overhead, for example, the splitting of the anonymous large page will bring a large overhead. When the number of large pages included in the electronic device is large, if the splitting, compression and swapping out of the anonymous large page are performed, it will also lead to a high performance overhead, at this time, it is also necessary to try to reduce the operation that may cause the increase of overhead, for example, the splitting of the anonymous large page can be stopped.

[0019] In a second aspect, the present application provides a second anonymous page recycling method, which can be executed by an electronic device. The method includes: the anonymous page includes an anonymous large page and an anonymous standard page, the size of the anonymous large page is N times the size of the anonymous standard page, N is a positive integer greater than 1, and the method includes: directly swapping out the anonymous large page to a storage space; compressing the anonymous standard page to a temporary cache area in the memory space, and then swapping out the compressed anonymous standard page in the temporary cache area to the storage space.

[0020] In this method, by not splitting the anonymous large page and not compressing it, not only can the additional management and performance overhead caused by the splitting process be reduced, but also the additional memory load caused by the compression process and the storage of the temporary cache area can be reduced. Therefore, the performance advantage of the hybrid large page scenario can be exerted to a greater extent. In addition, by retaining the compression of the anonymous standard page, the positive effect of reducing the amount of occupied ROM storage space after swapping out can also be achieved. In this way, by this method, the time efficiency and the space efficiency can be balanced on the basis of ensuring the smoothness and real-time response of the system.

[0021] In a possible scenario, the method specifically includes: determining whether the anonymous page to be recycled is the anonymous large page; if the anonymous page to be recycled is the anonymous large page, directly swapping out the anonymous large page to the storage space; otherwise, the anonymous page to be recycled is the anonymous standard page, compressing the anonymous standard page to the temporary cache area in the memory space, and then swapping out the compressed anonymous standard page in the temporary cache area to the storage space.

[0022] In a possible scenario, the size of the anonymous standard page is 4K, N is M power of 2, and M is a positive integer greater than 1.

[0023] In a possible scenario, the size of the anonymous standard page is 4K, and the size of the anonymous large page is 64K.

[0024] In a possible scenario, the compressing the anonymous large page and the anonymous standard page to the temporary cache area in the memory space specifically includes: in response to detecting an anonymous page recycling event, compressing the anonymous large page and the anonymous standard page to the temporary cache area in the memory space.

[0025] In a possible scenario, the anonymous page recycling event includes one or more of the following: being in a memory overload scenario, a memory occupancy rate being greater than a preset threshold, an application retreating to the background, a high-load application starting, and a user actively triggering memory space release.

[0026] In a possible scenario, detecting that the memory space is in a memory overload scenario includes: determining that the memory space is in a memory overload scenario when it is determined that the remaining memory space is less than a memory space threshold; and / or determining that the memory space is in a memory overload scenario when it is determined that the number of large pages is greater than a large page number threshold; wherein the large pages include anonymous large pages and file large pages.

[0027] In a third aspect, the present application provides a third anonymous page recycling method, which can be executed by an electronic device. The method includes: the anonymous pages include anonymous large pages and anonymous standard pages, the size of the anonymous large page is N times the size of the anonymous standard page, the N is a positive integer greater than 1, and the method includes: directly swapping out the anonymous large pages and the anonymous standard pages to a storage space.

[0028] In the method, the anonymous page recycling mode of directly swapping out the anonymous large pages and the anonymous standard pages can greatly reduce the overhead of memory management, thereby greatly guaranteeing the fluency and real-time response of the system.

[0029] In a possible scenario, the size of the anonymous standard page is 4K, and the N is M power of 2, the M being a positive integer greater than 1.

[0030] In a possible scenario, the size of the anonymous standard page is 4K, and the size of the anonymous large page is 64K.

[0031] In a possible scenario, the compressing the anonymous large page and the anonymous standard page to the temporary cache area in the memory space specifically includes: in response to detecting an anonymous page recycling event, compressing the anonymous large page and the anonymous standard page to the temporary cache area in the memory space.

[0032] In a possible scenario, the anonymous page recycling event includes, but is not limited to, one or more of the following: being in a memory overload scenario, a memory occupancy rate being greater than a preset threshold, an application being backgrounded, a high-load application being started, and a user actively triggering memory space release.

[0033] In a possible scenario, detecting that the memory space is in a memory overload scenario includes: determining that the memory space is in the memory overload scenario when it is determined that the remaining memory space is less than a memory space threshold; and / or determining that the memory space is in the memory overload scenario when it is determined that the number of large pages is greater than a large page number threshold; wherein the large pages include anonymous large pages and file large pages.

[0034] In a fourth aspect, the present application provides a fourth anonymous page recycling method, which can be executed by an electronic device. The method includes: the anonymous pages include anonymous large pages and anonymous standard pages, the size of the anonymous large pages is N times the size of the anonymous standard pages, N is a positive integer greater than 1, and the method includes: determining a scenario in which the electronic device is currently located; and recycling the anonymous large pages and the anonymous standard pages by using an anonymous page recycling manner corresponding to the scenario in which the electronic device is currently located.

[0035] In a possible scenario, the scenario in which the electronic device is currently located includes at least two of a first scenario, a second scenario, a third scenario, and a fourth scenario, and the memory pressure of the electronic device in the first scenario < the memory pressure of the electronic device in the second scenario < the memory pressure of the electronic device in the third scenario < the memory pressure of the electronic device in the fourth scenario.

[0036] (1) The anonymous page recycling manner corresponding to the first scenario includes: splitting the anonymous large pages into N anonymous standard pages; and compressing the anonymous standard pages including the N anonymous standard pages obtained by splitting the anonymous large pages into the temporary cache area in the memory space, and then swapping the compressed anonymous standard pages in the temporary cache area to the storage space.

[0037] (2) The anonymous page recycling manner corresponding to the second scenario includes: compressing the anonymous large pages and the anonymous standard pages to the temporary cache area; and swapping the compressed anonymous large pages and the compressed anonymous standard pages in the temporary cache area to the storage space.

[0038] (3) The anonymous page recycling manner corresponding to the third scenario includes: directly swapping the anonymous large pages to the storage space; and compressing the anonymous standard pages to the temporary cache area, and then swapping the compressed anonymous standard pages in the temporary cache area to the storage space.

[0039] (4) The anonymous page recycling manner corresponding to the fourth scenario comprises: directly swapping out the anonymous large page and the anonymous standard page to a storage space.

[0040] In the method, by pre-configuring different anonymous page recycling strategies under different memory conditions, the balance between recycling efficiency and performance overhead can be achieved for each degree. In this way, the performance advantage of the hybrid large page can be greatly exerted.

[0041] In a possible scenario, the size of the anonymous standard page is 4K, the N is 2 raised to the power of M, and the M is a positive integer greater than 1.

[0042] In a possible scenario, the size of the anonymous standard page is 4K, and the size of the anonymous large page is 64K.

[0043] In a fifth aspect, the present application provides an electronic device, which comprises a plurality of functional modules; the plurality of functional modules interact to implement the method performed by the electronic device in the first aspect and each of the implementation manners thereof, or implement the method performed by the electronic device in the second aspect and each of the implementation manners thereof, or implement the method performed by the electronic device in the third aspect and each of the implementation manners thereof, or implement the method performed by the electronic device in the fourth aspect and each of the implementation manners thereof.

[0044] The plurality of functional modules can be implemented based on software, hardware or a combination of software and hardware, and the plurality of functional modules can be arbitrarily combined or divided based on specific implementation.

[0045] In a sixth aspect, the present application provides an electronic device, which comprises at least one processor and at least one memory, and the at least one memory stores computer program instructions; when the electronic device is running, the at least one processor executes the method performed by the electronic device in the first aspect and each of the implementation manners thereof, or executes the method performed by the electronic device in the second aspect and each of the implementation manners thereof, or executes the method performed by the electronic device in the third aspect and each of the implementation manners thereof, or executes the method performed by the electronic device in the fourth aspect and each of the implementation manners thereof.

[0046] In a seventh aspect, the present application further provides a computer program product comprising instructions, which, when the computer program product is running on a computer, causes the computer to execute the method performed by the electronic device in the first aspect and each of the implementation manners thereof, or execute the method performed by the electronic device in the second aspect and each of the implementation manners thereof, or execute the method performed by the electronic device in the third aspect and each of the implementation manners thereof, or execute the method performed by the electronic device in the fourth aspect and each of the implementation manners thereof.

[0047] In an eighth aspect, the present application provides a computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and when the computer program is executed by a computer, the computer is caused to perform the method performed by the electronic device in the first aspect and the embodiments thereof, or perform the method performed by the electronic device in the second aspect and the embodiments thereof, or perform the method performed by the electronic device in the third aspect and the embodiments thereof, or perform the method performed by the electronic device in the fourth aspect and the embodiments thereof.

[0048] In a ninth aspect, the present application provides a chip, which is used to read a computer program stored in a memory, and perform the method performed by the electronic device in the first aspect and the embodiments thereof, or perform the method performed by the electronic device in the second aspect and the embodiments thereof, or perform the method performed by the electronic device in the third aspect and the embodiments thereof, or perform the method performed by the electronic device in the fourth aspect and the embodiments thereof.

[0049] In a tenth aspect, the present application provides a chip system, which comprises a processor, and is used to support a computer device to implement the method performed by the electronic device in the first aspect and the embodiments thereof, or implement the method performed by the electronic device in the second aspect and the embodiments thereof, or implement the method performed by the electronic device in the third aspect and the embodiments thereof, or implement the method performed by the electronic device in the fourth aspect and the embodiments thereof.

[0050] In a possible design, the chip system further comprises a memory, which is used to store programs and data necessary for the computer device. The chip system can be composed of a chip, or can include a chip and other discrete devices.

[0051] The advantages of the second aspect to the tenth aspect and the possible designs thereof can refer to the advantages of the possible designs of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0052] FIG. 1A is a schematic diagram of a scenario of an anonymous page recycling;

[0053] FIG. 1B is a schematic diagram of a flow of an anonymous page recycling;

[0054] FIG. 2 shows a schematic diagram of a hardware structure of a possible electronic device;

[0055] FIG. 3 is a software architecture block diagram of an electronic device provided by an embodiment of the present application;

[0056] FIG. 4 is a schematic diagram of a scenario of an anonymous page recycling method provided by an embodiment of the present application;

[0057] FIG. 5 is a flow diagram of one of the anonymous page recycling methods provided by the embodiments of the present application;

[0058] FIG. 6 is another scenario diagram of the anonymous page recycling method provided by the embodiments of the present application;

[0059] FIG. 7 is a flow diagram of another of the anonymous page recycling methods provided by the embodiments of the present application;

[0060] FIG. 8A is another scenario diagram of the anonymous page recycling method provided by the embodiments of the present application;

[0061] FIG. 8B is a flow diagram of another of the anonymous page recycling methods provided by the embodiments of the present application;

[0062] FIG. 9 is a flow diagram of another of the anonymous page recycling methods provided by the embodiments of the present application;

[0063] FIG. 10 is a flow diagram of another of the anonymous page recycling methods provided by the embodiments of the present application;

[0064] FIG. 11 is a flow diagram of another of the anonymous page recycling methods provided by the embodiments of the present application;

[0065] FIG. 12 is a flow diagram of another of the anonymous page recycling methods provided by the embodiments of the present application. DETAILED DESCRIPTION

[0066] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and embodiments.

[0067] The method provided by the embodiments of the present application can be applied to the field of computer storage technology on electronic devices, and can be particularly applicable to the field of memory management technology in the mixed large page technology scenario. The storage on electronic devices can generally include random access memory (RAM) memory space and read-only memory (ROM), and the former is usually referred to as "memory" or "memory space" and the like, and the latter is usually referred to as "storage" or "storage space" or "disk" and the like. The RAM memory space is used for temporarily storing data required by the electronic device during the running of the program, and has the advantage of access speed, but the stored data will be lost after the electronic device is powered off. The ROM storage space is used for storing software programs, files and other data of the electronic device, and the stored data will not be lost even after the electronic device is powered off, and has non-volatility, but has low access speed. Therefore, the electronic device can use the RAM memory space as the running memory to ensure the running speed of the program, and use the ROM storage space as the storage memory to ensure that the data will not be lost.

[0068] On an electronic device, the RAM memory space is generally small, such as 8 gigabytes (GB), 12 GB, etc., and the ROM storage space is generally large, such as 128 GB, 256 GB, 512 GB, 1 terabyte (TB), etc.

[0069] The types of pages in the RAM memory space can include file-backed pages and anonymous pages. A file-backed page is a page that has a mapping relationship with a file in the ROM storage space, that is, a page that has a file background or has a corresponding disk file, such as a page used to store a process code segment, a file, an icon resource, etc. Since the file-backed page has a file background, the file-backed page can be directly released during memory recycling, and data loss will not occur. An anonymous page is a page that does not have a mapping relationship with a file in the ROM storage space, that is, a page that does not have a file background or does not have a corresponding disk file, such as a heap, a stack, a data segment, etc. Since the anonymous page does not have a file background, the anonymous page cannot be directly released during memory recycling, otherwise data loss will occur and the anonymous page will be affected in subsequent access. Instead, the anonymous page is compressed and swapped out to the ROM storage space, or the anonymous page is directly swapped out to the ROM storage space without compression, and then the anonymous page in the RAM memory space can be released. In this way, more memory space can be obtained, and the data corresponding to the anonymous page can be avoided from being lost.

[0070] Based on this, during memory management, when a scenario in which the RAM memory space is under great pressure (such as a memory overload scenario) is detected, the anonymous pages in the RAM memory space can be recycled to the ROM storage space, so as to relieve the pressure of the RAM memory space. Referring to FIG. 1A, which is a schematic diagram of an anonymous page recycling scenario. Taking 12 GB of RAM memory space and 512 GB of ROM storage space as an example, when the RAM memory space is under great pressure, the anonymous pages are recycled. In a hybrid large page scenario, the anonymous pages can include anonymous standard pages and anonymous large pages. Further, in some embodiments, the anonymous large pages in the hybrid large page scenario can also include anonymous large pages of various granularities (or sizes), such as 16K, 32K, 64K, 128K, etc.

[0071] In one possible example, FIG. 1B is a flowchart of an anonymous page recycling process. The process includes the following steps:

[0072] S101, an anonymous page recycling event is detected.

[0073] For example, the anonymous page recycling event can include one or more of a memory overload scenario, a memory occupancy greater than a preset threshold, an application backgrounding, a high-load application starting, a user actively triggering memory space release, and the like. The memory overload scenario refers to a situation where the remaining available memory of the RAM memory space is small, the memory load is high, and the memory pressure is large. It can be understood that the memory overload scenario can affect the running of the application program, for example, causing lag, abnormal exit, and the like.

[0074] In S102, it is determined whether the anonymous page to be recycled is an anonymous large page. If yes, S103 is performed; otherwise, S104 is performed.

[0075] In S103, the anonymous page to be recycled is split into multiple anonymous standard pages.

[0076] Specifically, in the case where the anonymous page to be recycled is an anonymous large page, the anonymous large page is split (or divided) into multiple anonymous standard pages before the compression and swapping-out operations are performed. For example, if the size of the anonymous large page is 16K, one anonymous large page is composed of 4 anonymous standard pages with a size of 4K. Therefore, if the anonymous large page with a size of 16K is to be recycled, the anonymous large page needs to be divided into 4 anonymous standard pages with a size of 4K.

[0077] In S104, the anonymous standard pages are compressed to a temporary cache area.

[0078] For example, the existing compression algorithm can be used to compress the multiple anonymous standard pages obtained after the anonymous large page is split, and the compressed anonymous standard pages are temporarily stored in the temporary cache area of the RAM memory space.

[0079] In S105, the compressed anonymous standard pages are swapped out from the temporary cache area to the ROM storage space.

[0080] For example, the compressed anonymous standard pages can be stored in the data storage area of the ROM storage space.

[0081] In addition, the compressed anonymous standard pages swapped out to the ROM storage space can also be swapped back to the temporary cache area of the RAM memory space in reverse, and further, the compressed anonymous standard pages swapped back to the temporary cache area can also be decompressed to anonymous standard pages in reverse. For example, the above swapping-in and decompression processes can be performed when one or more of the following conditions occur: a non-memory overload scenario, a memory occupancy lower than a preset threshold, an application returning to the foreground, and the like.

[0082] As can be seen, in the anonymous page recycling process shown in FIG. 1B, in the hybrid large page scenario, if the anonymous large page is to be recycled, the anonymous large page needs to be split into anonymous standard pages first, and the large page splitting will increase the performance overhead.

[0083] Therefore, the embodiment of the present application provides an anonymous page recycling method. In the method, when memory recycling is needed, such as when a memory overload scenario is detected, the anonymous large page is not split but directly compressed and swapped out, or directly swapped out without compression, which can avoid the increase of performance overhead caused by large page splitting in the memory recycling process. In this way, the method can pre-configure different anonymous large page recycling strategies under the detection of different memory scenarios, such as different anonymous large page recycling strategies used in the memory overload scenario and the non-memory overload scenario, so as to achieve the balance between recycling efficiency and performance overhead, and maximize the performance advantage of the hybrid large page.

[0084] The technical solutions in the embodiments of the present application can be applied to an electronic device, which can be any device with limited RAM memory space. For example, the electronic device can be an electronic device such as a mobile phone, a tablet computer, a wearable device (for example, a watch, a bracelet, etc.), a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a smart home device (for example, a smart television, etc.), and the like. It can be understood that the embodiments of the present application do not make any limitation on the specific type of the electronic device.

[0085] The electronic device to which the embodiments of the present application can be applied, exemplary embodiments include but are not limited to electronic devices carrying or other operating systems. The electronic device may, for example, be the electronic device introduced in the foregoing embodiments.

[0086] FIG. 2 shows a possible hardware structure schematic diagram of an electronic device. The electronic device 200 includes radio frequency (RF) circuit 210, power supply 220, processor 230, memory 240, input unit 250, display unit 260, audio circuit 270, communication interface 280, and Wi-Fi module 290, and the like. Those skilled in the art can understand that the hardware structure of the electronic device 200 shown in FIG. 2 does not constitute a limitation on the electronic device 200, and the electronic device 200 provided by the embodiments of the present application can include more or fewer components than those shown, can combine two or more components, or can have a different component configuration. The various components shown in FIG. 2 can be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0087] The various constituent components of the electronic device 200 will be specifically introduced below in conjunction with FIG. 2:

[0088] The RF circuit 210 can be used for receiving and sending data in the process of communication or conversation. In particular, the RF circuit 210 sends the downlink data received from the base station to the processor 230 for processing, and sends the uplink data to be sent to the base station. Generally, the RF circuit 210 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc.

[0089] In addition, the RF circuit 210 can also communicate with other devices through a wireless communication network. The wireless communication can use any communication standard or protocol, including but not limited to global system of mobile communication (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), long term evolution (LTE), email, short messaging service (SMS), etc.

[0090] The Wi-Fi technology belongs to a short distance wireless transmission technology. The electronic device 200 can connect to an access point (AP) through the Wi-Fi module 290 to access a data network. The Wi-Fi module 290 can be used for receiving and sending data in the process of communication.

[0091] The electronic device 200 can be physically connected to other devices through the communication interface 280. Optionally, the communication interface 280 and the communication interface of the other device are connected through a cable to realize data transmission between the electronic device 200 and the other device.

[0092] The electronic device 200 can also realize communication services and interact with other electronic devices, so the electronic device 200 needs to have a data transmission function, that is, the electronic device 200 needs to include a communication module. Although FIG. 2 shows the RF circuit 210, the Wi-Fi module 290, and the communication interface 280, etc. as communication modules, it can be understood that the electronic device 200 includes at least one of the above components or other communication modules (such as a Bluetooth module) for realizing communication to perform data transmission.

[0093] The memory 240 can be configured to store software programs and modules. The processor 230 can execute various function applications and data processing of the electronic device 200 by running the software programs and modules stored in the memory 240. Optionally, the memory 240 can mainly include a program storage area and a data storage area. The program storage area can store an operating system (mainly including respective software programs or modules of a kernel layer, a system layer, an application program framework layer, and an application program layer).

[0094] In addition, the memory 240 can include a RAM 241, that is, a high-speed random access memory, and can also include a ROM 242, that is, a nonvolatile memory, for example, at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. In an embodiment of the present application, a method provided by the embodiment of the present application can be used, for example, when it is detected that the RAM 241 is in a memory reloading scenario, the anonymous large pages included in the RAM 241 are swapped out to the ROM 242.

[0095] The input unit 250 can be configured to receive editing operations of various types of data objects such as digital or character information input by a user, and to generate key signal inputs related to user settings and function control of the electronic device 200. Optionally, the input unit 250 can include a touch panel 251 and other input devices 252.

[0096] The touch panel 251, also referred to as a touch screen, can collect touch operations of a user thereon or therearound (such as operations of the user using a finger, a stylus, or any suitable object or accessory on or near the touch panel 251), and drive corresponding connection devices according to a pre-set program. In an embodiment of the present application, the touch panel 251 can collect user operations of a user thereon or therearound.

[0097] Optionally, the other input devices 252 can include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, on-off keys, etc.), a trackball, a mouse, a joystick, and the like.

[0098] The display unit 260 can be used to display information input by a user or information provided to the user, as well as various menus of the electronic device 200. The display unit 260 is a display system of the electronic device 200, and is used to present an interface and realize human-computer interaction. The display unit 260 can include a display panel 261. Optionally, the display panel 261 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. In this embodiment of the application, the display unit 260 can be used to display a user interface.

[0099] The processor 230 is a control center of the electronic device 200, and connects various components by using various interfaces and lines, executes various functions of the electronic device 200 and processes data by running or executing software programs and / or modules stored in the memory 240 and calling data stored in the memory 240, so that various services based on the electronic device 200 can be realized. In this embodiment of the application, the processor 230 can be used to implement an anonymous page recycling method provided in this embodiment of the application.

[0100] The electronic device 200 further includes a power supply 220 (such as a battery) for supplying power to various components. Optionally, the power supply 220 can be logically connected to the processor 230 through a power management system, so that the power management system can be used to manage charging, discharging, power consumption and the like.

[0101] As shown in FIG. 2, the electronic device 200 further includes an audio circuit 270, a microphone 271 and a speaker 272, which can provide an audio interface between a user and the electronic device 200. The audio circuit 270 can be used to convert audio data into a signal recognizable by the speaker 272, and transmit the signal to the speaker 272 to be converted into an audible signal by the speaker 272. The microphone 271 is used to collect external sound signals (such as human speech or other sounds), and convert the collected external sound signals into a signal recognizable by the audio circuit 270, and send the signal to the audio circuit 270. The audio circuit 270 can also be used to convert the signal sent by the microphone 271 into audio data, and then output the audio data to the RF circuit 210 for transmission to another electronic device, or output the audio data to the memory 240 for subsequent further processing.

[0102] Although not shown, the electronic device 200 can further include a camera, at least one sensor, and the like, which will not be described herein. The at least one sensor can include, but is not limited to, a pressure sensor, an air pressure sensor, an acceleration sensor, a distance sensor, a fingerprint sensor, a touch sensor, a temperature sensor, and the like.

[0103] The operating system (OS) involved in the embodiments of the present application is the most basic system software running on the electronic device 200. The software system of the electronic device 200 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiments of the present application take the operating system adopting a layered architecture as an example to exemplarily illustrate the software architecture of the electronic device 200.

[0104] FIG. 3 is a software architecture block diagram of an electronic device provided by an embodiment of the present application. As shown in FIG. 3, the software architecture of the electronic device can be a layered architecture, for example, the software can be divided into several layers, each layer has a clear role and division of labor. The layers communicate with each other through a software interface. In some embodiments, the operating system is divided into five layers, from top to bottom, the application program layer, the application program framework layer (FWK), the runtime and system library, the kernel layer, and the hardware layer.

[0105] The application program layer can include a series of application program packages. As shown in FIG. 3, the application program layer can include a user interface (UI), a camera, a setting, a skin module, a third-party application program, and the like. Among them, the third-party application program can include, for example, a wireless local area network (WLAN), music, a call, Bluetooth, a video, and the like. Among them, in the application program layer, the attributes of the UI including elements and the shadow of the elements can also be defined according to a system interface.

[0106] In a possible implementation manner, the application program can be developed using the java language, and is completed by calling the application programming interface (API) provided by the application program framework layer. The developer can interact with the bottom layer (such as the hardware layer, the kernel layer, and the like) of the operating system through the application program framework layer to develop his own application program. The application program framework layer is mainly a series of services and management systems of the operating system.

[0107] The application program framework layer provides the application programming interface and the programming framework for the application program of the application program layer. The application program framework layer includes some predefined functions. As shown in FIG. 3, the application program framework layer can include a view system, an activity manager, a window manager, a content provider, a phone manager, a resource manager, a notification manager, and the like.

[0108] The activity manager is used to manage the life cycle of each application program and provide a commonly used navigation back function, and provides an interactive interface for the window of all programs.

[0109] The window manager is used to manage windows programs. The window manager can get the display screen size, determine whether there is a status bar, lock the screen, take a screenshot, etc. The content provider is used to store and obtain data, and make the data accessible to application programs. The data can include videos, images, audio, dialed and received calls, browsing history and bookmarks, phonebook, etc.

[0110] The view system includes visual controls (also referred to as "visual elements") and non-visual controls (also referred to as "non-visual elements"), such as controls that display text, controls that display pictures, etc. The view system can be used to build application programs. A display interface can be composed of one or more views. For example, a display interface that includes a short message notification icon can include a view that displays text and a view that displays a picture.

[0111] The phone manager is used to provide the communication functions of the electronic device. For example, management of call status (including call connection, call hang-up, etc.).

[0112] The resource manager provides various resources for application programs, such as localized strings, icons, pictures, layout files, video files, etc.

[0113] The notification manager enables application programs to display notification information in the status bar, which can be used to convey messages of the notification type, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify the completion of a download, message reminders, etc. The notification manager can also be a notification that appears in the form of a chart or a scroll bar text in the top status bar of the system, such as a notification of an application program running in the background, and can also be a notification that appears in the form of a dialog window on the screen. For example, prompting text information in the status bar, issuing a prompt sound, the electronic device vibrating, the indicator light flashing, etc.

[0114] The runtime includes a core library and a virtual machine. The runtime is responsible for the scheduling and management of the operating system.

[0115] The core library contains two parts: one part is the function function that the java language needs to call, and the other part is the core library of the operating system. The application program layer and the application program framework layer run in the virtual machine. The virtual machine executes the java files of the application program layer and the application program framework layer into binary files. The virtual machine is used to perform object lifecycle management, stack management, thread management, security and exception management, and garbage collection functions.

[0116] The system library can include multiple functional modules. For example: surface manager, media framework, three-dimensional graphics processing library (such as OpenGL ES), two-dimensional graphics engine (such as SGL), etc.

[0117] The surface manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.

[0118] The media framework supports a variety of commonly used audio, video format playback and recording, and static image files, etc. The media framework can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0119] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc.

[0120] The 2D graphics engine is a drawing engine for 2D drawing. The 2D graphics engine can perform drawing operations to draw elements included in the UI and shadows of the elements on the screen.

[0121] In some embodiments, the 3D graphics processing library can be used to draw a 3D motion trajectory image, and the 2D graphics engine can be used to draw a 2D motion trajectory image.

[0122] The kernel layer is a layer between hardware and software. The kernel layer at least includes display drivers, camera drivers, audio drivers, and sensor drivers.

[0123] The hardware layer can include various sensors, such as acceleration sensors, gravity sensors, touch sensors, etc.

[0124] Generally, the electronic device 200 can run multiple applications simultaneously. More simply, one application can correspond to one process, and more complexly, one application can correspond to multiple processes. Each process has a process number (process ID).

[0125] It should be understood that "at least one" or similar expressions in the embodiments of the present application refer to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b, or c can represent: a, b, c, a and b, a and c, b and c, or a, b, and c, where a, b, and c can be single or multiple. "Multiple" refers to two or more. "And / or" is used to describe the association between the associated objects, which means that there can be three relationships, for example, A and / or B, which means that A exists alone, A and B exist together, B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects.

[0126] In addition, it should be understood that in the description of the present application, the words "first", "second", etc. are only used for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can it be understood as indicating or implying order.

[0127] It should be understood that the hardware structure of the electronic device can be as shown in FIG. 2, and the software system architecture can be as shown in FIG. 3, wherein the software system architecture in the electronic device corresponds to the software programs and / or modules stored in the memory 240, and the processor 230 can run the software programs and applications stored in the memory 240 to execute the flow of the anonymous page recycling method provided in the embodiments of the present application.

[0128] In order to facilitate the understanding of the anonymous page recycling method provided in the present application, the implementation process of the method provided in the present application will be introduced below in combination with the contents shown in FIGS. 4 to 8A, 8B to 12.

[0129] In one possible example, FIG. 4 is a schematic diagram of a scenario of the anonymous page recycling method provided in the embodiments of the present application. The method can be applied to an electronic device. In this scenario, when the electronic device detects an anonymous page recycling event, the splitting processing of the anonymous large page can be stopped, and the anonymous large page is directly compressed and stored in a temporary cache area, and finally exchanged out to the ROM storage space through the temporary cache area. Therefore, the additional management and performance overhead caused by the splitting processing can be reduced. For example, the anonymous page recycling event can include one or more of the following: a memory overload scenario, a memory occupancy rate greater than a preset threshold, an application background, a high-load application startup, a user actively triggering memory space release, and the like.

[0130] Based on the scenario shown in FIG. 4, FIG. 5 is a flowchart of the anonymous page recycling method provided in the embodiments of the present application. The flow can include the following steps:

[0131] Step 501, detecting an anonymous page recycling event. Optionally, the electronic device can determine the anonymous page recycling event according to at least one of the following information: the size of the remaining memory space, the number of large pages included in the RAM memory space, and the like.

[0132] For example, taking the detection of a memory overload scenario as an example, when the size of the remaining memory space is less than a preset memory space threshold, it can be determined that the memory overload scenario is detected. For another example, when the number of large pages included in the RAM memory space is greater than a preset large page number threshold, it can be determined that the memory overload scenario is detected, which can also be understood as that the number of large pages included in the RAM memory space is large, and at this time, it can also be used as a basis for determining that the memory overload scenario is detected. In addition, if the number of large pages is large, if the splitting, compression and exchange-out processing of the anonymous large page is adopted, it will also cause high performance overhead. For another example, when the size of the remaining memory space is less than a preset memory space threshold, and the number of large pages included in the RAM memory space is greater than a preset large page number threshold, it can be determined that the memory overload scenario is detected.

[0133] It should be noted that the detection manner of the memory reloading scenario in subsequent embodiments is similar, and subsequent details will not be repeated. The detection manner of other anonymous page recycling events can refer to the detection of the memory reloading scenario, and details will not be repeated.

[0134] Step 502, compressing the anonymous page to a temporary cache area. The anonymous page includes at least one memory granularity anonymous large page, such as 16K anonymous large page, 32K anonymous large page, 64K anonymous large page, and 128K anonymous large page. In addition, based on the consideration of memory management, business memory demand and other factors, the electronic device preferably uses 64K anonymous large page, thereby improving the efficiency of memory allocation, and improving the utilization rate of memory space, etc.

[0135] For example, the temporary cache area can be ZRAM (a memory optimization technology). ZRAM can make the electronic device use memory more efficiently and reduce the memory demand for swap space by dividing a piece of memory area as the exchange partition of RAM memory space and ROM storage space, and having an automatic compression function.

[0136] Step 503, swapping out the compressed anonymous page from the temporary cache area of the RAM memory space to the ROM storage space. For example, it can be swapped out to the preset data storage area of the ROM storage space, such as the compressed data storage area.

[0137] In addition, it should be noted that when the electronic device does not detect the anonymous page recycling event, the anonymous large page recycling can be performed according to the normal splitting-compression-swap process, which will not be repeated here. It can be understood that the anonymous standard page can be recycled according to the normal compression-swap process, which will not be repeated here.

[0138] In another possible example, FIG. 6 is another scenario diagram of an anonymous page recycling method provided by an embodiment of the present application. The method can be applied to an electronic device. In this scenario, when the electronic device detects an anonymous page recycling event, not only the splitting process of the anonymous large page is not performed, but also the compression process of the anonymous large page is not performed, that is, it is directly swapped out to the ROM storage space. Therefore, not only the additional management and performance overhead caused by the splitting process can be reduced, but also the additional memory load caused by the compression process and the storage of the temporary cache area can be reduced.

[0139] Based on the scenario shown in FIG. 6, FIG. 7 is a flow diagram of an anonymous page recycling method provided by an embodiment of the present application. The flow can include the following steps:

[0140] Step 701, detecting an anonymous page recycling event. The processing of step 701 can refer to the processing of step 501, and details will not be repeated here.

[0141] Step 702, determine whether the anonymous page to be recycled is an anonymous large page. When it is determined to be an anonymous large page, the following step 703 is executed. When it is determined to be an anonymous standard page, the following step 704 can be executed.

[0142] For example, when the size of the anonymous page is greater than 4K, the anonymous page can be determined to be an anonymous large page. Correspondingly, when the size of the anonymous page is equal to 4K, the anonymous page can be determined to be an anonymous standard page.

[0143] Step 703, directly swap the anonymous large page from the RAM memory space to the ROM storage space.

[0144] The anonymous page includes at least one memory granularity anonymous large page, an anonymous standard page. For example, the at least one memory granularity anonymous large page is 16K anonymous large page, 32K anonymous large page, 64K anonymous large page, 128K anonymous large page. In addition, based on the consideration of memory management, business memory demand and other factors, the electronic device preferably uses 64K anonymous large page, so as to improve the efficiency of memory allocation, and improve the utilization rate of memory space, etc.

[0145] For example, the preset data storage area of the ROM storage space, such as the compressed data storage area, etc.

[0146] Step 704, compress the anonymous standard page to a temporary cache area.

[0147] Step 705, swap the compressed anonymous standard page from the temporary cache area of the RAM memory space to the ROM storage space.

[0148] In this example, by directly swapping the anonymous large page, the additional memory load caused by the compression of the anonymous large page can be reduced, and the additional management and performance overhead caused by the splitting of the anonymous large page can be reduced. Moreover, by recycling the anonymous standard page using the standard compression-swap process, the memory occupied after swapping can be reduced by compressing the anonymous standard page. In this way, the memory pressure of the RAM memory space and the memory occupation of the ROM storage space can be balanced.

[0149] Another optional, when it is determined to be an anonymous standard page, the anonymous standard page recycling can also be performed according to the following step 703. It can be understood that at this time, it can be unnecessary to determine whether the anonymous page to be recycled is an anonymous large page.

[0150] In another possible example, FIG. 8A is another schematic diagram of another scenario of an anonymous page recycling method according to an embodiment of the present application. The method can be applied to an electronic device. In this scenario, when the electronic device detects an anonymous page recycling event, the anonymous page can be directly swapped out to the ROM storage space, i.e., without compression and without splitting the anonymous large page. Therefore, not only can the additional management and performance overhead caused by the splitting process be reduced, but the additional memory load caused by the compression process and the temporary cache area can also be reduced.

[0151] Based on the scenario shown in FIG. 8A, FIG. 8B is a flowchart of an anonymous page recycling method according to an embodiment of the present application. The flowchart can include the following steps:

[0152] Step 801: detecting an anonymous page recycling event. The processing of step 801 can also refer to the processing of step 501, which will not be described here.

[0153] Step 802: directly swapping the anonymous page from the RAM memory space to the ROM storage space. Compared with steps 702 and 703 in FIG. 7, whether the anonymous page is an anonymous large page or an anonymous standard page, the anonymous page can be directly swapped from the RAM memory space to the ROM storage space without determining whether the anonymous page is an anonymous large page.

[0154] The anonymous page includes at least one memory granularity anonymous large page and an anonymous standard page. The at least one memory granularity anonymous large page is, for example, a 16K anonymous large page, a 32K anonymous large page, a 64K anonymous large page, or a 128K anonymous large page. In addition, based on the consideration of memory management, business memory demand, and other factors, the electronic device preferably uses a 64K anonymous large page, thereby improving the efficiency of memory allocation and the utilization rate of memory space.

[0155] For example, the preset data storage area in the ROM storage space, such as a compressed data storage area, can be swapped out.

[0156] In a possible implementation manner, the electronic device can also adopt different anonymous page recycling strategies according to different degrees of memory overload. For example, referring to Table 1, a possible anonymous page recycling scenario is as follows:

[0157] Table 1

[0158] The order of the memory pressure in the above several memory overload degrees is: no memory overload < third-level memory overload < second-level memory overload < first-level memory overload, where the first-level memory overload indicates the largest memory pressure. For example, the smaller the remaining available memory space of the electronic device, the greater the memory pressure of the electronic device.

[0159] In this way, when the memory is not overloaded, the normal split-compression-swap procedure can be used for the anonymous large pages, and the normal compression-swap procedure can be used for the anonymous standard pages, so that the occupation of the ROM storage space after the anonymous pages are swapped out can be reduced.

[0160] When the third-level memory is overloaded, the non-split-compression-swap procedure can be used for the anonymous large pages, and the normal compression-swap procedure can be used for the anonymous standard pages, so that the additional management and performance overhead caused by the splitting processing of the anonymous large pages can be reduced.

[0161] When the second-level memory is overloaded, the direct-swap procedure can be used for the anonymous large pages, and the normal compression-swap procedure can be used for the anonymous standard pages, so that not only the additional management and performance overhead caused by the splitting processing of the anonymous large pages can be reduced, but also the additional memory load caused by the compression processing of the anonymous large pages and the storage of the temporary cache area can be reduced.

[0162] When the first-level memory is overloaded, the direct-swap procedure can be used for both the anonymous large pages and the anonymous standard pages, so that not only the additional management and performance overhead caused by the splitting processing of the anonymous large pages can be reduced, but also the additional memory load caused by the compression processing of the anonymous large pages and the anonymous standard pages and the storage of the temporary cache area can be reduced.

[0163] It can be understood that the above classification of the memory overload degree into four levels is only an example, and in actual applications, different classifications of the memory overload degree can be configured, and different anonymous page recycling strategies can be configured for each level, so as to balance the recycling efficiency and performance overhead.

[0164] It can be understood that the operation of splitting the anonymous large pages into anonymous standard pages and the operation of compressing the anonymous standard pages can not only bring negative effects such as increasing the performance overhead (such as increasing the computing power requirement and memory requirement of the system), but also bring positive effects such as reducing the occupation of the ROM storage space after swapping out. Therefore, in the case where the system is already overloaded and the computing power is insufficient, selectively discarding one or more of the above operations (the operation of splitting the anonymous large pages into anonymous standard pages and the operation of compressing the anonymous standard pages) can reduce the performance overhead. Although it may also increase the occupation of the ROM storage space after swapping out, at this time, the smoothness, response real-time performance, and user experience of the system are more important, and space can be exchanged for time, that is, space efficiency is sacrificed for time efficiency, so as to ensure the smoothness, response real-time performance, and user experience of the system.

[0165] Based on the same concept, the embodiment of the present application further provides a first anonymous page recycling method, which can be executed by the electronic device. FIG. 9 is a flow chart of the first anonymous page recycling method according to the embodiment of the present application. As introduced above, the anonymous page includes an anonymous large page and an anonymous standard page, the size of the anonymous large page is N times of the size of the anonymous standard page, and the N is a positive integer greater than 1. Referring to FIG. 9, the method includes the following steps:

[0166] S901: compressing the anonymous large page and the anonymous standard page to a temporary cache area in the memory space.

[0167] S902: swapping out the compressed anonymous large page and the compressed anonymous standard page in the temporary cache area to the storage space.

[0168] It should be noted that the anonymous page recycling method shown in FIG. 9 of the present application can refer to the embodiments corresponding to FIG. 4 and FIG. 5 in the specific implementation, and the repeated parts will not be described herein.

[0169] Based on the same concept, the embodiment of the present application further provides a second anonymous page recycling method, which can be executed by the electronic device. FIG. 10 is a flow chart of the second anonymous page recycling method according to the embodiment of the present application. As introduced above, the anonymous page includes an anonymous large page and an anonymous standard page, the size of the anonymous large page is N times of the size of the anonymous standard page, and the N is a positive integer greater than 1. Referring to FIG. 10, the method includes the following steps:

[0170] S1001: directly swapping out the anonymous large page to the storage space.

[0171] S1002: after compressing the anonymous standard page to a temporary cache area in the memory space, swapping out the compressed anonymous standard page in the temporary cache area to the storage space.

[0172] It should be noted that the anonymous page recycling method shown in FIG. 10 of the present application can refer to the embodiments corresponding to FIG. 6 and FIG. 7 in the specific implementation, and the repeated parts will not be described herein.

[0173] It can be understood that the embodiment of the present application does not limit the execution order of S1001 and S1002. S1001 and S1002 can be executed in parallel (or simultaneously, synchronously), or S1001 can be executed first and S1002 can be executed later, or S1002 can be executed first and S1001 can be executed later.

[0174] Based on the same idea, the embodiments of the present application further provide a third anonymous page recycling method, which can be executed by an electronic device. FIG. 11 is a flowchart of the third anonymous page recycling method provided by the embodiments of the present application. As introduced above, the anonymous page includes an anonymous large page and an anonymous standard page, the size of the anonymous large page is N times of the size of the anonymous standard page, and the N is a positive integer greater than 1. Referring to FIG. 11, the method includes the following steps:

[0175] S1101: directly swapping out the anonymous large page and the anonymous standard page to a storage space.

[0176] It should be noted that the anonymous page recycling method shown in FIG. 11 can refer to the embodiments corresponding to FIG. 8A and FIG. 8B in specific implementation, and the repeated parts will not be described herein.

[0177] Based on the same idea, the embodiments of the present application further provide a fourth anonymous page recycling method, which can be executed by an electronic device. FIG. 12 is a flowchart of the fourth anonymous page recycling method provided by the embodiments of the present application. As introduced above, the anonymous page includes an anonymous large page and an anonymous standard page, the size of the anonymous large page is N times of the size of the anonymous standard page, and the N is a positive integer greater than 1. Referring to FIG. 12, the method includes the following steps:

[0178] S1201: determining a current scenario in which the electronic device is located;

[0179] S1202: according to the current scenario in which the electronic device is located, recycling the anonymous large page and the anonymous standard page by using an anonymous page recycling manner corresponding to the current scenario in which the electronic device is located.

[0180] The current scenario in which the electronic device is located includes at least two of a first scenario, a second scenario, a third scenario, and a fourth scenario, the memory pressure of the electronic device in the first scenario < the memory pressure of the electronic device in the second scenario < the memory pressure of the electronic device in the third scenario < the memory pressure of the electronic device in the fourth scenario.

[0181] (1) the anonymous page recycling manner corresponding to the first scenario includes: splitting the anonymous large page into N anonymous standard pages; compressing the anonymous standard pages including the N anonymous standard pages obtained by splitting the anonymous large page to a temporary cache area in the memory space, and then swapping out the compressed anonymous standard pages in the temporary cache area to the storage space.

[0182] It should be noted that the anonymous page recycling manner corresponding to the scenario can refer to the embodiments corresponding to FIG. 1A and FIG. 1B in specific implementation, and the repeated parts will not be described herein.

[0183] (2), the anonymous page recycling mode corresponding to the second scenario comprises: compressing the anonymous large page and the anonymous standard page to the temporary cache area; and swapping out the compressed anonymous large page and the compressed anonymous standard page in the temporary cache area to the storage space.

[0184] It should be noted that the anonymous page recycling mode corresponding to this scenario can refer to the corresponding embodiments of FIG. 4 and FIG. 5 in specific implementation, and repeated parts will not be described again.

[0185] (3), the anonymous page recycling mode corresponding to the third scenario comprises: directly swapping out the anonymous large page to the storage space; and after compressing the anonymous standard page to the temporary cache area, swapping out the compressed anonymous standard page in the temporary cache area to the storage space.

[0186] It should be noted that the anonymous page recycling mode corresponding to this scenario can refer to the corresponding embodiments of FIG. 6 and FIG. 7 in specific implementation, and repeated parts will not be described again.

[0187] (4), the anonymous page recycling mode corresponding to the fourth scenario comprises: directly swapping out the anonymous large page and the anonymous standard page to the storage space.

[0188] It should be noted that the anonymous page recycling mode corresponding to this scenario can refer to the corresponding embodiments of FIG. 8A and FIG. 8B in specific implementation, and repeated parts will not be described again.

[0189] It should be noted that the anonymous page recycling method shown in FIG. 12 of the present application can refer to the corresponding embodiments of Table 1 in specific implementation, and repeated parts will not be described again.

[0190] Based on the above embodiments, the present application further provides an electronic device, which comprises a plurality of functional modules; the plurality of functional modules interact to realize the functions performed by the electronic device in the methods described in the embodiments of the present application. The plurality of functional modules can be realized based on software, hardware or a combination of software and hardware, and the plurality of functional modules can be arbitrarily combined or divided based on specific implementation. For example, steps 501 to 503 performed by the electronic device in the embodiment shown in FIG. 5. Or steps 701 and 705 performed by the electronic device in the embodiment shown in FIG. 7. Or steps 801 and 802 performed by the electronic device in the embodiment shown in FIG. 8B. Or steps 901 and 902 performed by the electronic device in the embodiment shown in FIG. 9. Or steps 1001 and 1002 performed by the electronic device in the embodiment shown in FIG. 10. Or step 1101 performed by the electronic device in the embodiment shown in FIG. 11. Or steps 1201 and 1202 performed by the electronic device in the embodiment shown in FIG. 12.

[0191] Based on the above embodiments, the present application further provides an electronic device, comprising at least one processor and at least one memory, wherein the at least one memory stores computer program instructions, and when the electronic device is running, the at least one processor executes the functions performed by the electronic device in the methods described in the embodiments of the present application. For example, the electronic device executes steps 501 to 503 in the embodiment shown in FIG. 5. Or the electronic device executes steps 701 and 705 in the embodiment shown in FIG. 7. Or the electronic device executes steps 801 and 802 in the embodiment shown in FIG. 8B. Or the electronic device executes steps 901 and 902 in the embodiment shown in FIG. 9. Or the electronic device executes steps 1001 and 1002 in the embodiment shown in FIG. 10. Or the electronic device executes step 1101 in the embodiment shown in FIG. 11. Or the electronic device executes steps 1201 and 1202 in the embodiment shown in FIG. 12.

[0192] Based on the above embodiments, the present application further provides a computer program product, comprising: a computer program (also referred to as code or instructions), when the computer program is executed, causing a computer to execute the methods described in the embodiments of the present application.

[0193] Based on the above embodiments, the present application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, when the computer program is executed by a computer, causing the computer to execute the methods described in the embodiments of the present application.

[0194] Based on the above embodiments, the present application further provides a chip, which is used to read a computer program stored in a memory, and implements the methods described in the embodiments of the present application.

[0195] Based on the above embodiments, the present application provides a chip system, which comprises a processor, and is used to support a computer device to implement the methods described in the embodiments of the present application. In a possible design, the chip system further comprises a memory, and the memory is used to store necessary programs and data of the computer device. The chip system can be composed of a chip, or can include a chip and other discrete devices. Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt a form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt a form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.

[0196] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks.

[0197] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart block or blocks.

[0198] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks.

[0199] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. An anonymous page reclamation method, applied to electronic devices, characterized in that, The anonymous page includes an anonymous large page and an anonymous standard page. The size of the anonymous large page is N times the size of the anonymous standard page, where N is a positive integer greater than 1. The method includes: The anonymous large pages and the anonymous standard pages are compressed into a temporary cache area in memory space; The compressed anonymous large pages and compressed anonymous standard pages in the temporary cache area are swapped out to the storage space.

2. The method according to claim 1, characterized in that, The size of the anonymous standard page is 4 kilobytes (K), N is 2 to the power of M, and M is a positive integer greater than 1.

3. The method according to claim 1 or 2, characterized in that, The size of the anonymous standard page is 4K, and the size of the anonymous large page is 64K.

4. The method according to any one of claims 1 to 3, characterized in that, The step of compressing the anonymous large pages and the anonymous standard pages into a temporary cache area in memory specifically includes: In response to the detection of an anonymous page reclamation event, the anonymous large page and the anonymous standard page are compressed into a temporary cache area in the memory space.

5. The method according to claim 4, characterized in that, The anonymous page reclamation event includes one or more of the following: memory overload scenario, memory usage exceeding a preset threshold, application exiting the background, high-load application startup, and user-initiated memory space release.

6. The method according to claim 5, characterized in that, Detected a memory overload scenario, including: When it is determined that the remaining memory space is less than the memory space threshold, it is determined that the memory space is in a memory overload scenario; and / or, When the number of large pages is determined to be greater than the large page number threshold, the memory space is determined to be in a memory overload scenario; wherein, the large pages include anonymous large pages and file large pages.

7. An anonymous page recycling method, applied to electronic devices, characterized in that, The anonymous page includes an anonymous large page and an anonymous standard page. The size of the anonymous large page is N times the size of the anonymous standard page, where N is a positive integer greater than 1. The method includes: The anonymous large page is directly swapped out to the storage space; After compressing the anonymous standard pages into a temporary cache area in the memory space, the compressed anonymous standard pages in the temporary cache area are then swapped out to the storage space.

8. The method according to claim 7, characterized in that, The method specifically includes: Determine whether the anonymous page to be reclaimed is the aforementioned anonymous large page; If the anonymous page to be reclaimed is the anonymous large page, then the anonymous large page will be directly swapped out to the storage space; Otherwise, the anonymous page to be reclaimed is an anonymous standard page. After compressing the anonymous standard page into the temporary cache area in the memory space, the compressed anonymous standard page in the temporary cache area is swapped out to the storage space.

9. The method according to claim 7 or 8, characterized in that, The size of the anonymous standard page is 4 kilobytes (K), N is 2 to the power of M, and M is a positive integer greater than 1.

10. The method according to any one of claims 7 to 9, characterized in that, The size of the anonymous standard page is 4K, and the size of the anonymous large page is 64K.

11. The method according to any one of claims 7 to 10, characterized in that, The step of compressing the anonymous large pages and the anonymous standard pages into a temporary cache area in memory specifically includes: In response to the detection of an anonymous page reclamation event, the anonymous large page and the anonymous standard page are compressed into a temporary cache area in the memory space.

12. The method according to claim 11, characterized in that, The anonymous page reclamation event includes one or more of the following: memory overload scenario, memory usage exceeding a preset threshold, application exiting the background, high-load application startup, and user-initiated memory space release.

13. The method according to claim 12, characterized in that, Detected a memory overload scenario, including: When it is determined that the remaining memory space is less than the memory space threshold, it is determined that the memory space is in a memory overload scenario; and / or, When the number of large pages is determined to be greater than the large page number threshold, the memory space is determined to be in a memory overload scenario; wherein, the large pages include anonymous large pages and file large pages.

14. An anonymous page reclamation method, applied to electronic devices, characterized in that, The anonymous page includes an anonymous large page and an anonymous standard page. The size of the anonymous large page is N times the size of the anonymous standard page, where N is a positive integer greater than 1. The method includes: The anonymous large page and the anonymous standard page are directly swapped out to the storage space.

15. The method according to claim 14, characterized in that, The size of the anonymous standard page is 4 kilobytes (K), N is 2 to the power of M, and M is a positive integer greater than 1.

16. The method according to claim 14 or 15, characterized in that, The size of the anonymous standard page is 4K, and the size of the anonymous large page is 64K.

17. The method according to any one of claims 14 to 16, characterized in that, The step of compressing the anonymous large pages and the anonymous standard pages into a temporary cache area in memory specifically includes: In response to the detection of an anonymous page reclamation event, the anonymous large page and the anonymous standard page are compressed into a temporary cache area in the memory space.

18. The method according to claim 17, characterized in that, The anonymous page reclamation event includes one or more of the following: memory overload scenario, memory usage exceeding a preset threshold, application exiting the background, high-load application startup, and user-initiated memory space release.

19. The method according to any one of claims 14 to 18, characterized in that, Detected a memory overload scenario, including: When it is determined that the remaining memory space is less than the memory space threshold, it is determined that the memory space is in a memory overload scenario; and / or, When the number of large pages is determined to be greater than the large page number threshold, the memory space is determined to be in a memory overload scenario; wherein, the large pages include anonymous large pages and file large pages.

20. An anonymous page reclamation method, applied to electronic devices, characterized in that, The anonymous page includes an anonymous large page and an anonymous standard page. The size of the anonymous large page is N times the size of the anonymous standard page, where N is a positive integer greater than 1. The method includes: Determine the current scene of the electronic device; Based on the current scenario of the electronic device, an anonymous page recycling method corresponding to the current scenario of the electronic device is adopted to recycle the anonymous large page and the anonymous standard page; The scenario in which the electronic device is currently located includes at least two of the following scenarios: a first scenario, a second scenario, a third scenario, and a fourth scenario. The memory pressure of the electronic device in the first scenario is less than the memory pressure of the electronic device in the second scenario, which is less than the memory pressure of the electronic device in the third scenario, which is less than the memory pressure of the electronic device in the fourth scenario. The anonymous page reclamation methods corresponding to the first scenario include: The anonymous large page is split into N anonymous standard pages; After compressing the anonymous standard pages, including the N anonymous standard pages obtained by splitting the anonymous big page, into a temporary cache area in the memory space, the compressed anonymous standard pages in the temporary cache area are swapped out to the storage space. The anonymous page reclamation methods corresponding to the second scenario include: Compress the anonymous large page and the anonymous standard page into the temporary cache area; The compressed anonymous large pages and compressed anonymous standard pages in the temporary cache area are swapped out to the storage space; The anonymous page reclamation methods corresponding to the third scenario include: The anonymous large page is directly swapped out to the storage space; After compressing the anonymous standard pages into the temporary cache area, the compressed anonymous standard pages in the temporary cache area are then swapped out to the storage space. The anonymous page reclamation methods corresponding to the fourth scenario include: The anonymous large page and the anonymous standard page are directly swapped out to the storage space.

21. The method according to claim 20, characterized in that, The size of the anonymous standard page is 4 kilobytes (K), N is 2 to the power of M, and M is a positive integer greater than 1.

22. The method according to claim 20 or 21, characterized in that, The size of the anonymous standard page is 4K, and the size of the anonymous large page is 64K.

23. An electronic device, characterized in that, Including processor and memory; The processor is configured to execute instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1-6, or the method as described in any one of claims 7-13, or the method as described in any one of claims 14-19, or the method as described in any one of claims 20-22.

24. A computer storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to perform the method as claimed in any one of claims 1-6, or the method as claimed in any one of claims 7-13, or the method as claimed in any one of claims 14-19, or the method as claimed in any one of claims 20-22.

Citation Information

Patent Citations

  • Large page memory compression recovery system and method

    CN106980541A

  • Data processing method and device

    CN113296940A

  • Anonymous page recovery method and electronic equipment

    CN114741205A

  • Memory page caching method and device, electronic equipment and storage medium

    CN115509958A

  • Identification of page sharing opportunities within large pages

    US20150012722A1