CN114185494A - Memory anonymous page processing method, electronic device and readable storage medium - Google Patents

Memory anonymous page processing method, electronic device and readable storage medium Download PDF

Info

Publication number
CN114185494A
CN114185494A CN202210143582.3A CN202210143582A CN114185494A CN 114185494 A CN114185494 A CN 114185494A CN 202210143582 A CN202210143582 A CN 202210143582A CN 114185494 A CN114185494 A CN 114185494A
Authority
CN
China
Prior art keywords
anonymous page
anonymous
page
preset area
electronic device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210143582.3A
Other languages
Chinese (zh)
Other versions
CN114185494B (en
Inventor
高旭
李鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Glory Smart Technology Development Co ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202210143582.3A priority Critical patent/CN114185494B/en
Publication of CN114185494A publication Critical patent/CN114185494A/en
Application granted granted Critical
Publication of CN114185494B publication Critical patent/CN114185494B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0616Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0631Configuration or reconfiguration of storage systems by allocating resources to storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Storage Device Security (AREA)

Abstract

The application provides a processing method of memory anonymous pages, an electronic device and a readable storage medium, which belong to the technical field of electronic devices, and the method comprises the following steps: the electronic equipment receives a first operation of exiting an application; in response to the first operation, the electronic device determines an anonymous page corresponding to the application; in a preset area of an external memory of the electronic equipment, the electronic equipment carries out retrieval based on the anonymous page; and the electronic equipment executes the writing operation of the anonymous page according to the retrieval result. According to the processing method, the same anonymous page can be effectively prevented from being repeatedly written into the preset area by searching before the writing operation is executed, and the utilization rate of the preset area is improved. Meanwhile, for the processor, the writing times are reduced, the execution efficiency of the processor can be improved, for the external memory, the space is reasonably utilized, the written times are reduced, and the service life of the external memory can be prolonged.

Description

Memory anonymous page processing method, electronic device and readable storage medium
Technical Field
The present invention relates to the field of electronic technologies, and in particular, to a method for processing an anonymous page of a memory, an electronic device, and a readable storage medium.
Background
In Android (Android system), when an application of the electronic device is temporarily not used, the application is switched to background temporary storage. For example, when the user clicks and uses the application again, the electronic device may quickly switch the application from the background to the foreground, so that the user can quickly browse the page of the application. However, when the memory of the system is insufficient, the system may clean the page data corresponding to the application buffered in the background. When the user opens the cleaned application again, the system loads the application data from the Read-Only Memory (ROM) again and starts the application, so that the time for re-opening the application page is reduced, the interface of the last operation of the user is not reserved, and the user experience is poor.
To improve the above problem, increasing the memory space or creating a Swap (Swap) area on the ROM is currently adopted, wherein selecting a device with larger memory capacity results in increased cost of the product. By creating a Swap area (Swap) on the ROM, the electronic device dumps an anonymous page that is not commonly used in the system into the Swap area of the ROM each time an application is switched, and reads from the Swap area as needed. A large number of anonymous pages are dumped into ROM and read again, resulting in a shortened ROM device lifetime.
Disclosure of Invention
In view of this, the present invention provides a method for processing anonymous pages of a memory, an electronic device, and a computer-readable storage medium, so as to solve the problems of poor user experience and shortened lifetime of a ROM device.
Some embodiments of the present application provide a method for processing anonymous pages of a memory. The present application is described below in terms of several aspects, embodiments and advantages of which are mutually referenced.
In a first aspect, the present invention provides a method for processing an anonymous memory page, which is applied to an electronic device, and includes:
the electronic equipment receives a first operation of exiting an application;
in response to the first operation, the electronic device determines an anonymous page corresponding to the application;
in a preset area of an external memory of the electronic equipment, the electronic equipment carries out retrieval based on the anonymous page;
and the electronic equipment executes the writing operation of the anonymous page according to the retrieval result.
According to the method for processing the anonymous page of the memory, before the writing operation of the anonymous page is executed, the anonymous page is searched, whether the writing operation needs to be executed is determined according to the searching result, and therefore unnecessary writing operation can be effectively avoided.
In a possible implementation of the first aspect, the electronic device performs retrieval based on an anonymous page, and the method includes:
the electronic equipment searches the hash table based on the hash value corresponding to the anonymous page and obtains a search result, and the hash table is stored in a physical memory of the electronic equipment and used for recording the hash value corresponding to the anonymous page written in the preset area. By means of the retrieval mode of the hash table, the calculation is fast, the occupied space is small, and the anonymous page is convenient to retrieve.
In a possible implementation of the first aspect, the electronic device, according to a result of the retrieving, performs a write operation of the anonymous page, including:
and the electronic equipment determines that the retrieval result is that the hash value corresponding to the anonymous page exists in the hash table, which indicates that the anonymous page already exists in the preset area, and does not execute writing of the anonymous page into the preset area. Repeated writing of the same data is avoided, and the utilization rate of the preset area is improved. Meanwhile, for the processor, the writing times are reduced, the execution efficiency of the processor can be improved, for the external memory, the space is reasonably utilized, the written times are reduced, and the service life of the external memory can be prolonged.
In a possible implementation of the first aspect, the electronic device, according to a result of the retrieving, performs a write operation of the anonymous page, including:
the electronic equipment determines that the retrieval result is that the hash value corresponding to the anonymous page does not exist in the hash table, which indicates that the anonymous page is not written in the preset area;
and the electronic equipment writes the anonymous page into the preset area, releases the physical memory and records that the anonymous page is written into the preset area. And when writing is carried out next time, whether anonymous pages are written in the preset area or not can be judged through recording.
In a possible implementation of the first aspect, the recording that the anonymous page has been written in the preset area includes:
the electronic device generates a hash value corresponding to the anonymous page and saves the hash value in a hash table. When the same anonymous page needs to be written for multiple times, the hash value corresponding to the anonymous page in the hash table marks a reference count, that is, the reference count is increased by 1 each time the anonymous page needs to be written.
In a possible implementation of the first aspect, the writing, by the electronic device, the anonymous page into the preset area includes:
and the electronic equipment compresses the anonymous page and writes the compressed anonymous page into a preset area.
In a possible implementation of the first aspect, the method further includes:
the electronic device receives a second operation of switching the application to the current interface,
in response to the second operation, the electronic device reads the anonymous page from the preset area and marks the read page, wherein the mark read can adopt a reference counting mode, and the reference counting response is reduced by 1 every time the mark read is read;
when the remaining space of the preset area is less than or equal to the preset value, the electronic device deletes the anonymous page marked as read from the preset area, wherein the anonymous page with the reference count of 0 can be preferentially deleted.
According to the method, the read anonymous page is not deleted immediately, but is deleted after the preset value is reached, so that the probability of anonymous page retrieval hit in a writing scene can be increased, and repeated writing is avoided as far as possible. So as to reduce the writing times and promote the swap writing speed. Further avoid frequently writing into the damage external memory, improve the life of external memory.
In a possible implementation of the first aspect, when the remaining space of the preset area is greater than the preset value, the electronic device retains the read anonymous page in the preset area.
In a possible implementation of the first aspect, an electronic device reads an anonymous page from a preset area, and the method includes:
and the electronic equipment reads the compressed anonymous page from the preset area to the zram area for decompression, and then reads the decompressed anonymous page.
In a possible implementation of the first aspect, the preset area is a swap area or a swap file.
In a second aspect, the present application further provides an electronic device, comprising: at least one processor and a memory, the memory including physical memory and external memory, for storing instructions for execution by the one or more processors of the device;
a processor to execute instructions and perform:
receiving a first operation of exiting the application;
responding to the first operation, and determining an anonymous page corresponding to the application from a physical memory;
in a preset area of an external memory, searching based on an anonymous page;
and according to the retrieval result, executing the write operation of the anonymous page.
In a possible implementation of the second aspect, the processor searches the hash table based on the hash value corresponding to the anonymous page, and obtains a search result, where the hash table is stored in a physical memory of the electronic device and used for recording the hash value corresponding to the anonymous page that has been written into the preset area. By means of the retrieval mode of the hash table, the calculation is fast, the occupied space is small, and the anonymous page is convenient to retrieve.
In a possible implementation of the second aspect, the processor determines that the hash value corresponding to the anonymous page exists in the hash table as a result of the retrieval, which indicates that the anonymous page already exists in the preset area, and the processor does not perform writing of the anonymous page into the preset area. Repeated writing of the same data is avoided, and the utilization rate of the preset area is improved. Meanwhile, for the processor, the writing times are reduced, the running speed of the processor can be improved, for the external memory, the space is reasonably utilized, the written times are reduced, and the service life of the external memory can be prolonged.
In a possible implementation of the second aspect, the processor determines that the hash value corresponding to the anonymous page does not exist in the hash table as a result of the retrieval, which indicates that the anonymous page is not written in the preset area;
and the processor writes the anonymous page into the preset area, releases the physical memory and records that the anonymous page is written into the preset area.
In one possible implementation of the second aspect, the processor is configured to generate a hash value corresponding to the anonymous page, and save the hash value in a hash table to record that the anonymous page has been written in the preset area.
In a possible implementation of the second aspect, the processor is configured to compress the anonymous page, and write the compressed anonymous page into the preset area.
In a possible implementation of the second aspect, the processor is further configured to perform:
a second operation to switch the application to the current interface is received,
in response to a second operation, reading the anonymous page from the preset area and marking the read page;
and when the residual space of the preset area is less than or equal to the preset value, deleting the anonymous page marked to be read from the preset area.
According to the method, the read anonymous page is not deleted immediately, but is deleted after the preset value is reached, so that the probability of anonymous page retrieval hit in a writing scene can be increased, and repeated writing is avoided as far as possible. So as to reduce the writing times and promote the swap writing speed. Further avoid frequently writing into the damage external memory, improve the life of external memory.
In a possible implementation of the second aspect, the processor is configured to reserve the read anonymous page in the preset area when the remaining space of the preset area is larger than the preset value.
In a possible implementation of the second aspect, the processor is configured to read the compressed anonymous page from the preset area to the zram area for decompression, and then read the decompressed anonymous page.
In a possible implementation of the second aspect, the preset area is a swap area or a swap file.
In a third aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by an electronic device, the computer program causes the electronic device to execute the method in the first aspect.
In a fourth aspect, the present application discloses a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of the first aspect embodiment described above.
Drawings
FIG. 1 is a diagram of a scenario in which a user switches applications using a mobile phone;
FIG. 2 is a schematic diagram of an internal architecture of a mobile phone and an anonymous page dump process;
fig. 3 is a schematic diagram of an internal architecture of a mobile phone and an anonymous page dump process according to an embodiment of the present application;
FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to another embodiment of the present application;
FIG. 6 is a diagram illustrating a software architecture of an electronic device according to an embodiment of the present application;
fig. 7 is an interaction flowchart of a processing method for executing anonymous memory pages by each module in a mobile phone according to an embodiment of the present application;
FIG. 8 is a diagram illustrating a relationship between an anonymous page and a hash value according to an embodiment of the present application;
fig. 9 is an interaction flowchart of a processing method for executing anonymous memory pages by each module in a mobile phone according to another embodiment of the present application;
FIG. 10 is a block diagram of a system on a chip according to some embodiments of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
In order to facilitate understanding of the technical solutions of the present application, the following first describes key terms appearing in the present application.
The memory in the present application includes a logical memory (also referred to as a virtual memory) and a physical memory, and the physical memory may be used for storing page data corresponding to an application. In the android system, page data is mainly stored by means of file-backed pages and anonymous pages.
The external Memory is referred to as an "external Memory" in this application, and the internal Memory is a main Memory of the electronic device, and may also be referred to as a "internal Memory" as well, for example, a Random Access Memory (RAM). The external Memory is used as an auxiliary Memory of the electronic device, and is also called as an external Memory, for example, a Read Only Memory (ROM). In some embodiments, the external memory may also be a hard disk, a floppy disk, an optical disk, a usb disk, an embedded multimedia card (emmc), a Universal Flash Storage (UFS), a multimedia card, or the like.
The file pages can be mapped into an external memory (also referred to as an external memory in the present application), and when the memory space is insufficient, the physical memory can be released by cleaning the file pages of the memory space, and when necessary, the physical memory can be read from the external memory again.
Anonymous page refers to heap memory dynamically allocated by an application. When the application is enabled again, the application may be accessed again, and usually cannot be directly recycled, and the anonymous page has no mapping with the external memory, so that the internal memory cannot be directly recycled and released. Therefore, in order to retain the anonymous page and save the memory space, a swap area (swap space) is usually established on the external memory as a space (virtual memory space) for assisting the memory, and the system transfers the anonymous page to the swap area, so that the memory space can be released, and the anonymous page can be cleaned up due to insufficient memory space. And when the application is reused, the system can directly read the anonymous page from the swap area, and the efficiency of switching back the application is improved.
zRAM, also known as zRAM, is a function of the CPU core and provides virtual memory compression. In the method, before the anonymous page is transferred to the swap area, the anonymous page is compressed through the zram function, and then the compressed anonymous page is stored in a physical memory (zram area) temporarily applied by the zram, so that the memory overhead of the swap area and the transmission overhead when the anonymous page is exchanged to an external memory are reduced, and the performance is improved.
The technical solution of the present application is explained below with reference to a scene diagram.
Referring to fig. 1, fig. 1 illustrates a scenario in which a user switches an application using a cellular phone. As shown in fig. 1 (a), when the user opens the application 1, an interface a of the application 1 is displayed on the screen of the mobile phone 10. When the user exits the application 1 (at this time, the application 1 is running in the background, not closed), the mobile phone desktop, or opens the application 2, as shown in fig. 2 (b), the interface of the application 2 has been displayed on the screen of the mobile phone 10. When the user switches back to the application 1, as shown in fig. 3 (c), the screen of the mobile phone 10 returns to the interface a of the application 1.
The technical problem of the embodiments of the present application is described in conjunction with the scenario described in fig. 1.
Referring to fig. 1, in a normal situation, when the mobile phone 10 receives an operation of switching back the application 1, since the application 1 runs in the background, when switching back the interface a of the application 1, the screen of the mobile phone 10 can quickly display the interface a of the application 1. However, when the memory space of the mobile phone 10 is insufficient, when the user exits the application 1, the mobile phone 10 deletes the page data corresponding to the application 1, including the document page and the anonymous page. Therefore, when the mobile phone 10 receives the operation of switching back to the application 1, the anonymous page in the page data is also deleted, and the anonymous page is not mapped or transferred to the external memory, so that the mobile phone system needs to reload the page data corresponding to the application 1, and compared with the case that the memory space is sufficient, the speed of switching back to the application 1 by the mobile phone is slow, and the interface a of the application 1 cannot be directly displayed, so that the user experience is poor.
Referring to fig. 2, fig. 2 shows a schematic diagram of the internal architecture of the handset and a schematic diagram of the anonymous page dump process. As shown in fig. 2, the mobile phone includes a processor and an external memory, and in order to avoid anonymous pages from being deleted due to insufficient memory space, the mobile phone dumps anonymous pages that are not commonly used in the system into a Swap area of the external memory by creating the Swap area on the external memory. And after the application is retired to the background, the processor writes the anonymous page of the application into the swap area, and then releases the memory. When the processor receives a switch back application command, i.e., a command to switch the application back to the foreground, the mobile phone 10 will "read" the anonymous page from the swap area into the memory space. And cycling back and forth, each application exit will correspond to an anonymous page written to an application once, so that the Swap area is written with the same data frequently. Because the ROM space is used as persistent equipment, the service life is limited, a large number of anonymous pages are dumped and read again, the service life of the equipment can be greatly damaged, and the workload of the mobile phone can be increased due to frequent writing, so that the overall operation speed is influenced.
In view of the above, an embodiment of the present application provides a method for processing an anonymous page of a memory, which is used to solve the above technical problem.
The following outlines a processing method of memory anonymous pages according to an embodiment of the present application with reference to the drawings.
Referring to fig. 3, fig. 3 shows a schematic diagram of an internal architecture of a mobile phone and a schematic diagram of an anonymous page unloading process according to an embodiment of the present application. As shown in fig. 3, after receiving an application exit instruction, the mobile phone processor determines an anonymous page corresponding to the application, searches whether the anonymous page has been written in the swap area, and writes the anonymous page into the swap area when the anonymous page is not searched in the swap area. And when the anonymous page is retrieved and stored in the swap area, the anonymous page is not written into the swap area any more. Compared with the processing flow in fig. 2, the anonymous page processing method can effectively avoid the same anonymous page from being repeatedly written into the swap area, and improve the utilization rate of the swap area. Meanwhile, for the processor, the writing times are reduced, the running speed of the processor can be improved, for the external memory, the space is reasonably utilized, the written times are reduced, and the service life of the external memory can be prolonged.
In addition, before the anonymous page is written into the swap area, the anonymous page can be compressed through a zram function, and then the compressed anonymous page is transferred to the swap area. And further reducing the space occupied by the anonymous page in the swap area. The service life of the external memory is prolonged.
It should be noted that, in the present application, a processing method of an anonymous page in a memory is mainly considered, and other page data corresponding to an application, for example, data such as a file page, may be processed by using a conventional technical solution, which is not described in detail in the present application.
In the above embodiments, a mobile phone is used as an electronic device. In some embodiments of the present application, the electronic device may also be a desktop computer, a tablet computer, a notebook computer, a super mobile personal computer, a Personal Digital Assistant (PDA), or a wearable electronic device such as a watch, a bracelet, or the like.
The following describes a method for processing an anonymous memory page according to an embodiment of the present application, with reference to a specific structure of an electronic device.
Referring to fig. 4 and fig. 4, which show a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a Universal Serial Bus (USB) connector 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, a Subscriber Identity Module (SIM) card interface 195, and the like. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
It is to be understood that the illustrated structure of the embodiment of the present invention does not specifically limit the electronic device 100. In other embodiments of the present application, electronic device 100 may include more or fewer components than shown, or some components may be combined, some components may be split, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Processor 110 may include one or more processing units, such as: the processor 110 may include 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), etc. The different processing units may be separate devices or may be integrated into one or more processors.
The processor 110 may generate operation control signals according to the instruction operation code and the timing signals, so as to complete the control of instruction fetching and instruction execution.
A memory may also be provided in processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Avoiding repeated accesses reduces the latency of the processor 110, thereby increasing the efficiency of the system.
In some embodiments, the processor 110 determines an anonymous page corresponding to the application after receiving the operation of exiting the application, and transfers the anonymous page from the memory of the processor 110 to a preset area of an external memory connected to the processor 110, for example, to an awap area in a ROM. In other embodiments, the processor 110 performs a search based on the anonymous page before the anonymous page is transferred to the preset area of the external memory, and the processor 110 performs a write operation of the anonymous page according to a result of the search. That is, the processor may search for whether an anonymous page is already stored in the preset area before writing the anonymous page, for example, the processor 110 generates a unique identifier for each anonymous page when writing the anonymous page for the first time, and stores the unique identifier in the corresponding search table. The retrieval table is used for recording the identification of the anonymous page in the hilt preset area, for example, the retrieval table may be a hash table, and the identification may be a hash value. Thereafter, the processor 110 queries whether the current anonymous page has been transferred through the lookup table, and when the anonymous page is confirmed to be transferred, the processor 110 will not repeatedly write the anonymous page into the corresponding preset area of the external memory. Thereby avoiding the same data from being repeatedly written in the external memory. The method reduces the writing times, reduces redundant workload and improves the working efficiency of the processor. For the external storage, a large amount of repeated data cannot be stored, the space utilization rate is improved, and meanwhile, the service life of the external storage is prolonged.
The I2C interface is a bi-directional synchronous serial bus that includes a serial data line (SDA) and a Serial Clock Line (SCL). In some embodiments, processor 110 may include multiple sets of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, the internal memory 121, the external memory 120, etc., through different I2C bus interfaces, respectively. For example: the processor 110 may be coupled to the touch sensor 180K via an I2C interface, such that the processor 110 and the touch sensor 180K communicate via an I2C bus interface to implement the touch functionality of the electronic device 100.
MIPI interfaces may be used to connect processor 110 with peripheral devices such as display screen 194, camera 193, and the like. The MIPI interface includes a Camera Serial Interface (CSI), a Display Serial Interface (DSI), and the like. In some embodiments, processor 110 and camera 193 communicate through a CSI interface to implement the capture functionality of electronic device 100. The processor 110 and the display screen 194 communicate through the DSI interface to implement a display function of the electronic device 100, for example, implement switching of an application interface.
It should be understood that the connection relationship between the modules according to the embodiment of the present invention is only illustrative, and is not limited to the structure of the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection manners or a combination of multiple interface connection manners in the above embodiments.
The electronic device 100 implements display functions via the GPU, the display screen 194, and the application processor. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and an application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
The display screen 194 is used to display images, video, and the like. The display screen 194 includes a display panel. The display panel may adopt a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (active-matrix organic light-emitting diode, AMOLED), a flexible light-emitting diode (FLED), a miniature, a Micro-oeld, a quantum dot light-emitting diode (QLED), and the like. In some embodiments, the electronic device 100 may include 1 or N display screens 194, with N being a positive integer greater than 1.
In some embodiments, the display screen may display an interface corresponding to an application, when the application is switched to the background, the display screen may display a second interface of another application, and when the processor 110 determines that it is necessary to switch back to the first interface of the application, the processor 110 may control the display screen to quickly display the first interface corresponding to the application through the MIPI interface.
The external memory 120 may be an external memory card, such as a Micro SD card, connected to the processor 110, and is implemented to extend the storage capability of the electronic device 100. External storage refers to storage other than memory of the electronic device and cache of the processor, which is typically non-volatile storage. The external memory 120 communicates with the processor 110 to implement data storage functions. For example, when the application runs in the background, page data corresponding to the application may be stored through the external memory 120, for example, page data such as anonymous pages may be stored.
Internal memory 121, which may also be referred to as "memory," may be used to store computer-executable program code, including instructions. The internal memory 121 may include a program storage area and a data storage area. The storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required by at least one function, and the like. The storage data area may store page data (e.g., audio data, phone book, etc.) created during use of the electronic device 100, and the like. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (UFS), and the like. The processor 110 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
In an embodiment of the application, when the application is temporarily stored in the background, the internal memory may store page data corresponding to the application, and the processor 110 may also map a file page of the page data into the external memory 120, and forward an anonymous page in the page data to a preset area, for example, a swap area, of the external memory.
The pressure sensor 180A is used for sensing a pressure signal, and converting the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be disposed on the display screen 194. The pressure sensor 180A can be of a wide variety, such as a resistive pressure sensor, an inductive pressure sensor, a capacitive pressure sensor, and the like. The capacitive pressure sensor may be a sensor comprising at least two parallel plates having an electrically conductive material. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the strength of the pressure from the change in capacitance. When a touch operation is applied to the display screen 194, the electronic apparatus 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic apparatus 100 may also calculate the touched position from the detection signal of the pressure sensor 180A. In some embodiments, the touch operations that are applied to the same touch position but different touch operation intensities may correspond to different operation instructions. For example: and when the touch operation with the touch operation intensity smaller than the first pressure threshold value acts on the short message application icon, executing an instruction for viewing the short message. And when the touch operation with the touch operation intensity larger than or equal to the first pressure threshold value acts on the short message application icon, executing an instruction of newly building the short message.
In some embodiments of the present application, when the user opens the application by pressing the display screen 194 of the electronic device, the pressure sensor 180A receives a pressing operation of the user, sends an event corresponding to the pressing operation to the processor 110, and the processor 110 identifies the pressing operation to determine the application to be opened and performs an operation of opening the application, so that an interface corresponding to the application is displayed on the display screen 194.
The touch sensor 180K is also called a "touch device". The touch sensor 180K may be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, which is also called a "touch screen". The touch sensor 180K is used to detect a touch operation applied thereto or nearby. The touch sensor can communicate the detected touch operation to the application processor to determine the touch event type. Visual output associated with the touch operation may be provided through the display screen 194. In other embodiments, the touch sensor 180K may be disposed on a surface of the electronic device 100, different from the position of the display screen 194.
In some embodiments, when the user switches the application to the background operation through the sliding operation of the display screen, the touch sensor receives the operation of the user, sends the touch event to the processor 110 through the I2C interface, and the processor 110 recognizes the switching operation of the user and executes a corresponding switching command, thereby implementing the switching between the foreground and the background.
The relationship between the processor 110, the internal memory 121 (internal memory), and the external memory 120 is described below with reference to fig. 4.
Referring to fig. 5, fig. 5 shows a schematic structural diagram of an electronic device according to another embodiment of the present application. The processor 110 may include one or more CPU cores 111, cache memories 112 respectively corresponding to the CPU cores 111, and a memory management module (memory controller)113, an anonymous page management module 114, and an external space management module 115 running in the processor 110. The internal memory 121 is a physical memory.
The processor 110 is an integrated circuit, and the components are connected by a bus, and an operating system and software programs can be run in the processor 110, so that the processor 110 can access a cache, a memory, an external storage, and perform data processing.
The memory management module 113 is configured to control the internal memory 121 and implement data exchange between the internal memory 121 and the CPU core 111. The memory management module 113 receives a read/write request sent by the CPU core, translates a virtual address carried in the request into a physical address based on the page table, and sends the physical address to the internal memory 121, where the internal memory 121 performs corresponding read/write operations according to the physical address. While the memory management module 113 issues read/write requests to the anonymous page manager 114.
If the anonymous page manager 114 receives the write request, the anonymous page manager 114 finds a corresponding anonymous page from the internal memory 121, determines whether the anonymous page has been written in a predetermined area of the external memory, generates a processing command according to the determination result, and sends the processing command to the external space management module 115. When the anonymous page manager 114 determines that the anonymous page has been written into the preset area, the processing result may be a command that does not need to be written. And when the anonymous page is judged not to be written into the preset area, processing the command that the anonymous page needs to be written into the preset area.
The external space management module 115 receives the processing command and executes the command. In addition, in some embodiments, if the processing command is to write the anonymous page into the external memory, the external space management module 115 may further compress the anonymous page and write the compressed anonymous page into the external memory 115.
If the anonymous page manager 114 receives the read request, the anonymous page manager 114 notifies the external space manager 115 to read the corresponding anonymous page, and the external space manager 115 reads the corresponding anonymous page from the preset area of the external memory 120 into the internal memory 121.
In some embodiments, after receiving the read request, the anonymous page management module 114 issues a marking command to the external space management module 115, and the external space management module 115 reads the corresponding anonymous page from the preset area of the external memory 120 into the internal memory 121 and marks that the anonymous page has been read. Meanwhile, the external space management module 115 detects the remaining space of the external memory and sends the remaining space to the anonymous page management module 114, the anonymous page management module 114 judges whether the remaining space reaches a preset value, and sends a command whether to delete the read anonymous page to the external space management module 115 according to the judgment result, and the external space management module 115 executes the command to realize the management of the external memory.
In some embodiments, if the anonymous page is compressed and then written into the preset region, the external space management module 115 needs to read the compressed anonymous page into a specified region of the internal memory, such as a zram region, decompress the compressed anonymous page, and read the decompressed anonymous page into a memory outside the zram region.
It should be understood that the anonymous page management module 114 and the external space management module 115 may be integrated into one module, or may be disposed in the memory management module 113, and the memory management module 113 may also be a separate chip, and is connected to the CPU core through a system bus.
The software system of the electronic device 100 shown in fig. 4 and fig. 5 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, a cloud architecture, or the like. The embodiment of the invention takes an Android system with a layered architecture as an example, and exemplarily illustrates a software system architecture of the electronic device 100.
As shown in fig. 6, the layered architecture divides the software into several layers, each layer having a clear role and division of labor. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into four layers, an application layer, an application framework layer, an Android runtime (Android runtime) and system library, and a kernel layer from top to bottom.
The application layer may include a series of application packages. As shown in fig. 6, the application packages may include camera, gallery, calendar, call, map, navigation, WLAN, bluetooth, music, video, short message, and other applications, and may include other application packages not shown. The user may select to open the corresponding application through the application icon displayed on the display screen 194.
The application framework layer provides an Application Programming Interface (API) and a programming framework for the application program of the application layer. The application framework layer includes a number of predefined functions. As shown in FIG. 4, the application framework layers may include a window manager, content provider, view system, phone manager, resource manager, notification manager, and the like.
A window manager may be used to manage the window program. The window manager can obtain the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like.
The content provider may be used to store and retrieve data and make the data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
The view system may include visual controls such as controls to display text, controls to display pictures, and the like. The view system may be used to build applications.
The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and the like.
The notification manager enables the application to display notification information in the status bar, can be used to convey notification-type messages, can disappear automatically after a short dwell, and does not require user interaction. Such as a notification manager used to inform download completion, message alerts, etc. The notification manager may also be a notification that appears in the form of a chart or scroll bar text at the top status bar of the system, such as a notification of a background running application, or a notification that appears on the screen in the form of a dialog window. For example, prompting text information in the status bar, sounding a prompt tone, vibrating the electronic device, flashing an indicator light, etc.
The android runtime includes a core library and a virtual machine. The android runtime is responsible for scheduling and managing the android system. The core library comprises two parts: one part is a function which needs to be called by java language, and the other part is a core library of android.
The application layer and the application framework layer run in a virtual machine. And executing java files of the application program layer and the application program framework layer into a binary file by the virtual machine. The virtual machine is used for performing the functions of object life cycle management, stack management, thread management, safety and exception management, garbage collection and the like.
The kernel layer is a layer between hardware and software. The kernel layer may include a memory management module, an anonymous page management module, and an external space management module. The memory management module receives the read/write request and sends the read/write request to the anonymous page management module, the anonymous page management module receives the read/write request, determines whether the anonymous page needs to be written into a processing command of an external memory or whether the anonymous page needs to be deleted according to internal judgment logic, and the external space management module executes the command. In the following examples, the process will be described in detail, and reference may be made to specific example processes of the methods described below, which are not described in detail herein.
The memory management module, the anonymous page management module, and the external space management module in the present application are not limited to being provided in the kernel layer, and may be provided in the system runtime layer, and the like.
The following describes in detail a processing method of memory anonymous pages according to an embodiment of the present application with reference to specific drawings.
In the following embodiments, the method is applied to a mobile phone (as an example of an electronic device) as an example, and the specific structure of the mobile phone may refer to the hardware structure and the software structure of fig. 4, fig. 5, and fig. 6. In the present application, a method for processing an anonymous memory page is described mainly from two scenarios, namely a write-in process and a read process of the anonymous memory page.
Scene 1: anonymous page write procedure
Referring to fig. 7, fig. 7 is an interaction flowchart illustrating a processing method for executing an anonymous memory page by each module in a mobile phone according to an embodiment of the present application. As shown in fig. 7, the handset includes a processor and an external memory connected to the processor. The processor can comprise a memory management module, an anonymous page management module and an external space management module. And the external memory is provided with a swap area for transferring anonymous pages in the memory. The flowchart includes S710-S760.
S710, the memory management module receives the operation of quitting the application.
In the application, quitting the application means that the application runs in the background and is not closed, and the application is switched to the current interface at any time when needed. After the memory management module receives the operation of exiting the application, the write-in process of the anonymous page is triggered, and S720 is executed.
S720, the memory management module informs the anonymous page management module to write the anonymous page. The anonymous page is written into a swap area in an external memory. After receiving the notification, the anonymous page management module determines an anonymous page corresponding to the application from the memory, and executes S730.
S730, the anonymous page management module judges whether anonymous pages need to be written in.
In one embodiment of the present application, the anonymous page management module may determine whether the anonymous page has been written to by retrieving a swap area in external memory.
If the anonymous page is written, the task is ended, and the anonymous page management module does not inform the external space management module to write the anonymous page any more.
If the anonymous page is not written, the anonymous page management module executes step S730 to notify the external space management module to write the corresponding anonymous page into the swap area of the external memory.
In an embodiment of the application, when the anonymous page management module determines that the anonymous page is not written into the swap area, a unique identifier can be generated for the anonymous page and is recorded. When the memory management module sends out the write-in notice of the anonymous page again, the anonymous page management module can determine that the swap area stores the anonymous page through the recorded identification, and then the subsequent repeated write-in is avoided.
Referring to fig. 8, fig. 8 is a diagram illustrating a correspondence relationship between an anonymous page and a hash value according to an embodiment of the present application. As shown in fig. 8, the table includes different anonymous pages, e.g., anonymous page a and anonymous page b. These anonymous pages correspond to uniquely identified hash values. When the memory management module judges that the anonymous page a is not written into the swap area, the anonymous page management module generates a unique hash value 1 for the anonymous page a according to a hash algorithm, stores the unique hash value in a corresponding search table, and informs the external space storage module to write the anonymous page into the swap area. When the anonymous page management module receives the notification written into the anonymous page a again, the hash value 1 can be retrieved according to the hash table, so that the anonymous page corresponding to the hash value 1 is judged to be written into the swap area, repeated writing is not needed, the swap writing frequency is reduced, and the swap writing rate and the utilization rate of the storage space are improved. Meanwhile, the damage to the external memory caused by frequently writing data into the equipment is avoided, and the service life of the external memory is prolonged.
The search table in the present application may be in the form of a hash table (hash Map) or a Tree table (Tree Map). The structure of the search table is described by taking a hash table as an example, the hash table may include a key-value (key) where the key (key) is a value (hash value 1 or hash value 2) generated by anonymous page calculation, or a value generated by anonymous page calculation, and the calculation mode after compression is CRC, MD5, SHA1, and the like. The Value (Value) includes the address of the anonymous page in a preset area (e.g., swap area). In some embodiments, the Value (Value) also includes a reference count for the anonymous page, e.g., every time the anonymous page is written or needs to be written (a pre-set region already exists and does not need to be actually written), the reference count is incremented by 1. The reference count is decremented by 1 every read. Since the writing and reading are usually corresponding, by the number of writing and the number of reading, when the read anonymous page is deleted subsequently, the reference count is preferentially deleted to be 0, and the anonymous page with high read probability is prevented from being deleted as much as possible. In addition, when the anonymous page is deleted, the corresponding hash value in the search table is also deleted correspondingly.
After the external space management module receives the notification, it can be known that S760 is directly executed, and the corresponding anonymous page is written into the swap area. Or S750 may be executed first, the anonymous page is compressed through a compression algorithm, and the compressed anonymous page is written into the swap area, so that the utilization rate of the external storage space is further improved.
Scene 2: anonymous page read flow
Referring to fig. 9, fig. 9 is an interactive flowchart illustrating a processing method for executing an anonymous memory page by each module in a mobile phone according to another embodiment of the present application. As shown in fig. 9, the handset includes a processor and an external memory connected to the processor. The processor can comprise a memory management module, an anonymous page management module and an external space management module. And the external memory is provided with a swap area for transferring anonymous pages in the memory. The flowchart includes S910-S980.
S910, the memory management module receives the operation of switching back the application.
Switching back to the application means that the application runs in the background and switches back to the foreground again, namely the current interface. When the memory management module receives the operation of switching back to the application, the memory management module triggers a read process of the anonymous page, and executes S720.
S920, the memory management module notifies the anonymous page management module to read the anonymous page. Reading the anonymous page refers to reading the anonymous page from a swap area in an external memory to a memory so as to realize the quick switching of the application to the foreground. After receiving the notification, the anonymous page management module proceeds to S930.
S930, the anonymous page management module notifies the external space management module to read the anonymous page and marks it as read.
S940, the external space management module reads the anonymous page from the swap area of the external memory to the memory of the processor and marks the anonymous page as read. Meanwhile, the external space management module detects the residual space of the swap area.
In some embodiments, when the anonymous page stored in the swap area is an anonymous page compressed by the zram, after the external space management module reads the compressed anonymous page, the external space management module first reads the compressed anonymous page into the zram area in the memory, decompresses the compressed anonymous page, and reads the anonymous page into the memory outside the zram area.
S950, the external space management module sends the size of the residual space to the anonymous page management module.
S960, the anonymous page management module judges whether the residual space reaches a preset value.
If the remaining space is determined to have reached the predetermined value, for example, 100 MB. S970 is performed. If the preset value is not reached, the command does not need to be executed.
S970, the anonymous page management module notifies the external space management module to delete the marked anonymous page.
In an embodiment of the present application, the anonymous page deletion may preferentially delete the anonymous page with reference count of 0 in a manner of reference count in the hash table in S730. In some embodiments, deleting the anonymous page may prioritize the read anonymous page according to a preset rule, and prioritize the priority for deletion. For example, according to the read time arrangement, the read anonymous pages far away from the current time are set to be low in priority, and the anonymous pages with low priority are preferentially deleted until the remaining space is larger than the preset value. The priority setting may be performed according to the number of times the anonymous page is read, and is not limited herein.
S980, the external space management module executes a delete command to delete the anonymous pages marked to be read from the swap area.
According to the reading process of the embodiment of the application, the processor does not immediately delete the read anonymous page, but deletes the anonymous page after the preset value is reached, so that the probability of anonymous page retrieval hit in a writing scene can be increased, and repeated writing is avoided as far as possible. So as to reduce the writing times and promote the swap writing speed. Further avoid frequently writing into the damage external memory, improve the life of external memory.
In the above embodiments, the memory management module, the anonymous page management module, and the external space management module are taken as examples for explanation, and in some embodiments of the present application, other modules may be used, and the number of the modules may be more than the number of the modules or less than the number of the modules, which is not limited herein.
The present application further provides an electronic device, comprising: at least one processor and a memory, the memory including physical memory and external memory, for storing instructions for execution by the one or more processors of the device;
a processor to execute instructions and perform:
receiving a first operation of exiting the application;
responding to the first operation, and determining an anonymous page corresponding to the application from a physical memory;
searching based on an anonymous page in a preset area of an external memory, wherein the preset area can be a swap area or a swap file;
and according to the retrieval result, executing the write operation of the anonymous page.
In one embodiment of the application, the processor is configured to retrieve from the hash table based on a hash value corresponding to the anonymous page, and obtain a result of the retrieval.
In one embodiment of the application, the result of the retrieval is that the preset area has been written to an anonymous page,
performing a write operation of an anonymous page, comprising:
the processor no longer performs the writing of the anonymous page to the preset area.
In one embodiment of the present application, the result of the retrieval is that the predetermined area is not written with anonymous pages,
performing a write operation of an anonymous page, comprising:
the processor is used for writing the anonymous page into the preset area, releasing the physical memory and recording that the anonymous page is written into the preset area.
In one embodiment of the application, the processor is configured to generate a hash value corresponding to the anonymous page, and store the hash value in a hash table to record that the anonymous page has been written in the preset area.
In an embodiment of the application, the processor is configured to compress the anonymous page, and write the compressed anonymous page into a preset area.
In one embodiment of the present application, the processor is further configured to perform:
a second operation to switch the application to the current interface is received,
in response to a second operation, reading the anonymous page from the preset area and marking the read page;
and when the residual space of the preset area is less than or equal to the preset value, deleting the anonymous page marked to be read from the preset area.
In one embodiment of the present application, when the remaining space of the preset area is greater than the preset value, the processor is configured to reserve the read anonymous page in the preset area.
In an embodiment of the application, the processor is configured to read the compressed anonymous page from the preset region to the zram region for decompression, and then read the decompressed anonymous page.
The components and the workflow of the electronic device in the embodiment of the present application are described in detail in the above embodiment, and reference may be specifically made to the processing method described in fig. 7 and fig. 9 in the above embodiment, which is not described herein again.
The present application further provides an electronic device, comprising:
a memory for storing instructions for execution by one or more processors of the device, an
A processor for executing the processing method explained in the above embodiments with reference to fig. 7 and 9.
The present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program causes the processor to execute the processing method explained in fig. 7 and 9 in the above embodiments.
The present application also provides a computer program product containing instructions that, when run on an electronic device, cause a processor to perform the processing method explained in fig. 7 and 9 in the above embodiments.
Referring now to fig. 10, shown is a block diagram of a SoC (System on Chip) 1300 in accordance with an embodiment of the present application. In fig. 10, like parts have the same reference numerals. In addition, the dashed box is an optional feature of more advanced socs. In fig. 10, SoC1300 includes: an interconnect unit 1350 coupled to the application processor 1310; a system agent unit 1380; a bus controller unit 1390; an integrated memory controller unit 1340; a set or one or more coprocessors 1320 which may include integrated graphics logic, an image processor, an audio processor, and a video processor; a Static Random Access Memory (SRAM) unit 1330; a Direct Memory Access (DMA) unit 1360. In one embodiment, the coprocessor 1320 includes a special-purpose processor, such as, for example, a network or communication processor, compression engine, GPGPU, a high-throughput MIC processor, embedded processor, or the like.
Included in Static Random Access Memory (SRAM) unit 1330 may be one or more computer-readable media for storing data and/or instructions. A computer-readable storage medium may have stored therein instructions, in particular, temporary and permanent copies of the instructions. The instructions may include: when executed by at least one unit in the processor, the Soc1300 is enabled to execute the shooting method according to the foregoing embodiment, which may specifically refer to the processing method explained in fig. 7 and fig. 9 in the foregoing embodiment, and will not be described herein again.
Embodiments of the mechanisms disclosed herein may be implemented in hardware, software, firmware, or a combination of these implementations. Embodiments of the application may be implemented as computer programs or program code executing on programmable systems comprising 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.
Program code may be applied to input instructions to perform the functions described herein and generate output information. The output information may be applied to one or more output devices in a known manner. For purposes of this Application, a 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.
The program code may be implemented in a high level procedural or object oriented programming language to communicate with a processing system. The program code can also be implemented in assembly or machine language, if desired. Indeed, the mechanisms described in this application are not limited in scope to any particular programming language. In any case, the language may be a compiled or interpreted language.
In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried by or stored on one or more transitory or non-transitory machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or via other computer readable media. Thus, a machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), including, but not limited to, floppy diskettes, optical disks, Compact disk Read Only memories (CD-ROMs), magneto-optical disks, Read Only Memories (ROMs), Random Access Memories (RAMs), Erasable Programmable Read Only Memories (EPROMs), Electrically Erasable Programmable Read Only Memories (EEPROMs), magnetic or optical cards, flash Memory, or a tangible machine-readable Memory for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in electrical, optical, acoustical or other forms of propagated signals. Thus, a machine-readable medium includes any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a form readable by a machine (e.g., a computer).
In the drawings, some features of the structures or methods may be shown in a particular arrangement and/or order. However, it is to be understood that such specific arrangement and/or ordering may not be required. Rather, in some embodiments, the features may be arranged in a manner and/or order different from that shown in the figures. In addition, the inclusion of a structural or methodical feature in a particular figure is not meant to imply that such feature is required in all embodiments, and in some embodiments, may not be included or may be combined with other features.
It should be noted that, in the embodiments of the apparatuses in the present application, each unit/module is a logical unit/module, and physically, one logical unit/module may be one physical unit/module, or may be a part of one physical unit/module, and may also be implemented by a combination of multiple physical units/modules, where the physical implementation manner of the logical unit/module itself is not the most important, and the combination of the functions implemented by the logical unit/module is the key to solve the technical problem provided by the present application. Furthermore, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units/modules which are not so closely related to solve the technical problems presented in the present application, which does not indicate that no other units/modules exist in the above-mentioned device embodiments.
It is noted that, in the examples and descriptions of this patent, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the use of the verb "comprise a" to define an element does not exclude the presence of another, same element in a process, method, article, or apparatus that comprises the element.
While the present application has been shown and described with reference to certain preferred embodiments thereof, it will be understood by those of ordinary skill in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present application.

Claims (22)

1. A processing method of memory anonymous pages is applied to electronic equipment and is characterized by comprising the following steps:
the electronic equipment receives a first operation of quitting an application;
in response to the first operation, the electronic device determining an anonymous page corresponding to an application;
in a preset area of an external memory of the electronic equipment, the electronic equipment carries out retrieval based on the anonymous page;
and the electronic equipment executes the write operation of the anonymous page according to the retrieval result.
2. The method of claim 1, wherein the electronic device retrieving based on the anonymous page comprises:
and the electronic equipment searches from a hash table based on the hash value corresponding to the anonymous page and obtains the search result, wherein the hash table is stored in a physical memory of the electronic equipment and used for recording the hash value corresponding to the anonymous page written into a preset area.
3. The method of claim 2, wherein the electronic device performs a write operation of the anonymous page based on a result of the retrieving, comprising,
and the electronic equipment determines that the retrieval result is that the hash value corresponding to the anonymous page exists in the hash table, which indicates that the anonymous page exists in the preset area, and the electronic equipment does not execute writing of the anonymous page into the preset area.
4. The method of claim 2, wherein the electronic device performs a write operation of the anonymous page according to the retrieved result, comprising:
the electronic equipment determines that the retrieval result is that the hash value corresponding to the anonymous page does not exist in the hash table, which indicates that the anonymous page is not written in the preset area;
and the electronic equipment writes the anonymous page into the preset area, releases the physical memory and records that the anonymous page is written into the preset area.
5. The method of claim 4, wherein recording that the anonymous page has been written to the preset area comprises:
and the electronic equipment generates a hash value corresponding to the anonymous page and stores the hash value in a hash table.
6. The method of claim 4 or 5, wherein the electronic device writes the anonymous page to the preset area, comprising:
and the electronic equipment compresses the anonymous page and writes the compressed anonymous page into the preset area.
7. The method of any one of claims 1-5, further comprising:
the electronic device receives a second operation of switching the application to the current interface,
in response to the second operation, the electronic equipment reads the anonymous page from the preset area and marks the read page;
and when the residual space of the preset area is less than or equal to a preset value, the electronic equipment deletes the anonymous page marked as read from the preset area.
8. The method of claim 7, wherein when the remaining space of the preset area is greater than a preset value, the electronic device retains the read anonymous page in the preset area.
9. The method of claim 7, wherein the electronic device reads the anonymous page from the preset region, comprising:
and the electronic equipment reads the compressed anonymous page from the preset region to a zram region for decompression, and then reads the decompressed anonymous page.
10. The method according to any one of claims 1 to 5, wherein the preset area is a swap area or a swap file.
11. An electronic device, comprising: at least one processor and a memory, the memory including physical memory and external memory, for storing instructions for execution by the one or more processors of the device;
a processor to execute instructions and perform:
receiving a first operation of exiting the application;
responding to the first operation, and determining an anonymous page corresponding to the application from the physical memory;
in a preset area of the external memory, retrieving based on the anonymous page;
and executing the write operation of the anonymous page according to the retrieval result.
12. The electronic device according to claim 11, wherein the processor retrieves from a hash table based on the hash value corresponding to the anonymous page, and obtains the retrieval result, and the hash table stores the hash value corresponding to the anonymous page written in a preset area in a physical memory of the electronic device.
13. The electronic device of claim 12, wherein the processor determines that a hash value corresponding to an anonymous page exists in the hash table as a result of the retrieving, indicating that the anonymous page already exists in the preset region, and the processor does not perform writing the anonymous page into the preset region.
14. The electronic device according to claim 12, wherein the processor determines that the hash value corresponding to the anonymous page does not exist in the hash table as a result of the retrieval, indicating that the anonymous page is not written in the preset area;
and the processor writes the anonymous page into the preset area, releases the physical memory, and records that the anonymous page is written into the preset area.
15. The electronic device of claim 14, wherein the processor is configured to generate a hash value corresponding to the anonymous page, and to save the hash value in a hash table to record that the anonymous page has been written into the preset area.
16. The electronic device of claim 14 or 15, wherein the processor is configured to compress the anonymous page, and write the compressed anonymous page into the preset area.
17. The electronic device of any of claims 11-15, wherein the processor is further configured to perform:
receiving a second operation of switching the application to the current interface,
reading the anonymous page from the preset area in response to the second operation, and marking the read page;
and when the residual space of the preset area is less than or equal to a preset value, deleting the anonymous page marked to be read from the preset area.
18. The electronic device of claim 17, wherein the processor is configured to reserve the read anonymous page in the preset area when the remaining space of the preset area is greater than a preset value.
19. The electronic device of claim 17, wherein the processor is configured to read the compressed anonymous page from the preset region to a zram region for decompression, and then read the decompressed anonymous page.
20. The electronic device according to any one of claims 11-15, wherein the preset area is a swap area or a swap file.
21. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by an electronic device, causes the electronic device to perform the method of any one of claims 1-10.
22. A computer program product comprising instructions for causing an electronic device to perform the method of any of claims 1-10 when the computer program product is run on the electronic device.
CN202210143582.3A 2022-02-16 2022-02-16 Memory anonymous page processing method, electronic device and readable storage medium Active CN114185494B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210143582.3A CN114185494B (en) 2022-02-16 2022-02-16 Memory anonymous page processing method, electronic device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210143582.3A CN114185494B (en) 2022-02-16 2022-02-16 Memory anonymous page processing method, electronic device and readable storage medium

Publications (2)

Publication Number Publication Date
CN114185494A true CN114185494A (en) 2022-03-15
CN114185494B CN114185494B (en) 2022-07-19

Family

ID=80607089

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210143582.3A Active CN114185494B (en) 2022-02-16 2022-02-16 Memory anonymous page processing method, electronic device and readable storage medium

Country Status (1)

Country Link
CN (1) CN114185494B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114741205A (en) * 2022-06-02 2022-07-12 荣耀终端有限公司 Anonymous page recovery method and electronic device
CN115858046A (en) * 2023-02-28 2023-03-28 荣耀终端有限公司 Memory page preloading method, electronic equipment and chip system
CN115981573A (en) * 2023-02-16 2023-04-18 荣耀终端有限公司 Data management method, electronic device and computer readable and writable storage medium
CN117130541A (en) * 2023-03-02 2023-11-28 荣耀终端有限公司 Storage space configuration method and related equipment
CN117130541B (en) * 2023-03-02 2024-06-04 荣耀终端有限公司 Storage space configuration method and related equipment

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103729305A (en) * 2012-10-11 2014-04-16 财团法人工业技术研究院 Method and computer system for memory management on virtual machine system
CN104050055A (en) * 2013-03-15 2014-09-17 索尼公司 Electronic Apparatus, Method Of Creating Snapshot Image, And Program
CN104794182A (en) * 2015-04-10 2015-07-22 中国科学院计算技术研究所 Small file asynchronous pre-reading device and method for parallel network file system
US20180032260A1 (en) * 2016-07-29 2018-02-01 Samsung Electronics Co., Ltd. System and method for integrating overprovisioned memory devices
CN107704321A (en) * 2017-09-30 2018-02-16 北京元心科技有限公司 Memory allocation method and device and terminal equipment
CN111984413A (en) * 2020-08-20 2020-11-24 Oppo(重庆)智能科技有限公司 Memory recovery method and device, electronic equipment and storage medium
US10901627B1 (en) * 2017-02-28 2021-01-26 Amazon Technologies, Inc. Tracking persistent memory usage
CN113722087A (en) * 2021-06-10 2021-11-30 荣耀终端有限公司 Virtual memory management method and electronic equipment
US20220035655A1 (en) * 2019-04-15 2022-02-03 Oneplus Technology (Shenzhen) Co., Ltd. Method and Device for Anonymous Page Management, Terminal Device, and Readable Storage Medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103729305A (en) * 2012-10-11 2014-04-16 财团法人工业技术研究院 Method and computer system for memory management on virtual machine system
CN104050055A (en) * 2013-03-15 2014-09-17 索尼公司 Electronic Apparatus, Method Of Creating Snapshot Image, And Program
CN104794182A (en) * 2015-04-10 2015-07-22 中国科学院计算技术研究所 Small file asynchronous pre-reading device and method for parallel network file system
US20180032260A1 (en) * 2016-07-29 2018-02-01 Samsung Electronics Co., Ltd. System and method for integrating overprovisioned memory devices
US10901627B1 (en) * 2017-02-28 2021-01-26 Amazon Technologies, Inc. Tracking persistent memory usage
CN107704321A (en) * 2017-09-30 2018-02-16 北京元心科技有限公司 Memory allocation method and device and terminal equipment
US20220035655A1 (en) * 2019-04-15 2022-02-03 Oneplus Technology (Shenzhen) Co., Ltd. Method and Device for Anonymous Page Management, Terminal Device, and Readable Storage Medium
CN111984413A (en) * 2020-08-20 2020-11-24 Oppo(重庆)智能科技有限公司 Memory recovery method and device, electronic equipment and storage medium
CN113722087A (en) * 2021-06-10 2021-11-30 荣耀终端有限公司 Virtual memory management method and electronic equipment

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114741205A (en) * 2022-06-02 2022-07-12 荣耀终端有限公司 Anonymous page recovery method and electronic device
CN114741205B (en) * 2022-06-02 2022-11-11 荣耀终端有限公司 Anonymous page recovery method and electronic device
CN115981573A (en) * 2023-02-16 2023-04-18 荣耀终端有限公司 Data management method, electronic device and computer readable and writable storage medium
CN115858046A (en) * 2023-02-28 2023-03-28 荣耀终端有限公司 Memory page preloading method, electronic equipment and chip system
CN117130541A (en) * 2023-03-02 2023-11-28 荣耀终端有限公司 Storage space configuration method and related equipment
CN117130541B (en) * 2023-03-02 2024-06-04 荣耀终端有限公司 Storage space configuration method and related equipment

Also Published As

Publication number Publication date
CN114185494B (en) 2022-07-19

Similar Documents

Publication Publication Date Title
CN114185494B (en) Memory anonymous page processing method, electronic device and readable storage medium
US11531625B2 (en) Memory management method and apparatus
CN111274039B (en) Memory recycling method and device, storage medium and electronic equipment
CN109992523B (en) Memory processing method and device, electronic equipment and computer readable storage medium
WO2019137252A1 (en) Memory processing method, electronic device, and computer-readable storage medium
CN114840450B (en) Storage space arrangement method and electronic equipment
WO2021185352A1 (en) Version upgrade method and related apparatus
WO2019128542A1 (en) Application processing method, electronic device, computer readable storage medium
WO2021218370A1 (en) Memory management method and terminal device
CN115858046B (en) Method for preloading memory pages, electronic equipment and chip system
CN114706633B (en) Preloading method, electronic device and storage medium
CN115033193B (en) Screen turning processing method and device, medium and electronic equipment
CN112783418B (en) Method for storing application program data and mobile terminal
CN110032421B (en) Method and device for managing atlas in memory, terminal and storage medium
CN116049021B (en) Storage space management method, electronic device, and computer-readable storage medium
WO2023070462A1 (en) File deduplication method and apparatus, and device
WO2023185684A1 (en) Process killing method for application, and electronic device
CN116661645B (en) Method for displaying application card, electronic device and readable storage medium
CN116049113B (en) File system arrangement method, electronic device and computer readable storage medium
CN118120212A (en) File deduplication method, device and equipment
WO2023237047A1 (en) Data processing method and electronic device
CN114461405B (en) Storage method and related device for locking page in memory
CN116166573B (en) Method for controlling memory reclamation, electronic device and storage medium
CN114741205B (en) Anonymous page recovery method and electronic device
CN115981573A (en) Data management method, electronic device and computer readable and writable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230906

Address after: 201306 building C, No. 888, Huanhu West 2nd Road, Lingang New Area, Pudong New Area, Shanghai

Patentee after: Shanghai Glory Smart Technology Development Co.,Ltd.

Address before: Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040

Patentee before: Honor Device Co.,Ltd.