CN118295809A - Memory management method, memory management device, electronic equipment and readable storage medium - Google Patents
Memory management method, memory management device, electronic equipment and readable storage medium Download PDFInfo
- Publication number
- CN118295809A CN118295809A CN202410443268.6A CN202410443268A CN118295809A CN 118295809 A CN118295809 A CN 118295809A CN 202410443268 A CN202410443268 A CN 202410443268A CN 118295809 A CN118295809 A CN 118295809A
- Authority
- CN
- China
- Prior art keywords
- application
- memory
- memory space
- state
- physical memory
- 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.)
- Pending
Links
- 238000007726 management method Methods 0.000 title claims abstract description 100
- 238000000034 method Methods 0.000 claims abstract description 233
- 238000004891 communication Methods 0.000 claims abstract description 11
- 238000013507 mapping Methods 0.000 claims description 88
- 238000012545 processing Methods 0.000 claims description 16
- 238000002955 isolation Methods 0.000 claims description 4
- 230000006870 function Effects 0.000 description 21
- 101150053844 APP1 gene Proteins 0.000 description 10
- 101100189105 Homo sapiens PABPC4 gene Proteins 0.000 description 10
- 102100039424 Polyadenylate-binding protein 4 Human genes 0.000 description 10
- 238000010586 diagram Methods 0.000 description 8
- 238000011084 recovery Methods 0.000 description 6
- 230000001360 synchronised effect Effects 0.000 description 5
- 230000000694 effects Effects 0.000 description 4
- 238000013459 approach Methods 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 3
- 230000003068 static effect Effects 0.000 description 3
- 230000001960 triggered effect Effects 0.000 description 3
- 230000003190 augmentative effect Effects 0.000 description 2
- 238000004590 computer program Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000010926 purge Methods 0.000 description 2
- 238000004064 recycling Methods 0.000 description 2
- 101100264195 Caenorhabditis elegans app-1 gene Proteins 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000007405 data analysis Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000007599 discharging Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000007334 memory performance Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000000717 retained effect Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Landscapes
- Memory System Of A Hierarchy Structure (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application discloses a memory management method, a memory management device, electronic equipment and a readable storage medium, and belongs to the technical field of communication. The method comprises the following steps: under the condition that the state of the application of the electronic equipment is switched to the first state, isolating a physical memory space where file data of the application are located, and executing memory demapping operation on an application process of the application, wherein the memory demapping operation is used for demapping a virtual memory space of the application process from the physical memory space.
Description
Technical Field
The application belongs to the technical field of communication, and particularly relates to a memory management method, a memory management device, electronic equipment and a readable storage medium.
Background
Currently, the memory required by the software of the electronic device during the running process includes file memory, anonymous memory, GPU display memory, and a small amount of management memory. Wherein, the memory mapping needs to be established in the use process of the memory, and the memory demapping needs to be executed when the memory is not needed.
In the related art, when the electronic device performs memory reclamation under the condition that the system memory space is insufficient, the application processes are released from the memory map one by one in the process of executing the memory reclamation so as to release a certain system memory. However, since the memory demapping process needs to search the multi-layer page table structure to complete, the CPU overhead occupied by the whole process is large, so that executing the memory demapping process under the condition of insufficient system memory space results in lower efficiency of executing the memory demapping, and thus lower memory management efficiency.
Disclosure of Invention
The embodiment of the application aims to provide a memory management method, a device, electronic equipment, a readable storage medium and a chip, which can avoid complex memory demapping operation when the system memory is tensed, thereby improving the memory management efficiency.
In a first aspect, an embodiment of the present application provides a memory management method, where the method includes: under the condition that the state of the application of the electronic equipment is switched to the first state, isolating a physical memory space where file data of the application are located, and executing memory demapping operation on an application process of the application, wherein the memory demapping operation is used for demapping a virtual memory space and a physical memory space of the application process.
In a second aspect, an embodiment of the present application provides a memory management device, including: the processing module is used for: under the condition that the state of the application of the electronic equipment is switched to the first state, isolating a physical memory space where file data of the application are located, and executing memory demapping operation on an application process of the application, wherein the memory demapping operation is used for demapping a virtual memory space and a physical memory space of the application process.
In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory storing a program or instructions executable on the processor, which when executed by the processor, implement the steps of the method as described in the first aspect.
In a fourth aspect, embodiments of the present application provide a readable storage medium having stored thereon a program or instructions which when executed by a processor perform the steps of the method according to the first aspect.
In a fifth aspect, an embodiment of the present application provides a chip, where the chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and where the processor is configured to execute a program or instructions to implement a method according to the first aspect.
In a sixth aspect, embodiments of the present application provide a computer program product stored in a storage medium, the program product being executable by at least one processor to implement the method according to the first aspect.
In the embodiment of the application, under the condition that the state of the application of the electronic device is switched to the first state, the physical memory space where the file data of the application is located is isolated, and the memory demapping operation is executed on the application process of the application, wherein the memory demapping operation is used for demapping the virtual memory space and the physical memory space of the application process. According to the method, under the condition that the state of the application of the electronic equipment is switched to the first state, the memory mapping between the application process of the application and the file data of the application is released, so that complex memory demapping operation can be prevented from being executed when the system memory is tense, and further the memory management efficiency is improved.
Drawings
FIG. 1 is a schematic diagram of a page table management process of a process according to an embodiment of the present application;
FIG. 2 is a flow chart of a memory management method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of control node initialization according to an embodiment of the present application;
FIG. 4 is a second flowchart of a memory management method according to an embodiment of the present application;
FIG. 5 is a third flow chart of a memory management method according to an embodiment of the application;
FIG. 6 is a schematic diagram of a memory management device according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
Fig. 8 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions of the embodiments of the present application will be clearly described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which are obtained by a person skilled in the art based on the embodiments of the present application, fall within the scope of protection of the present application.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application are capable of operation in sequences other than those illustrated or otherwise described herein, and that the objects identified by "first," "second," etc. are generally of a type not limited to the number of objects, for example, the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
The terms "at least one," "at least one," and the like in the description and in the claims, mean that they encompass any one, any two, or a combination of two or more of the objects. For example, at least one of a, b, c (item) may represent: "a", "b", "c", "a and b", "a and c", "b and c" and "a, b and c", wherein a, b, c may be single or plural. Similarly, the term "at least two" means two or more, and the meaning of the expression is similar to the term "at least one".
The nouns or self-explanatory words according to the present application are explained below.
1. Memory
Memory (Memory) is an important component of a computer, also called an internal Memory and a main Memory, and is used for temporarily storing operation data in a CPU and data exchanged with an external Memory such as a hard disk. The method is a bridge for communicating the external memory with the CPU, all programs in the computer are run in the internal memory, and the intensity of the internal memory performance affects the level of the whole exertion of the computer. Under the condition that the computer starts to run, the operating system can call the data to be operated from the memory to the CPU to operate, and when the operation is completed, the CPU outputs an operation result.
2. Memory management
Linux memory management is a complex theme and involves multiple subsystems including page caching, memory allocation, swap space management, etc. Three main concepts in memory management include linked lists, file pages, and pages, where:
Linked list: linux uses a doubly-cycled linked list to manage available memory pages, each of which can be linked in the linked list as a node, each node of the linked list being a memory page. During memory allocation, each free memory block of the linked list is scanned, one memory block with the size meeting the requirement is found out, and the memory block is removed from the linked list.
File page: when a program performs a file operation (e.g., reads and writes a file), the contents of the file are read into memory, which is referred to as a file-page (file-supported page). These file pages may be swapped onto disk to free up memory, from which memory can be read again when needed.
Page: linux manages memory in basic units of pages, typically 4KB or 8KB in size, which may vary from architecture to architecture.
3. Memory mapping
Memory mapping is a technique for mapping disk files or other devices to a process address space. In memory mapping, the operating system caches data of disk files or devices in memory and allocates a continuous segment of virtual addresses in the address space of the process so that the process can access the data as if it were accessing memory. This access scheme is more efficient than the traditional file read-write scheme because it avoids frequent disk operations and data copying. Meanwhile, the memory mapping can enable a plurality of processes to share the same data, so that more efficient inter-process communication is realized.
The memory map may map disk files into memory, thereby avoiding frequent disk accesses and data copying. This can increase the file access speed, especially for large files and randomly accessed files.
Multiple processes may map the same piece of data, thereby enabling inter-process communication. This approach is more efficient than conventional pipes or message queues. The memory map may map the same file to different process address spaces, thereby implementing inter-process shared memory. This approach is safer and more stable than the traditional shared memory approach.
4. Page table
In order to complete the memory mapping, the kernel maintains a page table for each process, records the mapping relationship between the virtual address and the physical address, specifically, the page table is used to store the starting address of the physical address page, that is, page table entries, where a page table includes 1024 page table entries in total, and the size of each page table entry is 4B, so that the size of one page table is also 4K, and since the directory table can store 1024 page tables at most, the maximum size of the page table is 1024 x 4k=4m.
5. Forward mapping and reverse mapping
When the process allocates memory and performs writing operation, virtual addresses are allocated and page missing occurs, physical memory is allocated and a mapping relationship from virtual addresses to physical addresses is established, and the process is called forward mapping.
The process of finding all virtual pages that map it through physical pages is called reverse-mapping (RMAP), and when memory reclamation occurs, the physical memory pages are obtained through reverse mapping techniques and all mapping relationships are found for demapping.
6. Memory page
The memory pages are divided into file pages and calculation pages, wherein the file pages in the memory are file cache areas, namely file type memory pages, and the memory pages (also called permanent pages) for storing file data are used for reducing the access to a disk when reading and writing the file, and if the size of the memory pages is set to be too small, the system can be caused to frequently access the disk, and the Input/Output (I/O) of the disk is increased; the calculation pages in the memory are also called calculation type memory pages, and are mainly used for storing program codes and temporary used data.
7. Memory reclamation
Memory reclamation refers to reclaiming heap segments and file map segments in user space. The user can manually perform memory release using free (), etc. When there is no free physical memory, the kernel will begin to automatically perform the reclaiming of memory. The recovery modes are mainly two types: background memory reclamation and direct memory reclamation.
Background memory reclamation (kswapd): when the physical memory is tense, the kswapd kernel thread is awakened to recover the memory, and the process of recovering the memory is asynchronous and cannot block the execution of the process.
Direct memory reclamation (DIRECT RECLAIM): if the background asynchronous recovery does not keep pace with the process memory application, direct recovery is started, and the process of recovering the memory is synchronous and blocks the process.
The memory required in the running process of the Android mobile phone software at present is roughly divided into file memory, anonymous memory, GPU display memory and a small amount of management memory. Wherein, in the use process, a Page Table Entry (PTE) mapping (i.e. memory mapping) needs to be established, and PTE Page Table demapping (i.e. memory demapping) needs to be performed when the memory mapping is not needed.
FIG. 1 is a schematic diagram of a Page Table management process in a related art process, as shown in FIG. 1, when performing Page Table management, a memory management unit (Memory Management Unit, MMU) finds a primary Page Table through a Page Table base register and a Page global directory (Page Global Directory, PGD) index (index) in a virtual address, finds a secondary Page Table through a primary Page Table and a Page upper directory (Page Upper Directory, PUD) index in a virtual address, finds a tertiary Page Table through a secondary Page Table and a Page middle directory (Page middledirectory, PMD) index in a virtual address, and finally finds a quaternary Page Table through a tertiary Page Table and a Page Table Entry (PTE) index in a virtual address, and finds a physical address of a file memory or anonymous memory through a quaternary Page Table and an Offset in a virtual address.
In combination with the above-mentioned fig. 1, when performing demapping, the demapping process needs to search the above-mentioned four-layer page table structure to complete, and the cpu overhead occupied by the whole process is relatively large.
In addition, in the system kswapd kernel thread memory recovery process, all page tables corresponding to the memory are found through reverse mapping, the mapping is removed one by one, and the CPU overhead occupied by the whole process is also very large. Specifically, the current system kswapd memory reclamation process finds all page table management structures through reverse mapping, unmaps one by one, and then releases memory. The influence on the recovery efficiency of the file pages is mainly the number of times of establishing mapping of the file pages, and the more the number of times of establishing mapping is, the more the demapping expense is. The number of file page mappings is related to how many processes the page is shared for use, and Android applications have one or more background processes in addition to a host process. In practical tests, it is found that the mapping times of the file pages reach 3 times on average after the memory data analysis is opened, so that at least 3 demapping needs to be continuously performed, and the memory demapping process is performed under the condition of insufficient memory space of the system due to the large CPU overhead occupied by the demapping process, so that the efficiency of performing the memory demapping is low, and the memory management efficiency is low.
In order to solve the above technical problems, in the memory management method provided by the embodiment of the present application, when the state of an application of an electronic device changes, the memory mapping between the application process of the application and the file data of the application is released, so that the complex memory demapping operation can be avoided from being executed when the system memory is in tension, and further the memory management efficiency is improved.
The execution body of the memory management method provided by the embodiment of the application can be electronic equipment, or at least one of a functional module and an entity module which can realize the memory management method in the electronic equipment, and the execution body can be specifically determined according to actual use requirements, and the embodiment of the application is not limited. The memory management method provided by the embodiment of the application is described below by taking an example of executing the memory management method by the electronic device.
The memory management method provided by the embodiment of the application is described in detail below through specific embodiments and application scenarios thereof with reference to the accompanying drawings.
Fig. 2 is a flow chart of a memory management method according to an embodiment of the present application, as shown in fig. 2, the memory management method may include the following step S201:
Step S201: under the condition that the state of the application of the electronic equipment is switched to the first state, isolating the physical memory space where the file data of the application are located, and executing memory demapping operation on the application process of the application.
The memory demapping operation is used for demapping the virtual memory space and the physical memory space of the application process.
In some embodiments of the present application, the file data may be data in a file of the application. By way of example, the files of the application may include program code files (e.g., executable files) or multimedia files (e.g., pictures, audio, video) that the application needs to load during execution.
For example, in the case where the file of the application is a multimedia file, the file may be a file of a picture, audio, video, or the like; or in the case where the file of the application is an executable file of the application, the file may be additional files and static content used by the application at runtime, such as images, audio, video, fonts, configuration files, and the like.
It should be noted that, the program code file of the application may be referred to as a resource file of the application.
In some embodiments of the present application, the file data may include all or part of the file data used in the application running process. In other words, the file data may include file data corresponding to one or more application processes of the application.
It should be noted that an application process may also be referred to as a process.
In some embodiments of the present application, the file of the application is a file stored in a disk, and the file data of the file may be file data loaded into a memory, where an application process of the application needs to access the file data from the memory during running.
It can be understood that when the application is running, the electronic device will read the data of the file of the application from the disk to the physical memory, the application process runs in the virtual memory space, the physical address of the physical memory and the virtual address of the virtual memory have a mapping relationship, and when the file data is accessed by the application process, the memory management unit of the electronic device will map the virtual address of the application process to the corresponding physical address, thereby realizing the access to the data in the physical memory space.
In some embodiments of the present application, the physical memory space in which the file data is located is: and loading the physical memory space of the file data.
It should be noted that the above-mentioned physical memory space may be referred to as physical memory or memory.
The Physical Memory (Physical Memory) is referred to as virtual Memory. Physical memory refers to a memory space obtained by a physical memory bank, and virtual memory refers to dividing a block area of a hard disk as memory. The main purpose of the memory is to provide temporary storage for the operating system and various programs when the computer is running.
In some embodiments of the present application, the application may be an application installed in an electronic device, or a lightweight application installed without downloading a fast application, applet, or the like.
The quick application is a novel installation-free application developed based on industry standards, and is characterized in that the bag body is small, and the quick application is a light application which is ready to use without downloading. The applet is a light application based on the ecological circle inside the corresponding platform, and has the characteristics of no need of installation, use at any time and running after use.
In some embodiments of the application, the application may be a system application of the electronic device or a third party application in the electronic device.
In some embodiments of the present application, the application may be all or part of at least one application in a foreground running state.
In some embodiments of the present application, the application may be an application of a preset application type. By way of example, the preset application type may be an instant messaging application, a multimedia application, a reading application, a news application, an office application, etc.
The application may be, for example, an instant messaging application in the electronic device that is in a foreground running state.
It should be noted that the application may be flexibly set according to actual requirements, which is not limited by the embodiment of the present application.
In some embodiments of the present application, the first state may include a background running state, a background suspended state, and the like.
It should be noted that there are five states of an application, namely, not Running (Not Running), foreground Inactive (Active), foreground Active (Active), background (Background), and Background Suspended (Suspended). Wherein, not running means that the application has not been started yet, or that the application is running but stopped by the system on the way; foreground inactive refers to an application being run in the foreground, but not receiving an event; the foreground active state refers to the current application being run in the foreground and receiving an event; the background state refers to the state that the application is in background operation; the background suspended state refers to the application being in the background and having stopped executing code.
In some embodiments of the present application, an electronic device may monitor a state of one or more applications in the electronic device in real time or periodically, and isolate a physical memory space corresponding to a file of the application and perform a memory demapping operation on an application process of the application when the state of the application is switched to a first state.
In an exemplary embodiment, the electronic device may isolate a physical memory space in which file data of APP1 is located when APP1 in a foreground running state is switched to a background running state, and perform a memory demapping operation on an application process of APP 1.
In some embodiments of the present application, the memory demapping operation is specifically configured to demap a virtual address of a virtual memory space of an application process from a physical address of a physical memory space.
In some embodiments of the present application, the electronic device may isolate the physical memory space in which the file data of the application is located through the software atomic lock, so that the application process cannot access the file data from the physical memory space.
In some embodiments of the application, the application processes of the application may include one or more application processes. By way of example, an application process of an application may include a main process and at least one background process.
In some embodiments of the present application, the electronic device may perform a memory demapping operation on at least one application process of the application, so as to demap a virtual memory space of the at least one application process from a physical memory space where file data to be accessed is located.
It should be noted that, when the application process accesses the file data, it needs to first establish a mapping between the virtual memory space of the application process and the physical memory space where the file data is located, and when the application process does not need to access the file data, it can release the mapping between the virtual memory space of the application process and the physical memory space where the file data is located, so as to release the file data from the physical memory space.
It should be noted that, the memory demapping operation may also be referred to as memory demapping, where memory demapping may be understood as memory demapping, and since it is necessary to reverse-map and search a multi-stage page table structure when demapping a memory, and based on the multi-stage page table structure, demap between a virtual address of a virtual memory space where an application process is located and a physical address of a physical memory space where file data accessed by the application process is located, memory demapping may also be referred to as page table demapping. For an explanation of the memory demapping process, refer to the related art, and the description of this embodiment of the present application is omitted.
It will be appreciated that the physical memory space needs to be isolated before the mapping of the virtual memory space and the physical memory space is released, to ensure that the mapping is released in the event that the application process cannot access the data in the physical memory space.
With reference to the foregoing embodiments, the following describes, by way of specific examples, a memory management method provided by the embodiments of the present application.
Taking an example that an application of the electronic device is an instant messaging APP1 and a first state is a background running state, when the electronic device monitors that the instant messaging APP1 is switched from the foreground running state to the background running state, the electronic device isolates a physical memory of data of a picture a accessed by an application process loaded with the instant messaging APP, searches a multi-stage page table corresponding to the application process through reverse mapping after isolating the physical memory, and releases mapping between a virtual memory of the application process and the physical memory of the picture a based on the multi-stage page table.
In the embodiment of the application, the electronic device can execute the memory demapping operation on all or part of the application processes of the application under the condition that the state of the application is switched to the background running state or the background suspending state, and can remove the mapping between the virtual memory where the application process of the application is located and the physical memory where the accessed file is located when the application is switched to the state where the user does not obviously perceive the application, so that the memory mapping can be removed in advance under the condition that the user does not need to use the application at present, and the memory demapping is not required to be executed first when the memory is recovered later, thereby improving the memory management efficiency.
In the memory management method provided by the embodiment of the application, under the condition that the state of the application of the electronic equipment is switched to the first state, the physical memory space where the file data of the application is located is isolated, and the memory demapping operation is executed on the application process of the application, wherein the memory demapping operation is used for demapping the virtual memory space and the physical memory space of the application process. According to the method, under the condition that the state of the application of the electronic equipment is switched to the first state, the memory mapping between the application process of the application and the file data of the application is released, so that complex memory demapping operation can be prevented from being executed when the system memory is tense, and the memory management efficiency is improved.
In some embodiments of the present application, the electronic device may trigger the execution of the above-mentioned memory management process by controlling the switch in case that it is detected that the state of the application of the electronic device is switched to the first state.
In some embodiments of the present application, the control switch may be a software program that is newly added to trigger a memory management process.
In some embodiments of the present application, the electronic device initializes the control switch under the condition of application start, and continues to execute other initialization flows after the initialization is completed.
Fig. 3 is a flow chart of a switch initialization process according to an embodiment of the present application, as shown in fig. 3, the switch initialization process may include the following steps S11 to S13:
step S11: the process is initialized.
Illustratively, in the case of application startup, application process initialization is performed, and in the execution of the application process initialization flow, the control switch initialization flow in step S12 is skipped.
Step S12: the control switch is initialized.
Illustratively, the initialization of the control node is performed by creating a new control switch under the original process attribute directory, through which the frame trigger function can trigger the page table de-function (i.e., the memory management function) of the present scheme. After the initialization is completed, continuing to return to the original initialization flow;
Step S13: and (5) exiting.
Illustratively, the initialization control switch flow is exited and the subsequent native process initialization flow continues.
In the embodiment of the application, the control switch for triggering the memory management process is newly added in the application process, so that the memory management process can be accurately triggered through the control switch, and the controllability of the whole memory management process is ensured.
In some embodiments of the present application, the physical memory space includes at least one file page, and the at least one file page is used for storing the file data; the process of isolating the physical memory space in which the file data of the application is located in step S201 may include the following steps S201a to S201c:
step S201a: and the electronic equipment queries at least one file page from the management linked list according to the physical address of the file data.
The management linked list comprises a plurality of file pages, and the file pages are used for storing file data of files.
Step S201b: the electronic device deletes at least one file page from the management linked list.
In combination with the step S201a and the step S201b, the step S202 of canceling the isolation of the physical memory space may include the following step S202a:
Step S202c: the electronic device re-adds the at least one file page to the management linked list.
In some embodiments of the present application, the at least one file page is a memory page storing file data of an application.
It will be appreciated that when an application process accesses a file, the file data of the file is read into memory, which is referred to as file pages, which may be swapped onto disk to free up memory, and read from disk again when needed.
In some embodiments of the present application, the management linked list is configured to manage the at least one file page, and each first memory page may be used as a node chain in the linked list, that is, each node in the linked list is a memory page.
In some embodiments of the present application, the electronic device may obtain a physical address of a physical memory space storing file data of the application, query a file page from the management linked list according to the physical address, and then remove the queried file page from the management linked list.
It will be appreciated that removing a file page from the management chain, i.e., deleting a node on the management chain, frees up memory.
In some embodiments of the present application, after the mapping between the virtual memory space and the physical memory space is removed, the electronic device re-adds the at least one file page to the management linked list, that is, newly adds a node to the management linked list, so that the application process may access the file data of the application on the at least one file page.
In an exemplary embodiment, in combination with the above-mentioned example, when it is monitored that the instant messaging APP1 is switched from the foreground running state to the background running state, the electronic device removes at least one file page storing the data of the picture a accessed by the application process of the instant messaging APP from the management linked list, and after removing the at least one file page, removes the mapping between the virtual address of the virtual memory of the application process and the physical address of the file page where the data of the picture a is located, and after removing the mapping, re-adds the at least one file page to the management linked list, and retains the data of the picture a in the file page.
Therefore, when the application process needs to access the picture A later, only the memory mapping is needed to be established, the data of the picture A does not need to be loaded on a file page again, repeated reading of the file data is not needed, and accordingly I/O re-reading delay is avoided.
In some embodiments of the present application, the process of step S201 may include the following step S201d:
Step S201d: and under the condition that the state of the application is switched to the first state and the duration of the first state is greater than or equal to the first duration, isolating the physical memory space corresponding to the file data and executing memory demapping operation on the application process of the application.
In some embodiments of the present application, the first duration may be 3s, 5s, 7s, etc., or the first duration may be 3 minutes, 5 minutes, 7 minutes, etc.
It should be noted that the first time length may be specifically set according to actual requirements, which is not limited in the embodiment of the present application.
In some embodiments of the present application, after the state of the application is switched to the first state, the electronic device may start a timer with a timing duration being the first duration to record the duration of the application in the first state, isolate a physical memory space where file data of the application is located after the timer is overtime, and perform a memory demapping operation on an application process of the application.
By way of example, in combination with the above example, when the electronic device monitors that the instant messaging APP1 is switched from the foreground running state to the background running state, a timer with a timing duration of 5s is started, after the timer is overtime, at least one file page storing data of the picture a accessed by an application process of the instant messaging APP is removed from the management linked list, and after the at least one file page is removed, mapping between a virtual address of a virtual memory of the application process and a physical address of a file page where the data of the picture a is located is released.
Therefore, the electronic equipment can execute the memory demapping operation after the application is switched to the background running state for a period of time, so that the memory demapping can be released in advance under the condition that a user does not need to use the application temporarily, the memory demapping frequency is higher due to the fact that the memory demapping is executed after the application is switched to the background running state every time is avoided, and the memory management efficiency is improved.
In some embodiments of the present application, the state of the application may be monitored by the software framework, and in the case that it is monitored that the application is switched to the background running state for the first duration, all the processes of the application are traversed, and the page table release function is triggered one by one process by the control node (i.e. the control switch described above) so as to release the mapping between the virtual memory of all the processes of the application and the physical memory of the accessed file data.
For ease of description, the above-described process may be referred to as a framework triggering function, and the framework may be the software framework described above.
The process of the software framework monitoring and triggering page table release described above is illustrated by specific examples below. Illustratively, as shown in fig. 4, the above-described process may include the following steps S21 to S24:
Step S21: the framework detects that the application is switched to a background running state.
Illustratively, when the framework detects that any one of the applications in the electronic device is switched to the background running state, and when the duration of the background running state is greater than 5S, the following step S22 is executed.
Step S22: the framework determines whether to traverse all of the processes of the application.
Illustratively, the framework may traverse the application process of the application, and determine whether to traverse all the processes of the application, if so, execute the following step S23; if not, the following step 22 is performed.
Step S23: the page table release function is triggered once per process by the control switch.
It should be noted that, the process of triggering the execution of the page table release function on the process by the control switch may be referred to the related description of the above embodiment, which is not repeated herein.
Step S24: and (5) exiting.
In the embodiment of the application, a new control switch is created under the attribute catalog of the original process of the application, the frame triggering function can trigger the page table releasing function through the control switch, and after the initialization is completed, the original initialization process is continued to be returned, so that the whole memory management process can be orderly and controllably executed.
In some embodiments of the present application, after the step S201, the memory management method provided in the embodiment of the present application further includes the following step S202:
step S202: and under the condition that the application is switched from the first state to the second state, the electronic equipment executes memory mapping operation on the application process of the application based on the physical address of the physical memory space.
The memory mapping operation is used for establishing mapping between the virtual memory space and the physical memory space of the application process.
In some embodiments of the application, the first state is any one of the following: a background running state and a background suspending state; the second state is a foreground operation state.
In some embodiments of the present application, when an application is switched from a background running state or a background suspended state to a foreground running state, if an application process of the application needs to access file data of the application again, the electronic device may establish a mapping between a virtual address of a virtual memory space of the application process and a physical address of a physical memory space where the file data of the application is located according to a physical address of a physical memory space (e.g., a file page) where the file data of the application is located.
In some embodiments of the present application, when the application is switched from the background running state or the background suspended state to the foreground running state, the electronic device may cancel the physical memory space in which the file data of the isolated application is located, so as to reestablish the memory mapping between the physical memory space in which the file data is located and the virtual memory space of the application process.
By way of example, in combination with the above example, when the electronic device monitors that the instant messaging APP1 is switched from the foreground running state to the background running state, the electronic device isolates the physical memory of the data of the picture a accessed by the application process loaded with the instant messaging APP, searches the multi-stage page table corresponding to the application process through reverse mapping after isolating the physical memory, and releases the mapping between the virtual memory of the application process and the physical memory where the data of the picture a are located based on the multi-stage page table. Then, under the condition that the APP1 is switched from the background running state to the foreground running state again, according to the physical address of the physical memory loading the data of the picture A, the mapping between the virtual memory of the application process and the physical memory where the data of the picture A are located is established, so that when the application process subsequently needs to access the picture A, the mapping relation between the virtual address of the virtual memory space of the application process and the physical address of the physical memory space where the picture A is located can be quickly established, and the application process can quickly access the picture A, thereby improving the application running efficiency.
In the embodiment of the application, when the application process needs to access the file again under the condition that the running state of the application is switched to the foreground running state, the mapping between the virtual memory space of the application process and the physical memory space of the file data can be established based on the physical address of the physical memory space of the file data which the application process needs to access, so that the electronic device can quickly establish the memory mapping, thereby improving the running efficiency of the application.
In some embodiments of the present application, after the step S201, the memory management method provided in the embodiment of the present application may further include the following step S203:
Step S203: the electronic device cancels the isolation of the physical memory space and reserves the file data in the physical memory space.
In some embodiments of the present application, the electronic device may cancel isolating the physical memory space after performing the memory demapping operation and canceling the mapping between the virtual memory space and the physical memory space, and may retain file data in the physical memory space; or the electronic device may cancel isolating the physical memory space and preserve file data in the physical memory space if the memory demapping operation is performed, but the mapping of the virtual memory space and the physical memory space is not successfully released.
In the embodiment of the application, after the electronic equipment executes the memory demapping operation, whether the memory demapping operation is successful or not, the corresponding file memory is placed back to the original position, so that the file is not required to be reloaded into the memory when the file is required to be read again later, and the I/O reading efficiency is improved.
In some embodiments of the present application, after the mapping between the virtual memory space and the physical memory space is removed, the electronic device removes the isolated physical memory space, so that the application process of the application can normally access the file data in the physical memory space.
In an exemplary embodiment, when the electronic device monitors that the instant messaging APP1 is switched from the foreground running state to the background running state, the electronic device isolates the physical memory of the data of the picture a accessed by the application process loaded with the instant messaging APP, searches the multi-level page table corresponding to the application process through reverse mapping after isolating the physical memory, and releases the mapping between the virtual memory of the application process and the physical memory where the data of the picture a is located based on the multi-level page table, and after releasing the mapping between the virtual memory of the application process and the physical memory where the data of the picture a is located, isolates the physical memory loaded with the data of the picture a, and retains the data of the picture a in the physical memory, so that when the application process subsequently needs to access the picture a, only the memory mapping needs to be established without reloading the data of the picture a to the physical memory, and repeated reading of file data is not needed, thereby avoiding I/O rereading delay.
In the embodiment of the application, under the condition that the state of the application of the electronic equipment is switched to the first state, the physical memory space where the file data of the application is located is isolated, the memory demapping operation is executed on the application process of the application, after the mapping between the virtual memory space and the physical memory space is released, the isolated physical memory space is canceled, and the file data is reserved in the physical memory space. Therefore, when the state of the application changes, the electronic equipment can remove the memory mapping in advance without recovering the system memory, on one hand, the memory mapping can be removed in advance when the state of the application changes, the complex memory demapping operation is avoided being recovered and executed again when the system memory is tense, so that the memory management efficiency is improved, and on the other hand, the file data of the file is still reserved in the physical memory due to the fact that the memory mapping is removed in advance, so that the file data does not need to be reloaded to the physical memory space when the application needs to access the file data later, and the memory mapping can be directly carried out according to the physical address of the file data, so that the operation efficiency of the application can be improved.
In some embodiments of the present application, the process of reserving file data in the physical memory space in the step S203 may include the following step S203a:
Step S203a: and under the condition that the size of the residual memory space of the electronic equipment is larger than a first threshold value, the electronic equipment keeps file data in the physical memory space.
In some embodiments of the present application, the electronic device may clear the file data from the physical memory space if the size of the remaining memory space of the electronic device is less than or equal to the first threshold.
In some embodiments of the present application, the remaining memory space may be an available physical memory space remaining in the electronic device.
In some embodiments of the present application, the first threshold may be 256M, 500M, 1G, etc., and the first threshold may be specifically set according to actual needs, which is not limited in this embodiment of the present application.
In some embodiments of the present application, after performing the memory demapping operation, the electronic device may obtain a remaining memory space of the electronic device, and determine to reserve file data or purge file data in the physical memory space according to the size of the remaining memory space.
In an exemplary embodiment, the electronic device may store the file data in the physical memory space if the size of the remaining memory space is greater than the first threshold, or may perform memory reclamation if the size of the remaining memory space is less than or equal to the first threshold, and release the physical memory space in which the file data of the application is stored, so as to purge the file data of the application.
By way of example, in combination with the above example, when the electronic device monitors that the instant messaging APP1 is switched from the foreground running state to the background running state, the electronic device isolates the physical memory of the data of the picture a accessed by the application process loaded with the instant messaging APP, searches the multi-stage page table corresponding to the application process through reverse mapping after isolating the physical memory, and based on the multi-stage page table, removes mapping between the virtual memory of the application process and the physical memory where the data of the picture a are located and cancels isolation of the physical memory loaded with the data of the picture a. If the remaining memory space of the electronic device is less than or equal to 500Mb, the data of the picture a in the physical memory is cleared, or if the remaining memory space of the electronic device is greater than 500Mb at this time, the data of the picture a is retained in the physical memory. Further, under the condition of keeping the data of the picture A, if the size of the residual physical memory is monitored to be less than 500Mb, memory reclamation is performed, and the data of the picture A is cleared from the physical memory to release a certain physical memory for other processes.
In the embodiment of the application, the electronic equipment can remove the memory mapping in advance under the condition that the application is switched to the background running state, and can reserve the file data of the application in the physical memory space under the condition that the system resources are sufficient, or can execute the memory recycling operation under the condition that the system resources are tense, i.e. the available physical memory is insufficient, i.e. the file data in the physical memory space is cleaned, so as to release a certain memory space, thereby improving the memory recycling efficiency and the running performance of the electronic equipment.
In combination with the foregoing embodiments, the memory management process provided by the embodiments of the present application is described below by way of specific examples. For example, as shown in fig. 5, the memory management process may include the following steps S31 to S38:
step S31: and entering a memory management function.
Illustratively, the electronic device triggers the page table de-function one by one for the main process and background process of the application through the framework after discovering that the application cuts the background for more than 5 seconds through the framework.
It should be noted that the memory management function may be referred to as a release function.
Step S32, filtering the memory of the non-file type.
By way of example, non-file type memory refers to memory that does not store file data, and memory that stores file data may be demapped during processing, so non-file type memory may be filtered first.
Step S33, searching a multi-stage page table.
Illustratively, the electronic device may search the four-level page table through the forward map.
Step S34, judging whether the PTE page table establishes mapping.
Illustratively, the electronic device may find each PTE page table through a native multi-level page table, determining whether a mapping exists for the PTE page table; the presence of a map finds the corresponding file page.
Step S35, isolating the corresponding file pages.
For example, the electronic device may isolate the file pages of the process that need to be unmapped, which is equivalent to isolating the file pages from system memory management, i.e., isolating the file page memory.
Step S36, all the mappings are released.
The electronic device may, for example, de-map all of the processes of the application via a reverse mapping function.
Step S37: and returning the file page memory.
For example, the electronic device may place the file page corresponding to the application process back in place, i.e., re-add the corresponding file page to the management linked list, if the release is successful or not successful.
Step S38: the function exits.
According to the embodiment of the application, the electronic equipment can remove the file page mapping of the background application in advance under the condition of not causing file page I/O rereading according to the running states of the background application. The recovery efficiency of the system memory is improved, and the I/O delay of the file page during revisiting is avoided.
The above-mentioned method embodiments, or various possible implementation manners in the method embodiments, may be executed alone or may be executed in combination with each other on the premise that there is no contradiction, and may be specifically determined according to actual use requirements, which is not limited by the embodiment of the present application.
According to the memory management method provided by the embodiment of the application, the execution main body can be a memory management device. In the embodiment of the present application, a memory management device is used as an example to execute a memory management method.
Fig. 6 is a schematic structural diagram of a memory management device according to an embodiment of the present application, as shown in fig. 6, the memory management device 600 may include a processing module 601, where the processing module 601 is configured to: under the condition that the state of the application of the electronic equipment is switched to the first state, isolating a physical memory space where file data of the application are located, and executing memory demapping operation on an application process of the application, wherein the memory demapping operation is used for demapping a virtual memory space and the physical memory space of the application process.
In some embodiments of the present application, the processing module is specifically configured to isolate a physical memory space in which file data of the application is located and perform a memory demapping operation on an application process of the application when the state of the application is switched to the first state and a duration of the first state is greater than or equal to a first duration.
In some embodiments of the present application, the processing module is further configured to perform a memory mapping operation on an application process of the application based on a physical address of a physical memory space where file data of the application is located, where the application is switched from the first state to the second state after isolating the physical memory space where the file data of the application is located and performing the memory demapping operation on the application process; the memory mapping operation is used for establishing mapping between the virtual memory space of the application process and the physical memory space; the first state is any one of the following: a background running state and a background suspending state; the second state is a foreground operation state.
In some embodiments of the present application, the processing module is further configured to cancel a physical memory space in which the file data of the isolated application is located and to reserve the file data in the physical memory space after isolating the physical memory space in which the file data of the application is located and performing the memory demapping operation on the application process of the application.
In some embodiments of the present application, the processing module is specifically configured to, in a case where a size of a remaining memory space of the electronic device is greater than a first threshold, reserve file data in a physical memory space by the electronic device.
In the memory management device provided by the embodiment of the application, when the state of an application is switched to the first state, the memory management device isolates the physical memory space where the file data of the application is located, and performs a memory demapping operation on an application process of the application, wherein the memory demapping operation is used for demapping a virtual memory space and a physical memory space of the application process. By the method, the memory mapping can be released in advance, so that complex memory demapping operation is avoided when the system memory is tense, and further the memory management efficiency is improved.
The memory management device in the embodiment of the application can be an electronic device, or can be a component in the electronic device, such as an integrated circuit or a chip. The electronic device may be a terminal, or may be other devices than a terminal. The electronic device may be a Mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted electronic device, a Mobile internet appliance (Mobile INTERNET DEVICE, MID), an augmented reality (augmented reality, AR)/Virtual Reality (VR) device, a robot, a wearable device, an ultra-Mobile personal computer (UMPC), a netbook or a personal digital assistant (personal DIGITAL ASSISTANT, PDA), etc., and may also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (televisI/On, TV), a teller machine, a self-service machine, etc., which is not particularly limited in the embodiments of the present application.
The memory management device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android (Android) operating system, may be an I/Os operating system, and may also be other possible operating systems, which is not specifically limited in the embodiments of the present application.
The memory management device provided by the embodiment of the present application can realize each process implemented by the embodiments of the methods of fig. 1 to 5, so as to achieve the same beneficial effects, and in order to avoid repetition, no detailed description is given here.
Optionally, as shown in fig. 7, the embodiment of the present application further provides an electronic device 700, including a processor 701 and a memory 702, where the memory 702 stores a program or an instruction that can be executed on the processor 701, and the program or the instruction implements each step of the above-mentioned memory management method embodiment when executed by the processor 701, and the steps achieve the same technical effects, so that repetition is avoided, and no further description is given here.
The electronic device in the embodiment of the application includes the mobile electronic device and the non-mobile electronic device.
Fig. 8 is a schematic diagram of a hardware structure of an electronic device implementing an embodiment of the present application.
The electronic device 100 includes, but is not limited to: radio frequency unit 101, network module 102, audio output unit 103, input unit 104, sensor 105, display unit 106, user input unit 107, interface unit 108, memory 109, and processor 110.
Those skilled in the art will appreciate that the electronic device 100 may further include a power source (e.g., a battery) for powering the various components, and that the power source may be logically coupled to the processor 110 via a power management system to perform functions such as managing charging, discharging, and power consumption via the power management system. The electronic device structure shown in fig. 8 does not constitute a limitation of the electronic device, and the electronic device may include more or less components than shown, or may combine certain components, or may be arranged in different components, which are not described in detail herein.
Wherein, the processor 110 is configured to: under the condition that the state of the application of the electronic equipment is switched to the first state, isolating a physical memory space where file data of the application are located, and executing memory demapping operation on an application process of the application, wherein the memory demapping operation is used for demapping a virtual memory space and the physical memory space of the application process.
In some embodiments of the present application, the processor 110 is specifically configured to isolate a physical memory space in which the file data is located and perform a memory demapping operation on an application process of the application when the state of the application is switched to the first state and a duration of the first state is greater than or equal to a first duration.
In some embodiments of the present application, the processor 110 is further configured to, after isolating a physical memory space in which file data of the application is located and performing a memory demapping operation on an application process of the application, perform a memory mapping operation on the application process based on a physical address of the physical memory space when the application is switched from the first state to the second state; the memory mapping operation is used for establishing mapping between the virtual memory space of the application process and the physical memory space; the first state is any one of the following: a background running state and a background suspending state; the second state is a foreground operation state.
In some embodiments of the present application, the processor 110 is further configured to cancel the physical memory space in which the file data of the application is located and to reserve the file data in the physical memory space after isolating the physical memory space in which the file data of the application is located and performing the memory demapping operation on the application process of the application.
In some embodiments of the present application, the processor 110 is specifically configured to, in a case where a size of a remaining memory space of the electronic device is greater than a first threshold, hold file data in a physical memory space of the electronic device.
In the electronic device provided by the embodiment of the application, when the state of the application is switched to the first state, the physical memory space where the file data of the application is located is isolated, and the memory demapping operation is performed on the application process of the application, wherein the memory demapping operation is used for demapping the virtual memory space and the physical memory space of the application process. According to the method, under the condition that the state of the application of the electronic equipment is switched to the first state, the memory mapping between the application process of the application and the file data of the application is released, so that complex memory demapping operation can be prevented from being executed when the system memory is tense, and further the memory management efficiency is improved.
It should be appreciated that in embodiments of the present application, the input unit 104 may include a graphics processor (Graphics Processing Unit, GPU) 1041 and a microphone 1042, the graphics processor 1041 processing image data of still pictures or video obtained by an image capturing device (e.g. a camera) in a video capturing mode or an image capturing mode. The display unit 106 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit 107 includes at least one of a touch panel 1071 and other input devices 1072. The touch panel 1071 is also referred to as a touch screen. The touch panel 1071 may include two parts of a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and so forth, which are not described in detail herein.
Memory 109 may be used to store software programs as well as various data. The memory 109 may mainly include a first memory area storing programs or instructions and a second memory area storing data, wherein the first memory area may store an operating system, application programs or instructions (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like. Further, the memory 109 may include volatile memory or nonvolatile memory, or the memory 109 may include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable EPROM (EEPROM), or a flash Memory. The volatile memory may be random access memory (Random Access Memory, RAM), static random access memory (STATIC RAM, SRAM), dynamic random access memory (DYNAMIC RAM, DRAM), synchronous Dynamic Random Access Memory (SDRAM), double data rate Synchronous dynamic random access memory (Double DATA RATE SDRAM, DDRSDRAM), enhanced Synchronous dynamic random access memory (ENHANCED SDRAM, ESDRAM), synchronous link dynamic random access memory (SYNCH LINK DRAM, SLDRAM), and Direct random access memory (DRRAM). Memory 109 in embodiments of the present application includes, but is not limited to, these and any other suitable types of memory.
Processor 110 may include one or more processing units; optionally, the processor 110 integrates an application processor that primarily processes operations involving an operating system, user interface, application programs, etc., and a modem processor that primarily processes wireless communication signals, such as a baseband processor. It will be appreciated that the modem processor described above may not be integrated into the processor 110.
The embodiment of the application also provides a readable storage medium, on which a program or an instruction is stored, which when executed by a processor, implements each process of the above-mentioned memory management method embodiment, and can achieve the same technical effects, and in order to avoid repetition, the description is omitted here.
Wherein the processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes computer readable storage medium such as computer readable memory ROM, random access memory RAM, magnetic or optical disk, etc.
The embodiment of the application further provides a chip, which comprises a processor and a communication interface, wherein the communication interface is coupled with the processor, and the processor is used for running programs or instructions to realize the processes of the memory management method embodiment, and the same technical effects can be achieved, so that repetition is avoided, and the description is omitted here.
It should be understood that the chips referred to in the embodiments of the present application may also be referred to as system-on-chip chips, chip systems, or system-on-chip chips, etc.
Embodiments of the present application provide a computer program product stored in a storage medium, where the program product is executed by at least one processor to implement the respective processes of the embodiments of the memory management method described above, and achieve the same technical effects, and for avoiding repetition, a detailed description is omitted herein.
It should be noted that, in this document, 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, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Furthermore, it should be noted that the scope of the methods and apparatus in the embodiments of the present application is not limited to performing the functions in the order shown or discussed, but may also include performing the functions in a substantially simultaneous manner or in an opposite order depending on the functions involved, e.g., the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a computer software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present application.
The embodiments of the present application have been described above with reference to the accompanying drawings, but the present application is not limited to the above-described embodiments, which are merely illustrative and not restrictive, and many forms may be made by those having ordinary skill in the art without departing from the spirit of the present application and the scope of the claims, which are to be protected by the present application.
Claims (13)
1. A memory management method, the method comprising:
Under the condition that the state of the application of the electronic equipment is switched to a first state, isolating a physical memory space in which file data of the application are located, and executing memory demapping operation on an application process of the application;
the memory demapping operation is used for demapping the virtual memory space of the application process and the physical memory space.
2. The method according to claim 1, wherein in the case that the state of the application of the electronic device is switched to the first state, isolating the physical memory space in which the file data of the application is located, and performing the memory demapping operation on the application process of the application, includes:
And under the condition that the state of the application is switched to the first state and the duration of the first state is greater than or equal to a first duration, isolating a physical memory space in which file data of the application are located, and executing memory demapping operation on an application process of the application.
3. The method of claim 1, wherein after isolating the physical memory space in which the file data of the application is located and performing the memory demapping operation on the application process of the application, the method further comprises:
executing memory mapping operation on the application process based on the physical address of the physical memory space under the condition that the application is switched from the first state to the second state;
the memory mapping operation is used for establishing mapping between the virtual memory space of the application process and the physical memory space; the first state is any one of the following: a background running state and a background suspending state; the second state is a foreground running state.
4. A method according to any one of claims 1 to 3, wherein after isolating the physical memory space in which the file data of the application is located and performing a memory demapping operation on an application process of the application, the method further comprises:
and de-isolating the physical memory space and reserving the file data in the physical memory space.
5. The method of claim 4, wherein the reserving the file data in the physical memory space comprises:
and under the condition that the size of the residual memory space of the electronic equipment is larger than a first threshold value, the electronic equipment reserves the file data in the physical memory space.
6. A memory management device, the device comprising: a processing module for:
Under the condition that the state of the application of the electronic equipment is switched to a first state, isolating a physical memory space in which file data of the application are located, and executing memory demapping operation on an application process of the application;
the memory demapping operation is used for demapping the virtual memory space of the application process and the physical memory space.
7. The apparatus of claim 6, wherein the processing module is specifically configured to isolate a physical memory space in which file data of the application is located and perform a memory demapping operation on an application process of the application when the state of the application is switched to the first state and a duration of the first state is greater than or equal to a first duration.
8. The apparatus of claim 6, wherein the processing module is further configured to, after isolating a physical memory space in which file data of the application is located and performing a memory demapping operation on an application process of the application, perform a memory mapping operation on the application process based on a physical address of the physical memory space if the application is switched from the first state to the second state;
the memory mapping operation is used for establishing mapping between the virtual memory space of the application process and the physical memory space; the first state is any one of the following: a background running state and a background suspending state; the second state is a foreground running state.
9. The apparatus according to any one of claims 6 to 8, wherein the processing module is further configured to, after isolating a physical memory space in which file data of the application is located and performing a memory demapping operation on an application process of the application, cancel the isolation of the physical memory space and reserve the file data in the physical memory space.
10. The apparatus according to claim 9, wherein the processing module is configured to, in particular, reserve the file data in the physical memory space if the size of the remaining memory space of the electronic device is greater than a first threshold.
11. An electronic device comprising a processor and a memory storing a program or instructions executable on the processor, which when executed by the processor, implement the steps of the memory management method of any one of claims 1 to 5.
12. A readable storage medium, wherein a program or instructions is stored on the readable storage medium, which when executed by a processor, implements the steps of the memory management method according to any one of claims 1 to 5.
13. A chip comprising a processor and a communication interface, the communication interface and the processor being coupled, the processor being configured to execute a program or instructions to implement the memory management method according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410443268.6A CN118295809A (en) | 2024-04-12 | 2024-04-12 | Memory management method, memory management device, electronic equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410443268.6A CN118295809A (en) | 2024-04-12 | 2024-04-12 | Memory management method, memory management device, electronic equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118295809A true CN118295809A (en) | 2024-07-05 |
Family
ID=91674138
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410443268.6A Pending CN118295809A (en) | 2024-04-12 | 2024-04-12 | Memory management method, memory management device, electronic equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118295809A (en) |
-
2024
- 2024-04-12 CN CN202410443268.6A patent/CN118295809A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3514689B1 (en) | Memory management method and apparatus | |
US10963387B2 (en) | Methods of cache preloading on a partition or a context switch | |
US9081692B2 (en) | Information processing apparatus and method thereof | |
JP4718683B2 (en) | Method and system for restoring physical memory state when focus is changed between application programs in a computer | |
US6983467B2 (en) | Application programming interface enabling application programs to group code and data to control allocation of physical memory in a virtual memory system | |
KR20160023871A (en) | Latch-free, log-structured storage for multiple access methods | |
KR970022782A (en) | Systems and methods for managing distributed object resources | |
JP2004500605A (en) | An application programming interface for controlling the allocation of physical memory in a virtual storage system by an application program | |
JPH07200367A (en) | Memory snap shot method and information processing unit having memory snap shot function | |
CN113778662B (en) | Memory recovery method and device | |
US9342450B2 (en) | On-demand hypervisor memory mapping | |
CN109408149B (en) | Application program starting method, device, equipment and storage medium | |
CN114185494A (en) | Memory anonymous page processing method, electronic device and readable storage medium | |
CN112925606B (en) | Memory management method, device and equipment | |
CN118295809A (en) | Memory management method, memory management device, electronic equipment and readable storage medium | |
EP4375836A1 (en) | Memory paging method and system, and storage medium | |
CN108052415B (en) | Rapid recovery method and system for malicious software detection platform | |
CN103942120B (en) | A kind of reading/writing method and system based on Intel Virtualization Technology | |
CN115934276A (en) | Memory management method and device and electronic equipment | |
CN113485642A (en) | Data caching method and device | |
CN116680083A (en) | Memory processing method, device, equipment and storage medium | |
CN116954924A (en) | Memory management method and device and electronic equipment | |
JP4423849B2 (en) | Data protection system, data protection program, and data protection method | |
CN113419864B (en) | Application memory management method, device, equipment and storage medium | |
CN116431336A (en) | Page cache limiting method, page cache limiting system, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination |