Memory management method, device, storage medium, program product, apparatus and chip

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

Patent Information

Application Number
CN202510571955.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0004]然而,若被删除的数据后续被电子设备频繁访问,会使电子设备频繁地访问电子设备的外部存储空间,而电子设备从外部存储空间中读取数据的速度较慢,电子设备频繁访问外部存储空间可能会导致电子设备出现卡顿的现象,从而降低用户的使用体验

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011748A_ABST
    Figure CN123011748A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of storage, and discloses a memory management method, equipment, a storage medium, a program product, an apparatus and a chip. In the method, an electronic device determines hot area data of a first hot file and hot area data of a second hot file in a memory, stores the hot area data of the first hot file and the hot area data of the second hot file in a target storage space in the memory, and marks the target storage space as unrecoverable. At least one hot area data of the second hot file in the target storage space corresponds to address information of at least one cold area data of the first hot file in a first storage space of the first hot file. In this way, the hot area data of the hot file can be locked in the memory, and the hot file does not need to be completely locked in the memory, the space occupied by the hot file can be reduced, the unused space in the locked page can be reduced, and the memory resource utilization rate can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] When an electronic device is running an application (APP), if it detects an access request from the application (such as a request to retrieve target data), the electronic device reads the target data corresponding to the access request and sends it to the corresponding application. During the data reading process, the device first checks if the target data exists in its memory. If the target data exists in memory, the electronic device reads it directly from memory. If the target data does not exist in memory, the electronic device can read the target data from its external storage space (such as a hard disk drive), write the target data to memory, and then read the target data from memory to send it to the corresponding application.

[0003] Since the memory storage space of electronic devices is limited, when the memory space is insufficient, the electronic device will reclaim part of the storage space in memory, that is, delete the data stored in part of the memory storage space, so that the reclaimed storage space can be used to store new data.

[0004] However, if the deleted data is frequently accessed by the electronic device, it will cause the device to frequently access its external storage space. Since the speed at which the electronic device reads data from the external storage space is relatively slow, the frequent access to the external storage space may cause the electronic device to lag, thereby reducing the user experience. Summary of the Invention

[0005] To improve the utilization of memory resources, this application provides a memory management method, device, storage medium, program product, apparatus, and chip.

[0006] The first aspect of this application provides a memory management method applied to an electronic device. The method includes: acquiring N hot zone data of a first hot file and M hot zone data of a second hot file stored in the memory of the electronic device, wherein the hot file is a file whose access count is greater than a first threshold within a first time interval, and the hot zone data is data that stores the corresponding hot file and whose access count is greater than a second threshold within the first time interval, the second threshold being less than or equal to the first threshold, N being an integer greater than 0, and M being an integer greater than 0; storing the N hot zone data of the first hot file and the M hot zone data of the second hot file in a target storage space in memory, and marking the target storage space as non-reclaimable, wherein the address information of at least one hot zone data of the M hot zone data of the second hot file in the target storage space corresponds to the address information of at least one cold zone data of the first hot file in the first storage space in memory, the first storage space being the storage space for storing the first hot file, and the cold zone data being data that stores the corresponding hot file and whose access count is less than or equal to the second threshold within the first time interval.

[0007] In this embodiment of the application, the first hot file and the second hot file can be files stored in the memory of the electronic device, or files read from the external storage space of the electronic device into the memory of the electronic device after the electronic device detects the access request of the corresponding application.

[0008] Using the above method, electronic devices can lock only the frequently accessed portions (hot zone data) of each hot file in the device's memory, without locking the entire hot file in memory. This reduces the storage space occupied by hot files and minimizes memory resource waste. The address information of at least one hot zone data point from the M hot zone data points of the second hot file in the target storage space corresponds to the address information of at least one cold zone data point from the first hot file in the first storage space. In other words, the N hot zone data points of the first hot file and the M hot zone data points of the second hot file can be stored together in the target storage space. Furthermore, at least one hot zone data point from the second hot file is stored within the hot zone data storage space used to store the first hot file, improving the utilization rate of unused storage space in the storage space used to store the hot zone data points of the first hot file. For example, at least one hot zone data point from the first hot file and at least one hot zone data point from the second hot file can be stored on the same page, thus reducing the unused memory space in the locked page, avoiding memory resource waste, and improving memory resource utilization.

[0009] In one possible implementation of the first aspect described above, each hot file includes one or more file pages, each file page having a first size, and the target storage space having a size that is an integer multiple of the first size.

[0010] In one possible implementation of the first aspect described above, any one of the N hot zone data of the first hot file in the first storage space and any one of the M second logical address spaces of the second hot file in the second storage space do not overlap, wherein the second storage space is the storage space for storing the second hot file; and the N logical address spaces of the N hot zone data of the first hot file in the target storage space are the same as the N first logical address spaces, and the M logical address spaces of the M hot zone data of the second hot file in the target storage space are the same as the M second logical address spaces.

[0011] In this embodiment, if any one of the N hot zone data of the first hot file in the first storage space and any one of the M second logical address spaces of the second hot file in the second storage space do not overlap, the electronic device can directly store the N hot zone data of the first hot file in the target storage space according to the first logical address space (that is, the N hot zone data of the first hot file in the target storage space are the same as the N first logical address spaces), and store the M hot zone data of the second hot file in the target storage space according to the second logical address space (that is, the M hot zone data of the second hot file in the target storage space are the same as the M second logical address spaces).

[0012] The electronic device does not need to store the cold data of the first and second hot files in the target storage space. Furthermore, the hot data of both the first and second hot files are stored together in the target storage space, reducing the amount of idle storage area and thus improving the utilization rate of the target storage space. Moreover, the N hot data points of the first hot file are stored in the target storage space according to the first logical address space, and the M hot data points of the second hot file are stored in the target storage space according to the second logical address space. The electronic device does not need to change the access method for the N hot data points of the first hot file and the M hot data points of the second hot file.

[0013] In one possible implementation of the first aspect described above, storing N hot zone data of the first hot file and M hot zone data of the second hot file into a target storage space in memory includes: storing the N hot zone data of the first hot file into a first target storage space within the target storage space, wherein the N logical address spaces of the N hot zone data of the first hot file in the first target storage space are the same as the N first logical address spaces of the N hot zone data of the first hot file within the first storage space; storing the M hot zone data of the second hot file into a second target storage space within the target storage space, wherein the M logical address spaces of the M hot zone data of the second hot file in the second target storage space are the same as the M second logical address spaces of the M hot zone data of the second hot file within the second storage space, wherein at least one of the N first logical address spaces overlaps with at least one of the M second logical address spaces, wherein the second storage space is the storage space for storing the second hot file; and the base address of the second target storage space is the base address of the first target storage space plus a first length.

[0014] In this embodiment, the electronic device stores the M hot zone data of the second hot file into the second target storage space determined by adding a first length to the base address of the first target storage space. This ensures that the N hot zone data of the first hot file do not overlap in any of the N logical address spaces of the target storage space, and that the M hot zone data of the second hot file do not overlap in any of the M logical address spaces of the target storage space.

[0015] In this way, the electronic device can store N hot zone data of the first hot file in the first target storage space according to the first logical address space (that is, the N logical address spaces of the N hot zone data of the first hot file in the first target storage space are the same as the N first logical address spaces of the N hot zone data of the first hot file in the first storage space), and store M hot zone data of the second hot file in the second target storage space according to the second logical address space (that is, the M logical address spaces of the M hot zone data of the second hot file in the second target storage space are the same as the M second logical address spaces of the M hot zone data of the second hot file in the second storage space). The electronic device does not need to change the access method of the N hot zone data of the first hot file and the M hot zone data of the second hot file.

[0016] Furthermore, electronic devices do not need to store the cold data of the first and second hot files in the target storage space. The hot data of the first and second hot files are stored together in the target storage space, which can reduce the idle storage area in the target storage space, that is, improve the utilization rate of the target storage space.

[0017] In one possible implementation of the first aspect described above, the logical address space of the hot zone data within the corresponding storage space is determined based on the following parameters: the initial offset of the hot zone data relative to the base address of the storage space and the data length of the hot zone data.

[0018] In one possible implementation of the first aspect described above, the number of accesses within the first time interval is determined based on the number of times the file pages of the hot file are read into memory within the first time interval; or, the number of accesses within the first time interval is determined based on the number of address information access requests for the storage space storing the hot file within the first time interval.

[0019] In one possible implementation of the first aspect described above, obtaining N hotspot data of a first hotspot file and M hotspot data of a second hotspot file stored in the memory of an electronic device includes: using data stored in N first sub-storage spaces with access counts greater than a second threshold as N hotspot data of the first hotspot file, and using data stored in M ​​second sub-storage spaces with access counts greater than a second threshold as M hotspot data of the second hotspot file; wherein, the first storage space includes N first sub-storage spaces, the second storage space includes M second sub-storage spaces, and the second storage space is the storage space for storing the second hotspot file; the first sub-storage spaces are determined based on address information of multiple first data access requests, which are multiple access requests within a first time interval including address information of the first storage space storing the first hotspot file; the second sub-storage spaces are determined based on address information of multiple second data access requests, which are multiple access requests within a first time interval including address information of the second storage space storing the second hotspot file.

[0020] In this embodiment, the size of the target storage space is smaller than the sum of the sizes of the first target storage space and the second target storage space. That is, the first target storage space and the second target storage space at least partially overlap. This allows the address information of at least one hot data point in the M hot data points of the second hot file in the target storage space to correspond to the address information of at least one cold data point in the first hot file in the first storage space, thereby reducing unused memory space in locked pages and reducing the waste of memory resources.

[0021] In this embodiment of the application, for ease of access, the electronic device 100 may also store the mapping relationship between the physical address and logical address of the data stored in the target storage space (N hot zone data of the first hot file and M hot zone data of the second hot file).

[0022] In one possible implementation of the first aspect described above, the method further includes: detecting a first access request for at least one hot zone data of the first hot file; and reading the first target data corresponding to the first access request from the target storage space.

[0023] In one possible implementation of the first aspect described above, the method further includes: in response to a recycling instruction, storing the first hot file and the second hot file in memory to the external storage space of the electronic device.

[0024] In one possible implementation of the first aspect described above, the method further includes: detecting a second access request for at least one cold zone data of the first hot file, and the first hot file is not stored in the memory of the electronic device; reading the first hot file from the external storage space of the electronic device into the memory, and reading the second target data corresponding to the second access request from the memory.

[0025] In one possible implementation of the first aspect described above, the method further includes: acquiring a third hotspot file and L hotspot data of the third hotspot file stored in the memory of an electronic device, wherein L is an integer greater than 0; storing the L hotspot data of the third hotspot file in a target storage space; or, storing the L hotspot data of the third hotspot file in a third target storage space and marking the third target storage space as non-recoverable, wherein the third target storage space includes the target storage space.

[0026] In one possible implementation of the first aspect described above, the address information of at least one hot zone data among the L hot zone data of the third hot file in the target storage space corresponds to the address information of the area in the target storage space other than the N hot zone data of the first hot file and the M hot zone data of the second hot file; or, the address information of at least one hot zone data among the L hot zone data of the third hot file in the third target storage space corresponds to the address information of the area in the target storage space other than the N hot zone data of the first hot file and the M hot zone data of the second hot file.

[0027] In one possible implementation of the first aspect described above, any one of the N+M logical address spaces and any one of the L third logical address spaces in the third storage space containing the L hot zone data of the third hot file do not overlap. The N+M logical address spaces are determined based on the N logical address spaces in the target storage space containing the N hot zone data of the first hot file and the M logical address spaces in the target storage space containing the M hot zone data of the second hot file. The third storage space is the storage space for storing the third hot file. Furthermore, the L logical address spaces in the target storage space containing the L hot zone data of the third hot file are the same as the L third logical address spaces.

[0028] In one possible implementation of the first aspect described above, at least one logical address space among the N+M logical address spaces overlaps with at least one of the L third logical address spaces within the third storage space containing the L hot zone data of the third hot file. The N+M logical address spaces are determined based on the N logical address spaces of the N hot zone data of the first hot file within the target storage space and the M logical address spaces of the M hot zone data of the second hot file within the target storage space. The third storage space is the storage space for the third hot file. Furthermore, the fourth target storage space within the third target storage space stores the L hot zone data of the third hot file. The L hot zone data of the third hot file are identical to the L third logical address spaces in the L logical address spaces of the fourth target storage space. The base address of the fourth target storage space is the base address of the target storage space plus a second length.

[0029] In this embodiment, the electronic device stores the L hot zone data of the third hot file into a fourth target storage space determined by adding a second length to the base address of the target storage space. This ensures that any logical address space among the N+M logical address spaces and any logical address space among the L hot zone data of the third hot file in the fourth target storage space do not overlap.

[0030] A second aspect of this application provides an electronic device, comprising: a memory for storing instructions executable by one or more processing units of the electronic device; and a processor, one of the processors of the electronic device, for executing the instructions stored in the memory to implement any of the methods of the first aspect described above.

[0031] A third aspect of this application provides a computer-readable storage medium storing instructions that, when executed on a device, cause the device to implement any of the methods described in the first aspect.

[0032] The fourth aspect of this application provides a computer program product including instructions that, when executed on a device, cause the device to implement any of the methods described in the first aspect.

[0033] The fifth aspect of this application provides a communication device including a module for performing any of the methods described in the first aspect.

[0034] A sixth aspect of this application provides a chip including a processor coupled to a memory for executing a computer program or instructions stored in the memory, such that the chip implements any of the methods described in the first aspect above. Attached Figure Description

[0035] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0036] Figure 1 A software architecture diagram of an electronic device is shown according to an embodiment of this application;

[0037] Figure 2 A schematic diagram of a memory lock is shown according to an embodiment of this application;

[0038] Figure 3 A schematic diagram of a hotspot file is shown according to an embodiment of this application;

[0039] Figure 4 A schematic diagram of thermal zone data storage is shown according to an embodiment of this application;

[0040] Figure 5 A flowchart of a memory management method is shown according to an embodiment of this application;

[0041] Figure 6 A schematic diagram of a logical address space is shown according to an embodiment of this application;

[0042] Figure 7 A schematic diagram of thermal zone data is shown according to an embodiment of this application;

[0043] Figure 8 Another schematic diagram of thermal zone data storage is shown according to an embodiment of this application;

[0044] Figure 9 A schematic diagram illustrating the storage of hot zone data for a third hotspot file is shown according to an embodiment of this application.

[0045] Figure 10 According to an embodiment of this application, a schematic diagram of the storage of hot zone data of another third hotspot file is shown;

[0046] Figure 11 A schematic diagram of the structure of an electronic device 100 is shown according to an embodiment of this application;

[0047] Figure 12 A software structure block diagram of an electronic device 100 is shown according to an embodiment of this application;

[0048] Figure 13 An interactive flow diagram of a software module for implementing a memory management method is shown according to an embodiment of this application;

[0049] Figure 14 A schematic diagram of the structure of a communication device is shown according to an embodiment of this application. Detailed Implementation

[0050] The illustrative embodiments of this application include, but are not limited to, a memory management method, apparatus, storage medium, program product, device, and chip.

[0051] Before introducing the technical solutions involved in the embodiments of this application, some of the terms included in the embodiments of this application will be explained.

[0052] (1) Memory paging mechanism

[0053] Electronic devices can implement memory management based on memory units. Memory units include, but are not limited to, memory pages. For example, electronic devices can divide memory into memory pages according to a certain size (e.g., 4 kilobytes (KB)). Through memory paging mechanisms, the efficiency of accessing memory can be improved.

[0054] It should be noted that, with the evolution of technology, memory units can be implemented in other ways, not limited to memory pages. It is understood that this application uses memory pages as an example to illustrate the concept, but this does not constitute a limitation on memory units.

[0055] (2) Memory

[0056] The memory of an electronic device can include kernel memory, file-backed pages, anonymous pages, free memory, and other memory.

[0057] Kernel memory refers to the physical memory used by the operating system kernel of an electronic device. Kernel memory is used to run kernel code, store kernel data structures, and manage electronic devices.

[0058] A file page refers to a memory page (or simply a page) that has a source backup page in the external storage space of an electronic device (such as a disk, hard disk drive, network storage device, etc.). File pages and source backup pages in external storage space have a mapping relationship, such as having the same offset address. External storage space can refer to storage space other than memory.

[0059] An anonymous page is a memory page that does not have a corresponding file in external storage space. Pages used by a process's heap or stack can be anonymous pages. Similarly, pages requested by a process can be anonymous pages.

[0060] Free memory refers to currently unused storage space in memory. Free memory is not used by any process or system task and can be allocated to processes or system tasks that need memory at any time.

[0061] Applications (APPs) running on electronic devices can use different amounts of memory to support their operation. Different applications can use the same or different file pages; if different applications use the same file page, that same file can be called a shared page. Similarly, different applications can use the same or different anonymous pages.

[0062] Electronic devices can manage file pages and anonymous pages using a Least Recently Used (LRU) linked list. Multiple memory pages can be stored in the linked list.

[0063] (3) Memory reclamation technology

[0064] Electronic devices can group memory pages used by processes based on control group technology, controlling and managing memory in terms of allocation, sorting, and management. Memory reclamation management is performed by a reclamation thread (kswapd). When insufficient memory is detected (e.g., free memory is less than a preset memory threshold), the kswapd thread traverses all memory pages to determine which pages need to be reclaimed.

[0065] The following describes the methods for recycling file pages.

[0066] During memory reclamation, electronic devices filter out infrequently used file pages. If the data stored in a file page is identical to the data stored in a corresponding file page in external storage (such as a disk), the electronic device does not need to write the data stored in that file page back to the external storage space; instead, it can directly use that file page as a free page. This memory reclamation method is called page discarding.

[0067] If the data stored in a file page is inconsistent with the data stored in the corresponding file page in external storage, the electronic device can write the data stored in that file page back to the corresponding file page in external storage. Then, that file page is used as a free page. This memory reclamation method is called page write-back.

[0068] The process of writing file pages from memory to external storage is called swapping out. The process of reading file pages from external storage into memory is called swapping in.

[0069] The following section introduces the software architecture of electronic devices and, in conjunction with this architecture, describes the process of applications accessing data. For example, Figure 1A software architecture diagram of an electronic device is shown according to an embodiment of this application.

[0070] like Figure 1 As shown, the software architecture of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses a layered architecture as an example to exemplify the software structure of the electronic device 100.

[0071] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In the embodiments of this application, such as... Figure 1 As shown, the layered architecture of electronic device 100 includes: application layer, kernel layer, and hardware layer, etc.

[0072] The application layer can have multiple applications installed (e.g., application 1, application 2, etc. as shown in the diagram). Taking application 1 as an example, while the electronic device is running application 1, application 1 can initiate one or more access (read) requests. For example, assuming application 1 is a video playback application, while playing a video, application 1 can initiate a data access request to read the video data stored in the storage device, and then play the read video data.

[0073] The kernel layer can include a virtual file system (VFS), a page cache, and a file system (or secondary file system).

[0074] The virtual file system is a kernel software layer that serves as an interface between the physical file system and services. It abstracts all the details of the file system, making different secondary file systems appear identical to other processes running in the system.

[0075] Page cache is a part of memory. It uses memory as its storage medium to store file data in units of pages. Each page has a corresponding structure (structpage) in memory, which describes the page's attributes and state.

[0076] File systems can include extended file systems (ext4), journaling file systems (XFS), and zeta file systems (ZFS). Extended file systems (ext4) provide file journaling functionality. Journaling file systems provide metadata journaling functionality, ensuring rapid recovery of file system consistency after a system crash. Zeta file systems are used to create storage pools spanning multiple drives and can dynamically expand storage capacity online. It is understood that the file systems illustrated are merely examples; in practical applications, file systems can include more or fewer file systems or other types of file systems, and this application does not impose any limitations on this.

[0077] Below the application layer and kernel layer is the hardware layer, which consists of hardware devices that respond to various access requests. This includes various storage devices such as multimedia cards (MMC), embedded multimedia cards (eMMC), small computer system interface (SCSI) hard drives, universal flash storage (UFS), mechanical hard drives, disks, network storage devices, etc.

[0078] For each mounted file system, VFS generates a block structure in the kernel. The block represents a mounted file system and is used to store file system control information, such as file system type and size.

[0079] The virtual file system manages file data read and write operations through a page cache. When an application requests to read a file, the virtual file system first checks if the required data is already cached in the page cache. If the cache is hit, the data is read directly from the page cache; if the cache is missed, the virtual file system triggers an input / output (I / O) operation on the storage device (e.g., disk) to read the data from the storage device into the page cache, and then returns it to the application. Similarly, when an application needs to write data, the data is first written to the page cache, and then the kernel writes dirty pages (i.e., modified file pages) back to the storage device according to a certain strategy (e.g., write-back strategy).

[0080] As mentioned earlier, when an electronic device is running an application, if it detects an access request from the application (such as a request to retrieve target data), the electronic device reads the target data corresponding to the access request and sends it to the corresponding application. During the data reading process, the device first checks if the target data exists in its memory. If the target data exists in memory, the electronic device reads it directly from memory. If the target data does not exist in memory, the electronic device can read the target data from its external storage space (such as a hard disk drive), write the target data to memory, and then read the target data from memory to send it to the corresponding application.

[0081] Since the memory storage space of electronic devices is limited, when memory space is insufficient, the electronic device will reclaim part of the storage space in memory through the kswapd thread.

[0082] In other words, when an application references a file page, the electronic device reads the file page from external storage into memory. When memory is insufficient, the electronic device deletes the file page from memory and reads it back into memory on the next access.

[0083] If deleted data (file pages) is frequently accessed by electronic devices, it will cause the devices to frequently access their external storage space. Since electronic devices read data from external storage space relatively slowly, frequent access to external storage space may cause the electronic devices to lag, thereby reducing the user experience.

[0084] To address these issues, electronic devices can lock frequently accessed "hot files" (or high-frequency files) in memory. For example, during the device's boot process, the `mmap()` function can be called to lock these hot files into memory. The file pages corresponding to these locked files are marked as non-reclaimable, and will not be reclaimed when memory is insufficient.

[0085] When an electronic device accesses a file page corresponding to a file locked in memory, it can directly read the target data from memory. This avoids frequently swapping in and out of frequently accessed files, thus reducing the probability of lag caused by frequent access to external storage and improving the user experience.

[0086] For example, with Figure 1 Taking Application 1 as an example, when the electronic device is running Application 1, it detects an instruction to lock memory from Application 1. Application 1 then uses the virtual file system to call the file open() function to obtain the file (e.g., reading the file from the hardware storage device into the page cache), and uses the virtual file system to call the memory mapping function mmap() to map the file into the address space (virtual memory space) of the process corresponding to Application 1. Application 1 then uses the virtual file system to call the memory locking function mlock() to lock the file. This ensures that when memory space is insufficient, the file pages corresponding to the file locked in the page cache will not be reclaimed from memory.

[0087] After memory locking, application 1 can directly access and modify data in the locked file pages via pointers. Furthermore, the kswapd thread can reclaim the memory from the unlocked file pages.

[0088] After application 1 completes its access to and / or modification of the locked file page, it can unlock the memory by calling the memory unlock function `munlock()` through the virtual file system, and then remove the file from the address space of the process corresponding to application 1 by calling the memory unmapping function `munmap()` through the virtual file system. Finally, it closes the file by calling the file closing function `close()` through the virtual file system to release system resources, such as performing memory reclamation.

[0089] However, since electronic devices manage memory based on a paging mechanism, where a memory page is a memory unit, the basic unit of memory locking described above is also a page.

[0090] In some cases, if the size of a hot file is smaller than the size of a page, there will be some invalid memory areas in the locked memory space. The hot file cannot use this invalid memory area, and other files cannot use this invalid memory area either.

[0091] For example, refer to Figure 2 The diagram shown illustrates memory locking. Figure 2 The file page shown is 10 bytes (B), and the storage space corresponding to the locked file (i.e., the unrecoverable memory area) is 4KB. This will result in a waste of the invalid memory area corresponding to the remaining pages besides the file page. For example... Figure 2 The locked memory space shown contains a 4086-byte invalid memory region. That is, the remaining pages are invalid memory regions; the hot file cannot use these remaining pages, nor can other files.

[0092] Thus, although the size of the hot file is 10B, there will be an invalid memory area of ​​4086B in the locked memory space that cannot be allocated to store other data, which will result in a waste of this part of the memory resources.

[0093] In other cases, the size of hot files is often quite large, for example, tens of times the page size. Only a portion of the data in this hot file may be frequently accessed, such as... Figure 3 The hotspot file shown includes multiple high-frequency components and multiple non-high-frequency components.

[0094] Although only a portion of the data in the hot file may be frequently accessed, locking the memory space corresponding to the hot file prevents the memory space occupied by the less frequently accessed data in that file from being reclaimed. This results in a waste of memory resources.

[0095] In view of this, this application provides a memory management method. First, the electronic device determines N hot zone data of a first hot file and M hot zone data of a second hot file in the memory of the electronic device. Here, a hot file is a file whose access count within a first time interval is greater than a first access threshold, and hot zone data is data storing the corresponding hot file and whose access count within the first time interval is greater than a second access threshold, where the second access threshold is less than or equal to the first access threshold. N is a positive integer, and M is a positive integer.

[0096] Then, the N hot zone data of the first hot file and the M hot zone data of the second hot file are stored in the target storage space in the memory of the electronic device, and the target storage space is marked as non-reclaimable. The address information of at least one hot zone data from the M hot zone data of the second hot file in the target storage space corresponds to the address information of at least one cold zone data from the first hot file in the first storage space in the memory of the electronic device. The first storage space is the storage space for the first hot file, and the cold zone data is the data corresponding to the hot file that has been accessed less than or equal to a second access threshold within a first time interval.

[0097] In this way, electronic devices can lock only the frequently accessed portion (hot zone data) of each hot file in the memory of the electronic device, without having to lock the entire hot file in memory. This reduces the storage space occupied by hot files, reduces the waste of memory resources, and improves the utilization rate of memory resources.

[0098] Furthermore, the address information of at least one hot zone data from the M hot zone data of the second hot file in the target storage space corresponds to the address information of at least one cold zone data from the first hot file in the first storage space. In other words, the N hot zone data from the first hot file and the M hot zone data from the second hot file can be stored together in the target storage space, and at least one hot zone data from the second hot file is stored within the storage space used to store the hot zone data of the first hot file. This improves the utilization rate of unused storage space in the storage space used to store the hot zone data of the first hot file. For example, at least one hot zone data from the first hot file and at least one hot zone data from the second hot file can be stored on the same page, thus reducing the unused memory space in locked pages, avoiding wasted memory resources, and improving memory resource utilization.

[0099] For example, refer to Figure 4 The diagram shows a storage illustration of the hot zone data. (See diagram for example.) Figure 4As shown, the first hot file includes hot zone data 11, cold zone data 12, hot zone data 13, cold zone data 14, and hot zone data 15, while the second hot file includes cold zone data 21, hot zone data 22, cold zone data 23, hot zone data 24, and cold zone data 25. Therefore, the corresponding target storage space includes hot zone data 11, hot zone data 22, hot zone data 13, hot zone data 24, and hot zone data 15. Furthermore, the address information of hot zone data 22 in the target storage space corresponds to the address information of cold zone data 12 in the first hot file in the first storage space, and the address information of hot zone data 24 in the target storage space corresponds to the address information of cold zone data 14 in the first hot file in the first storage space.

[0100] It is understood that in some embodiments, each hot file includes one or more file pages, and the size of each file page is a first size (e.g., 4KB), then the size of the target storage space can be an integer multiple of the first size.

[0101] To more clearly illustrate the technical solution of this application, the memory management method provided in the embodiments of this application will be described below with reference to the accompanying drawings.

[0102] Figure 5 A flowchart illustrating a memory management method is shown according to an embodiment of this application. It can be understood that... Figure 5 The execution subject of the flowchart shown is electronic device 100. For ease of description, the following will refer to... Figure 5 When describing the flowchart shown, the execution subject of the flowchart will not be repeated.

[0103] like Figure 5 As shown, this process includes, but is not limited to:

[0104] S501: Electronic device 100 acquires N hot zone data of a first hot zone file and M hot zone data of a second hot zone file stored in the memory of electronic device 100.

[0105] In some embodiments, the electronic device 100 determines a first hotspot file and a second hotspot file stored in memory, and obtains N hotspot data of the first hotspot file and M hotspot data of the second hotspot file, wherein N is an integer greater than 0 and M is an integer greater than 0.

[0106] In some embodiments, a hot file is a file whose access count within a first time interval is greater than a first threshold, and hot zone data is data that stores the corresponding hot file and whose access count within the first time interval is greater than a second threshold.

[0107] It is understood that the second counting threshold is less than or equal to the first counting threshold. For example, the first counting threshold can be 5, 8, 10, or 15, and the second counting threshold can be 2, 5, 8, or 10. This application does not restrict the values ​​of the first counting threshold and the second counting threshold. The first counting threshold and the second counting threshold can be configured by the developers according to their needs.

[0108] It is understood that the first time interval can be a memory management cycle. For example, every preset time interval (the duration of the first time interval), the electronic device will identify hot files and their hot zones. The first time interval can also be a preset time interval within the historical usage records stored on the electronic device; this application does not impose any restrictions on this. The duration of the first time interval can be 5 minutes, 10 minutes, 30 minutes, 12 hours, 24 hours, 3 days, 7 days, or 30 days, etc. This application does not impose any restrictions on the duration of the first time interval, which can be configured by the developers according to their needs.

[0109] In some embodiments, the number of accesses within a first time interval is determined based on the number of times file pages of hot files are read into memory within the first time interval. Alternatively, the number of accesses within a first time interval is determined based on the number of address information access requests for the storage space storing hot files within the first time interval.

[0110] For example, if file 01 is read into memory 4 times within the first time interval, then file 01 is accessed 4 times within the first time interval. Or, for example, if electronic device 100 detects 10 access requests including the address information of the storage space corresponding to file 02 within the first time interval, then file 02 is accessed 10 times within the first time interval.

[0111] It is understood that the electronic device 100 can determine the number of file accesses and data accesses through the file system access log or configured script files, or it can use analysis tools to determine the number of file accesses and data accesses. This application does not limit this.

[0112] In some embodiments, the electronic device 100 uses data stored in N first sub-storage spaces with access counts greater than the second threshold as N hot zone data of a first hotspot file, and uses data stored in M ​​second sub-storage spaces with access counts greater than the second threshold as M hot zone data of a second hotspot file. The first storage space includes N first sub-storage spaces, and the second storage space includes M second sub-storage spaces.

[0113] It can be understood that the first sub-storage access space is determined based on the address information of multiple first data access requests, which are requests to access the address information of the first storage space containing the first hot file within a first time interval. The second sub-storage space is determined based on the address information of multiple second data access requests, which are requests to access the address information of the second storage space containing the second hot file within a first time interval.

[0114] For example, the address information may include the memory address of the storage space accessed by the data access request and the length of the data stored in the storage space accessed by the data access request. It is understood that if the storage spaces accessed by multiple data access requests overlap, the electronic device 100 may treat the multiple overlapping storage spaces as a sub-storage space, and this application does not impose any restrictions on this.

[0115] It is understandable that electronic device 100 can identify storage space and hotspot data that have been accessed more than the second access threshold by scanning the memory mapping information of hot files (such as smap files).

[0116] It is understood that the first hot file and the second hot file can be files stored in the memory of the electronic device 100, or files read from the external storage space of the electronic device 100 into the memory of the electronic device 100 after the electronic device 100 detects the access request of the corresponding application (such as the aforementioned application 1). This application does not impose any restrictions on this.

[0117] S502: Electronic device 100 stores N hot zone data of the first hot zone file and M hot zone data of the second hot zone file into the target storage space in memory, and marks the target storage space as non-recoverable.

[0118] In some embodiments, after the electronic device 100 determines N hot zone data of the first hot zone file and M hot zone data of the second hot zone file, it stores the N hot zone data of the first hot zone file and the M hot zone data of the second hot zone file into the target storage space in the memory of the electronic device 100, and marks the target storage space as non-recoverable.

[0119] The address information of at least one hot zone data of the second hot file in the target storage space corresponds to the address information of at least one cold zone data of the first hot file in the first storage space, and the first storage space is the storage space for storing the first hot file.

[0120] In some embodiments, the N hot zone data of the first hot file do not overlap in any one of the N first logical address spaces in the first storage space, and the M hot zone data of the second hot file do not overlap in any one of the M second logical address spaces in the second storage space. The N hot zone data of the first hot file are identical to the N first logical address spaces in the target storage space, and the M hot zone data of the second hot file are identical to the M second logical address spaces in the target storage space. The second storage space is the storage space for the second hot file.

[0121] In other words, if any one of the N hot zone data of the first hot file in the first storage space and any one of the M hot zone data of the second hot file in the second storage space does not overlap, the electronic device 100 will store the N hot zone data of the first hot file in the target storage space.

[0122] It can be understood that the logical address space of hotspot data within the corresponding storage space is determined based on the following parameters: the offset of the hotspot data relative to the base address of the storage space and the length of the hotspot data. The base address represents the starting address of the storage space in memory. For example, assuming the starting address of the storage space is 0x1000 and the address range of the storage space is 0x1000 to 0x13FF, then the size of this storage space is 1024 bytes. If the data is stored in the region from 0x1000 to 0x1011, then the offset of this data relative to the base address of the storage space is 0. For example, with... Figure 4 Taking the first hot file shown as an example, refer to... Figure 6 The diagram shows a logical address space.

[0123] like Figure 6 As shown, the first hotspot file includes hot zone data 11, cold zone data 12, hot zone data 13, cold zone data 14, and hot zone data 15. Taking hot zone data 11 as an example, the first offset of hot zone data 11 in the first storage space is 0, and the last offset is 127, that is, the first offset of hot zone data 11 in the first storage space is 0, and the data length of hot zone data 11 is 128 bits. The logical address space of hot zone data 11 in the first storage space is the space composed of bits 0 to 127 in the first storage space.

[0124] For example, continue to refer to Figure 4Assuming the initial offset of hot zone data 11 in the first hot file is 0, and the initial offset of cold zone data 21 in the second hot file is 0, and any one of the logical address spaces of hot zone data 11, hot zone data 13, and hot zone data 15 in the first hot file does not overlap with any one of the logical address spaces of hot zone data 22 and hot zone data 24, then the electronic device 100 can directly store hot zone data 11, hot zone data 13, hot zone data 15, hot zone data 22, and hot zone data 24 into the target storage space. Furthermore, the logical address spaces of hot zone data 11, hot zone data 13, and hot zone data 15 in the target storage space are the same as the logical address spaces of hot zone data 11, hot zone data 13, and hot zone data 15 in the corresponding storage space (first storage space) storing the first hot file. The logical address space of hot zone data 22 and hot zone data 24 in the target storage space is the same as the logical address space of hot zone data 22 and hot zone data 24 in the corresponding storage space (second storage space) storing the second hot file.

[0125] It is understandable that since the N hotspot data points of the first hotspot file reside in the same logical address space in the target storage space as those in the first storage space, the relative positions of the N hotspot data points of the first hotspot file remain unchanged. Therefore, the electronic device 100 does not need to change its access method for the first hotspot file. For example, if the electronic device 100 accesses the hotspot data of the first hotspot file via a pointer, it can point the pointer to the location with an offset of 0 in the target storage space (i.e., the location where the first hotspot file's initial offset is 0 in the target storage space), and add the offset information of the hotspot data to be accessed to access the corresponding hotspot data. For example, the electronic device 100 can point the pointer to... Figure 4 The position of the first offset of the hot zone data 11 is shown. If you need to access the hot zone data 13, you can add the first offset of the hot zone data 13 to access the hot zone data 13. The length of the data to be accessed can be set to the length of the hot zone data 13.

[0126] Similarly, since the M hotspot data points of the second hotspot file reside in the same logical address space in the target storage space as in the second storage space, the relative positions of the M hotspot data points of the second hotspot file remain unchanged, and the electronic device 100 does not need to change its access method for the second hotspot file. For example, if the electronic device 100 accesses the hotspot data of the second hotspot file via a pointer, it can point the pointer to the position with an offset of 0 in the target storage space (i.e., the position where the first offset of the second hotspot file in the target storage space is 0), and add the offset information of the hotspot data to be accessed to access the corresponding hotspot data. For example, the electronic device 100 can point the pointer to... Figure 4The position of the first offset of the hot zone data 11 shown (corresponding to the position where the first offset of the second hot zone file in the target storage space is 0) can be used to access the hot zone data 22 by adding the first offset of the hot zone data 22. The length of the data to be accessed can be set to the length of the hot zone data 22.

[0127] In other embodiments, the electronic device 100 stores N hot zone data of a first hot file in a first target storage space within a target storage space, wherein the N hot zone data of the first hot file are identical in the N logical address spaces of the first target storage space to the N first logical address spaces, and stores M hot zone data of a second hot file in a second target storage space within the target storage space, wherein the M hot zone data of the second hot file are identical in the M logical address spaces of the second target storage space to the M second logical address spaces.

[0128] Specifically, at least one of the N hot zone data of the first hot file within the first storage space overlaps with at least one of the M second logical address spaces of the second hot file within the second storage space. The second storage space is the storage space for the second hot file. Furthermore, the base address of the second target storage space is the base address of the first target storage space plus a first length. That is, the difference between the base address of the second target storage space and the base address of the first target storage space is the first length.

[0129] It is understandable that if the first length is 0, at least one hot zone data of the first hot file in the first target storage space and at least one hot zone data of the second hot file in the second target storage space will be stored in the same area of ​​the target storage space. Thus, at least one hot zone data of either the first or second hot file cannot be stored in the target storage space. Therefore, to ensure the integrity of the N hot zone data of the first hot file and the M hot zone data of the second hot file in the target storage space, the N hot zone data of the first hot file must not overlap in any logical address space of the N logical address spaces of the target storage space, and the M hot zone data of the second hot file must not overlap in any logical address space of the M logical address spaces of the target storage space.

[0130] Therefore, the first length is used to indicate the length value at which the N hot zone data of the first hot file do not overlap in any one of the N logical address spaces of the target storage space, and the M hot zone data of the second hot file do not overlap in any one of the M logical address spaces of the target storage space.

[0131] In this way, the electronic device 100 stores the M hot zone data of the second hot file in the second target storage space determined by the base address of the first target storage space plus the first length. This ensures that the N hot zone data of the first hot file do not overlap in any logical address space of the N logical address spaces of the target storage space, and the M hot zone data of the second hot file do not overlap in any logical address space of the M logical address spaces of the target storage space. This guarantees the integrity of the N hot zone data of the first hot file and the M hot zone data of the second hot file in the target storage space.

[0132] In other words, if at least one of the N hot zone data of the first hot file in the first storage space overlaps with at least one of the M second logical address spaces of the second hot file in the second storage space, the electronic device 100 stores the N hot zone data of the first hot file in the first target storage space and stores the M hot zone data of the second hot file in the second target storage space where the difference between the base address and the base address of the first target storage space is a first length. The target storage space includes the first target storage space and the second target storage space.

[0133] For example, refer to Figure 7 A schematic diagram of the thermal zone data is shown. (See attached diagram.) Figure 7 As shown, the first hotspot file includes hot zone data 31, cold zone data 32, hot zone data 33, cold zone data 34, and hot zone data 35, while the second hotspot file includes cold zone data 41, hot zone data 42, cold zone data 43, hot zone data 44, and cold zone data 45. Furthermore, the initial offset of the hot zone data 31 in the first hotspot file is 0, and the initial offset of the cold zone data 41 in the second hotspot file is 0. Since the logical address space of hot zone data 33 overlaps with the logical address space of hot zone data 42, the electronic device 100 can store the hot zone data of the first hotspot file in a first target storage space, add a first length to the base address of the first target storage space to obtain a second target storage space, store the hot zone data of the second hotspot file in the second target storage space, and use the storage space formed by the first and second target storage spaces as the target storage space.

[0134] For example, still using Figure 7 Taking the first and second hottest files shown as examples, refer to... Figure 8 The diagram shows a storage illustration of the hot zone data. (See diagram for example.) Figure 8As shown, the electronic device 100 stores hotspot data 31, 33, and 35 of the first hotspot file in a first target storage space, and stores hotspot data 42 and 44 of the second hotspot file in a second target storage space. The difference between the base address of the second target storage space and the base address of the first target storage space is a first length. Furthermore, the logical address space of hotspot data 31, 33, and 35 in the first target storage space is the same as the logical address space of hotspot data 42 and 44 in the second target storage space.

[0135] It is understandable that since the N hotspot data of the first hotspot file are in the same logical address space as the first target storage space, the relative positions of the N hotspot data of the first hotspot file do not change, and the electronic device 100 does not need to change its access method to the first hotspot file. For example, if the electronic device 100 accesses the hotspot data of the first hotspot file through a pointer, it can point the pointer to the position where the first offset is 0 in the first target storage space (i.e., the position where the first offset of the first hotspot file in the target storage space is 0), and add the offset information of the hotspot data to be accessed to access the corresponding hotspot data. For example, the electronic device 100 can point the pointer to... Figure 8 The position of the first offset of the hot zone data 31 is shown. If you need to access the hot zone data 35, you can add the first offset of the hot zone data 35 to access the hot zone data 35. The length of the data to be accessed can be set to the length of the hot zone data 35.

[0136] Similarly, since the M hotspot data of the second hotspot file reside in the same logical address space as the second target storage space, the relative positions of the M hotspot data of the second hotspot file remain unchanged, and the electronic device 100 does not need to change its access method to the second hotspot file. For example, if the electronic device 100 accesses the hotspot data of the second hotspot file via a pointer, it can point the pointer to the position where the first offset of the second target storage space is 0 (for example, position A in the target storage space shown in the figure, which corresponds to the position where the first offset of the second hotspot file is 0), and add the offset information of the hotspot data to be accessed to access the corresponding hotspot data. For example, the electronic device 100 can point the pointer to... Figure 8 The location with offset A in the target storage space shown (corresponding to the location where the first offset of the second hot file is 0) can be accessed by adding the first offset of hot data 44. The length of the accessed data can be set to the length of hot data 44.

[0137] In some embodiments, the first length may be the length of the overlapping region of one of the N hot zone data of the first hot file in the first storage space and one of the M second logical address spaces of the second hot file in the second storage space.

[0138] In other embodiments, the first length may also be the length of the largest overlapping region among multiple overlapping regions of multiple first logical address spaces in the N hot zone data of the first hot file in the first storage space and multiple second logical address spaces in the M second logical address spaces of the second hot file in the second storage space.

[0139] In other embodiments, the first length can also be other length values, such as Figure 8 The first length shown is the sum of the length values ​​of the hot zone data 44 and the cold zone data 45. It is understood that this application does not limit the length value of the first length, only requiring that the first length is a length value that indicates the non-overlapping length of any logical address space in the N logical address spaces of the first hot zone data of the first hot file and any logical address space in the M logical address spaces of the second hot file in the target storage space.

[0140] In some embodiments, the size of the target storage space is smaller than the sum of the sizes of the first target storage space and the second target storage space. That is, the first target storage space and the second target storage space at least partially overlap. In this way, the address information of at least one hot data point in the M hot data points of the second hot file in the target storage space can correspond to the address information of at least one cold data point in the first hot file in the first storage space, thereby reducing the unused memory space in locked pages and thus reducing the waste of memory resources.

[0141] In some embodiments, for ease of access, the electronic device 100 may also store the mapping relationship between the physical address and logical address of the data stored in the target storage space (N hot zone data of the first hot zone file and M hot zone data of the second hot zone file).

[0142] Understandable. Figure 5 The flowchart shown is just an example; in practical applications, Figure 5 The flowchart shown may also include more or fewer steps. This application does not limit this.

[0143] For example, in some embodiments, after S502 above, that is, after the electronic device 100 stores N hot zone data of the first hot zone file and M hot zone data of the second hot zone file into the target storage space in the memory of the electronic device and marks the target storage space as non-recyclable, if the electronic device 100 detects a first access request for at least one hot zone data of the first hot zone file, the electronic device 100 reads the first target data corresponding to the first access request from the target storage space.

[0144] Or, for example, in some other embodiments, after S502 above, that is, after the electronic device 100 stores the N hot zone data of the first hot zone file and the M hot zone data of the second hot zone file in the target storage space in the memory of the electronic device 100 and marks the target storage space as non-recyclable, if the electronic device 100 detects a recycling instruction, in response to the recycling instruction, the electronic device 100 stores the first hot zone file and the second hot zone file in the memory to the external storage space of the electronic device, that is, swaps out the memory pages corresponding to the first hot zone file and the second hot zone file to the external storage space of the electronic device.

[0145] For example, after the electronic device 100 stores the first hot file and the second hot file in memory to the external storage space of the electronic device, if the electronic device 100 detects a second access request for at least one cold zone data of the first hot file, and the first hot file is not stored in memory, the electronic device 100 reads the first hot file from the external storage device of the electronic device 100 into the memory of the electronic device 100, and reads the second target data corresponding to the second access request from the memory.

[0146] It is understandable that, in the event of insufficient memory, the electronic device 100 can reclaim the memory space occupied by the first and second hot files. Furthermore, after reclaiming the memory space occupied by the first and second hot files, the target storage space still stores the hot zone data of the first and second hot files. When the electronic device 100 detects an access request for the hot zone data of either the first or second hot file, it can directly read the corresponding target data from the target storage space.

[0147] Understandable. Figure 5The illustrated process uses only the first and second hot files as examples to illustrate the memory management method provided in this application. In other embodiments, the electronic device 100 can also acquire a third hot file and L hot zone data of the third hot file stored in the memory of the electronic device 100, and store the L hot zone data of the third hot file in a target storage space. Alternatively, the L hot zone data of the third hot file can be stored in a third target storage space, and the third target storage space can be marked as unrecoverable. The third target storage space includes the target storage space. Here, L is an integer greater than 0.

[0148] The method for determining the third hotspot file can refer to the methods for determining the first and second files mentioned above. The method for determining the L hotspot data of the third hotspot file can refer to the methods for determining the N hotspot data of the first hotspot file and the M hotspot data of the second hotspot file mentioned above. This application will not elaborate on these methods here.

[0149] In some embodiments, if the electronic device 100 stores L hot zone data of the third hot file in the target storage space, the address information of at least one hot zone data of the L hot zone data of the third hot file in the target storage space corresponds to the address information of the area in the target storage space other than the N hot zone data of the first hot file and the M hot zone data of the second hot file.

[0150] In some embodiments, if the electronic device 100 stores L hot zone data of the third hot file in the third target storage space, the address information of at least one hot zone data of the L hot zone data of the third hot file in the third target storage space corresponds to the address information of the area in the target storage space other than the N hot zone data of the first hot file and the M hot zone data of the second hot file.

[0151] In some embodiments, corresponding to the electronic device 100 storing L hotspot data of a third hotspot file in a target storage space: any one of the N+M logical address spaces and any one of the L third logical address spaces of the L hotspot data of the third hotspot file in the third storage space do not overlap; and the L logical address spaces of the L hotspot data of the third hotspot file in the target storage space are the same as the L third logical address spaces. The N+M logical address spaces are determined based on the N logical address spaces of the N hotspot data of the first hotspot file in the target storage space and the M logical address spaces of the M hotspot data of the second hotspot file in the target storage space, and the third storage space is the storage space for storing the third hotspot file.

[0152] In other words, if the N hot zone data of the first hot file and the M hot zone data of the second hot file do not overlap in any of the N+M logical address spaces in the target storage space and the L hot zone data of the third hot file do not overlap in any of the L third logical address spaces in the third storage space, the electronic device 100 stores the L hot zone data of the third hot file in the target storage space, wherein the L hot zone data of the third hot file are the same in the L logical address spaces and L third logical address spaces of the target storage space.

[0153] For example, to store Figure 4 Taking the first and second hottest files shown as examples, refer to... Figure 9 The diagram shows the storage of hotspot data for the third hotspot file.

[0154] like Figure 9 As shown, assuming the initial offset of hot zone data 11 in the target storage space is 0, and the initial offset of cold zone data 51 of the third hot file in the third storage space is 0. If any one of the logical address spaces of hot zone data 11, hot zone data 22, hot zone data 13, hot zone data 24, and hot zone data 15 in the target storage space does not overlap with the logical address space of hot zone data 52, then the electronic device 100 can directly store hot zone data 52 in the target storage space. Furthermore, the logical address space of hot zone data 52 in the target storage space is the same as the logical address space of hot zone data 52 in the corresponding storage space (third storage space) storing the third hot file.

[0155] In other embodiments, corresponding to the electronic device 100 storing L hotspot data of a third hotspot file in a third target storage space: at least one logical address space among N+M logical address spaces overlaps with at least one of the L third logical address spaces within the third storage space containing the L hotspot data of the third hotspot file; and the third target storage space includes a target storage space and a fourth target storage space. The fourth target storage space stores the L hotspot data of the third hotspot file, and the L hotspot data of the third hotspot file are identical to the L third logical address spaces within the fourth target storage space.

[0156] Furthermore, the base address of the fourth target storage space is the base address of the target storage space plus the second length. It can be understood that when the electronic device 100 stores the L hotspot data of the third hotspot file into the fourth target storage space determined by adding the second length to the base address of the target storage space, it ensures that any logical address space among the N+M logical address spaces and any logical address space among the L logical address spaces of the third hotspot file do not overlap. That is, the difference between the base address of the fourth target storage space and the base address of the target storage space is the second length, which is used to indicate the length by which any logical address space among the N+M logical address spaces and any logical address space among the L logical address spaces of the third hotspot file do not overlap.

[0157] In other words, if at least one logical address space in the N hot zone data of the first hot file and the M hot zone data of the second hot file overlaps with at least one third logical address space in the L logical address spaces of the third hot file within the third storage space, the electronic device 100 stores the L hot zone data of the third hot file in a fourth target storage space whose base address differs from the base address of the target storage space by a second length. Furthermore, the third target storage space includes both the target storage space and the fourth target storage space.

[0158] For example, to store Figure 4 Taking the first and second hottest files shown as examples, refer to... Figure 10 This is another storage diagram of the hot zone data of the third hotspot file.

[0159] like Figure 10 As shown, the initial offset of hot zone data 11 in the target storage space is 0, and the initial offset of cold zone data 61 of the third hot file in the third storage space is 0. The logical address space of hot zone data 22 in the target storage space overlaps with the logical address space of hot zone data 62 of the third hot file in the third storage space in region a, and the logical address space of hot zone data 24 in the target storage space overlaps with the logical address space of hot zone data 64 of the third hot file in the third storage space in region b. The electronic device 100 can store the hot zone data 62 and hot zone data 64 of the third hot file in the fourth target storage space. The difference between the base address of the fourth target storage space and the base address of the target storage space is the second length. Furthermore, the logical address space of hot zone data 62 and hot zone data 64 in the fourth target storage space is the same as the logical address space of hot zone data 62 and hot zone data 64 in the third storage space.

[0160] In some embodiments, the second length may be the length of the overlapping region of one logical address space in the N+M logical address spaces of the first hotspot file and the M hotspot files of the second hotspot file within the target storage space, and one third logical address space in the L third logical address spaces of the third hotspot file within the third storage space.

[0161] In other embodiments, the second length may also be the length of the maximum overlapping region among multiple overlapping regions of multiple logical address spaces in multiple logical address spaces of multiple logical address spaces in multiple logical address spaces of multiple third logical address spaces of multiple third logical address spaces in multiple logical address spaces of multiple third logical address spaces of multiple third logical address spaces of multiple hot zone data of the first hot zone file and M hot zone data of the second hot zone file in the target storage space and L hot zone data of the third hot zone file in the third storage space.

[0162] In other embodiments, the second length can also be other length values. It is understood that this application does not limit the length value of the second length, only requiring that the second length is a length value that indicates that the N hot zone data of the first hot file and the M hot zone data of the second hot file do not overlap in any one of the N+M logical address spaces of the target storage space, and that the L hot zone data of the third hot file do not overlap in any one of the L logical address spaces of the fourth target storage space.

[0163] It is understood that the memory management method provided in this application embodiment can be applied to electronic device 100 (as an example of an electronic device). Electronic device 100 can also be referred to as terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. Electronic device 100 can be a mobile phone, smart TV, wearable device, tablet computer, computer with wireless transceiver function, virtual reality (VR) device, augmented reality (AR) device, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, etc. This application does not limit the specific type of electronic device 100.

[0164] To better understand the technical solutions of the embodiments of this application, the devices involved in the embodiments of this application will be described below with reference to the accompanying drawings.

[0165] For example, Figure 11 A schematic diagram of the structure of an electronic device 100 is shown according to an embodiment of this application.

[0166] like Figure 11 As shown, the electronic device 100 may include a processor 110, a memory 120, an interface module 130, a power module 140, a wireless communication module 150, a mobile communication module 160, an audio module 170, a sensor module 180, buttons 190, a camera 191, a display screen 192, etc.

[0167] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0168] The processor 110 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU).

[0169] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory.

[0170] In this embodiment, the processor 110 can control the fetching and execution of instructions from the memory via a controller, so that the electronic device 100 can perform the above-described operations. Figure 5 The functions performed by the electronic device 100 in the illustrated implementation process are used to implement the memory management method provided in this application.

[0171] The power module 140 is connected to the processor 110 and provides power to the processor 110, memory 120, camera 191, display screen 192, and mobile communication module 160.

[0172] The wireless communication module 150 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (such as Wi-Fi networks), Bluetooth, global navigation satellite system (GNSS), frequency modulation (FM), NFC, infrared technology, etc.

[0173] The mobile communication module 160 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for use on electronic devices 100.

[0174] Audio module 170 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal. Audio module 170 can also be used for encoding and decoding audio signals.

[0175] The sensor module 180 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.

[0176] The display screen 192 is used to display images, videos, etc. In some embodiments, the electronic device 100 may include one or N display screens 192, where N is a positive integer greater than 1.

[0177] Camera 191 is used to capture still images or videos. In some embodiments, electronic device 100 may include one or N cameras 191, where N is a positive integer greater than 1.

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

[0179] Button 190 includes the power button, volume buttons, etc. Button 190 can be a mechanical button or a touch button.

[0180] Figure 12 A software structure block diagram of an electronic device 100 according to an embodiment of this application is shown.

[0181] like Figure 12 As shown, the software architecture of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses a layered architecture as an example to exemplify the software structure of electronic device 100.

[0182] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In the embodiments of this application, such as... Figure 12 As shown, the layered architecture of electronic device 100 includes: application layer, kernel layer, and hardware layer, etc.

[0183] The application layer can have multiple applications installed (e.g., application 1, application 2, etc. as shown in the diagram), as well as a hotspot file management service. Taking application 1 as an example, while the electronic device is running application 1, application 1 can initiate one or more access requests.

[0184] The hot file management service can identify hot files and hot zone data within them, as well as lock hot zone data within hot files.

[0185] The kernel layer can include a virtual file system (VFS), a page cache, a memory management module, an inode cache module, and a file system (or secondary file system).

[0186] The memory management module is used to store the hot zone data of the first hot file and the hot zone data of the second hot file in the target storage space, and to store the mapping relationship between the physical address and logical address of the hot zone data of the first hot file stored in the target storage space, as well as the mapping relationship between the physical address and logical address of the hot zone data of the second hot file stored in the target storage space, in the index node cache module.

[0187] The inode caching module is used to store the mapping relationship between the physical address and logical address of data already stored in the target storage space (such as hot zone data of the first hot file and hot zone data of the second hot file).

[0188] Page cache is a part of memory. Page cache uses memory as the storage medium to store file data in units of pages.

[0189] File systems can include extended file systems (ext4), journaling file systems (XFS), zeta file systems (ZFS), etc. Extended file systems (ext4) are used to provide file journaling functionality. It is understood that the file systems illustrated are merely examples; in practical applications, file systems can include more or fewer file systems or other types of file systems, and this application does not impose any limitations on this.

[0190] Below the application layer and kernel layer is the hardware layer, which consists of hardware devices that respond to various access requests, including various storage devices such as multimedia cards, embedded multimedia cards, SCSI hard drives, general-purpose flash storage, mechanical hard drives, disks, and network storage.

[0191] Understandable, compared to Figure 1 The software architecture of the electronic device shown is as follows: Figure 12 The software architecture of the illustrated electronic device 100 includes a hotspot file management service, a memory management module, and an inode caching module for implementing the methods provided in the embodiments of this application. In other embodiments, the methods provided in the embodiments of this application may also be implemented based on more or fewer modules, and this application does not limit this.

[0192] The following is combined with Figure 13 The software architecture of the electronic device 100 shown in this application describes the memory management method provided in the embodiments.

[0193] For example, Figure 13 An embodiment of this application illustrates an interactive flow diagram of a software module for implementing a memory management method.

[0194] like Figure 13 As shown, the process includes:

[0195] S1301: The first application (e.g., application 1) sends a request to the virtual file system to open the first hot file list.

[0196] The files in the first hot file list are those whose access count in the history of the first application exceeds the access count threshold, and / or those whose access frequency in the history of the first application exceeds the access frequency threshold.

[0197] S1302: The virtual file system sends a request to the file system to create a file page cache.

[0198] In some embodiments, after receiving a request to open the first hot file list, the virtual file system sends a request to the file system to create a file page cache, so that the file system stores the files in the first hot file list into the memory of the electronic device 100.

[0199] S1303: The file system creates a file page cache.

[0200] In some embodiments, the file system creates a file page and reads files from the external storage space of the electronic device 100 from the first hot file list into the created file page.

[0201] S1304: The file system sends a message to the virtual file system indicating that the creation is complete.

[0202] In some embodiments, after the file system reads the files from the first hot file list from the external storage space of the electronic device 100 into the created file page, it sends a message to the virtual file system indicating that the creation is complete.

[0203] S1305: The virtual file system sends a message to the first application that the file opening operation has been completed.

[0204] In some embodiments, after receiving a message indicating that the creation is complete, the virtual file system sends a message to the first application indicating that the file opening operation has been completed.

[0205] S1306: The first application sends a request to the hot file management service to lock the memory corresponding to the hot file.

[0206] In some embodiments, when the first application receives a message that the file opening is complete and has a need to lock memory, it sends a request to the hot file management service to lock the memory corresponding to the hot file.

[0207] S1307: The Hot File Management Service identifies hot files among multiple files in the first hot file list.

[0208] In some embodiments, after receiving a request to lock the memory corresponding to a hot file, the hot file management service identifies the hot file among multiple files in the first hot file list.

[0209] For specific methods of identifying hot files, please refer to the relevant description in the aforementioned S501, which will not be repeated here.

[0210] S1308: Hotspot file management service determines the hotspot data in each hotspot file.

[0211] In some embodiments, after identifying hot files, the hot file management service determines the hot zone data within each hot file.

[0212] For specific methods of determining hot zone data in the hotspot file, please refer to the relevant description in the aforementioned S501, which will not be repeated here.

[0213] S1309: The hot file management service sends a request to the virtual file system to lock the memory corresponding to the hot file.

[0214] In some embodiments, after the hot file management service identifies the hot data in each hot file, it sends a request to the virtual file system to lock the memory corresponding to the hot file.

[0215] S1310: The virtual file system sends a request to the memory management module to lock the memory corresponding to the hot file.

[0216] In some embodiments, after receiving a request to lock the memory corresponding to a hot file, the virtual file system sends the received request to the memory management module.

[0217] S1311: The memory management module determines the address information of the target storage space, as well as the address information of the hot zone data in each hot file that is stored in the target storage space.

[0218] In some embodiments, after receiving a request to lock the memory corresponding to a hot file, the memory management module determines the address information of the target storage space, as well as the address information of the hot zone data in each hot file stored in the target storage space. For example, it determines the address information of N hot zone data of the first hot file and M hot zone data of the second hot file in the target storage space.

[0219] S1312: The memory management module sends the address information of the target storage space, as well as the address information of the hot zone data in each hot file stored in the target storage space, to the file system.

[0220] In some embodiments, after the memory management module determines the address information of the target storage space and the address information of the hot zone data in each hot file stored in the target storage space, it sends the address information of the target storage space and the address information of the hot zone data in each hot file stored in the target storage space to the file system.

[0221] S1313: The file system stores the hot data of each hot file into the target storage space.

[0222] In some embodiments, after receiving the address information of the target storage space and the address information of the hot zone data of each hot file stored in the target storage space, the file system determines the target storage space based on the address information and allocates the target storage space for storing the hot zone data of each hot file. Furthermore, based on the address information of the target storage space corresponding to the hot zone data of each hot file, the file system stores the hot zone data of each hot file in the target storage space.

[0223] The specific methods for determining the target storage space and storing the N hot zone data of the first hot file and the M hot zone data of the second hot file into the target storage space can be referred to the relevant description in S502 above, and will not be repeated here.

[0224] S1314: The file system sends a message to the memory management module indicating successful storage.

[0225] In some embodiments, after the file system stores the hot data of each hot file into the target storage space, it sends a message to the memory management module indicating successful storage.

[0226] S1315: The memory management module determines the mapping relationship between the physical address and logical address of each hot zone data in the target storage space.

[0227] In some embodiments, after receiving a successful storage message, the memory management module determines the mapping relationship between the physical addresses and logical addresses of each hot zone data in the target storage space. For example, the memory management module determines the mapping relationship between the physical addresses and logical addresses of N hot zone data of the first hot file and M hot zone data of the second hot file in the aforementioned target storage space.

[0228] S1316: The memory management module sends the mapping relationship between the physical address and logical address of each hot zone data in the target storage space to the virtual file system.

[0229] In some embodiments, after determining the mapping relationship between the physical addresses and logical addresses of the data in each hot zone of the target storage space, the memory management module sends the mapping relationship between the physical addresses and logical addresses of the data in each hot zone of the target storage space to the virtual file system.

[0230] S1317: The virtual file system sends a message to the hot file management service indicating successful storage.

[0231] In some embodiments, after receiving the mapping relationship between the physical addresses and logical addresses of the data in each hot zone of the target storage space, the virtual file system sends a message of successful storage to the hot file management service.

[0232] S1318: The first application sends a request to the virtual file system to access hotspot data.

[0233] S1319: The virtual file system determines the address information in the target storage space corresponding to the hot area data to be accessed.

[0234] In some embodiments, the virtual file system receives a request to access hot zone data and detects that the hot zone data is stored in the target storage space, and determines the address information in the target storage space corresponding to the hot zone data to be accessed.

[0235] S1320: The virtual file system sends the address information of the target storage space corresponding to the hot area data to be accessed to the memory management module.

[0236] In some embodiments, after the virtual file system determines the address information in the target storage space corresponding to the hot zone data to be accessed, it sends the address information in the target storage space corresponding to the hot zone data to be accessed to the memory management module.

[0237] S1321: The memory management module sends the address information of the target storage space corresponding to the hot area data to be accessed to the file system.

[0238] In some embodiments, after receiving the address information in the target storage space corresponding to the hot zone data to be accessed, the memory management module sends the address information in the target storage space corresponding to the hot zone data to the file system.

[0239] S1322: The file system reads the corresponding target data from the target storage space based on the address information in the target storage space corresponding to the hot zone data to be accessed.

[0240] In some embodiments, after the file system receives the address information in the target storage space corresponding to the hot zone data to be accessed, it reads the corresponding target data (such as the aforementioned first target data) from the target storage space based on the address information in the target storage space corresponding to the hot zone data to be accessed.

[0241] S1323: The file system sends the target data to the memory management module.

[0242] In some embodiments, after the file system reads the target data, it sends the target data to the memory management module.

[0243] S1324: The memory management module sends the target data to the virtual file system.

[0244] In some cases, it's about capability. After receiving the target data, the memory management module sends the target data to the virtual file system.

[0245] S1325: The virtual file system sends the target data to the first application.

[0246] In some embodiments, after receiving the target data, the virtual file system sends the target data to the first application.

[0247] Understandable. Figure 13 The interaction flow shown is only one example; in other embodiments, Figure 13 The interactive process shown may include more or fewer steps, and this application does not limit this.

[0248] To facilitate better implementation of the above-described solutions in the embodiments of this application, the embodiments of this application also provide a related apparatus for implementing the above-described solutions.

[0249] For example, Figure 14 A schematic diagram of the structure of a communication device is shown according to an embodiment of this application.

[0250] like Figure 14 As shown, the communication device 200 may include a processing module 201 (sometimes also called a processing unit) and a storage module 202 (sometimes also called a storage unit) for storing any data, computer instructions and / or computer programs that may be involved in the various embodiments of this application.

[0251] In some possible implementations, the communication device 200 provided in this application embodiment further includes: a transceiver module (sometimes also called a transceiver unit). The transceiver module is capable of performing both sending and receiving functions. When the transceiver module performs the sending function, it can be called a sending module (sometimes also called a sending unit), and when the transceiver module performs the receiving function, it can be called a receiving module (sometimes also called a receiving unit). The sending module and the receiving module can be the same functional module, which is called the transceiver module and can perform both sending and receiving functions; or, the sending module and the receiving module can be different functional modules, and the transceiver module is a collective term for these functional modules.

[0252] The following describes the various modules in the communication device 200, which is used to implement the functions of the electronic device 100 in the above method embodiments:

[0253] When the communication device 200 is used to implement Figure 5 In the illustrated method embodiment, when the electronic device functions, the processing module 501 is used to store a first hotspot file and N hotspot data points of the first hotspot file, as well as a second hotspot file and M hotspot data points of the second hotspot file in the electronic device's memory. A hotspot file is a file whose access count within a first time interval exceeds a first access threshold. Hotspot data points are data storing the corresponding hotspot file whose access count within the first time interval exceeds a second access threshold, where the second access threshold is less than or equal to the first access threshold. N is a positive integer, and M is a positive integer. The processing module 501 is also used to store the N hotspot data points of the first hotspot file and the M hotspot data points of the second hotspot file in a target storage space within the electronic device's memory, and to mark the target storage space as non-reclaimable. The address information of at least one hotspot data point in the M hotspot data points of the second hotspot file in the target storage space corresponds to the address information of at least one coldspot data point in the first hotspot file in the first storage space. The first storage space is the storage space for the first hotspot file, and the coldspot data points are data storing the corresponding hotspot file whose access count within the first time interval is less than or equal to the second access threshold. Storage module 202 is used to store any data, computer instructions and / or computer programs involved in the processing of the above-mentioned processing module 201.

[0254] It is understood that a more detailed description of the aforementioned processing module 201 and storage module 202 can be found in [reference needed]. Figure 5 The relevant descriptions in the illustrated method embodiments are not repeated here.

[0255] It should be noted that, in this application, the physical device corresponding to the processing module is a processor, and the physical device corresponding to the storage module is a memory.

[0256] This application also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, which is loaded and executed by a processor to implement the memory management methods provided in the above-described method embodiments.

[0257] This application also provides a program product that includes instructions that, when executed by a device, enable the device to implement the memory management method provided in this application.

[0258] In some embodiments, a chip is also provided, the chip including a processor coupled to a memory for executing computer programs or instructions stored in the memory, such that the chip implements the memory management methods provided in the above-described method embodiments.

[0259] 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 or stored thereon on one or more temporary or non-temporary 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 through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, optical discs, magneto-optical disks, read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in the form of electrical, optical, acoustic, or other forms of propagated signals. Therefore, machine-readable media include any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.

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

[0261] It should be noted that all units / modules mentioned in the device embodiments of this application are logical units / modules. Physically, a logical unit / module can be a physical unit / module, a part of a physical unit / module, or a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important factor; the combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed in this application. Furthermore, to highlight the innovative aspects of this application, the above-described device embodiments of this application have not introduced units / modules that are not closely related to solving the technical problems proposed in this application. This does not mean that the above-described device embodiments do not contain other units / modules.

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

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

Claims

1. A memory management method, characterized in that, Applied to electronic devices, the method includes: Obtain N hot zone data of a first hot file and M hot zone data of a second hot file stored in the memory of the electronic device. The hot file is a file whose access count is greater than a first threshold in a first time interval. The hot zone data is data that stores the corresponding hot file and whose access count is greater than a second threshold in the first time interval. The second threshold is less than or equal to the first threshold. N is an integer greater than 0 and M is an integer greater than 0. The N hot zone data of the first hot file and the M hot zone data of the second hot file are stored in the target storage space in the memory, and the target storage space is marked as non-reclaimable. The address information of at least one hot zone data of the M hot zone data of the second hot file in the target storage space corresponds to the address information of at least one cold zone data of the first hot file in the first storage space in the memory. The first storage space is the storage space for storing the first hot file. The cold zone data is the data that stores the corresponding hot file and whose access count within the first time interval is less than or equal to the second access count threshold.

2. The method according to claim 1, characterized in that, Each hot file includes one or more file pages, each file page having a first size, and the target storage space having a size that is an integer multiple of the first size.

3. The method according to claim 1 or 2, characterized in that, The N hot zone data of the first hot file do not overlap with any of the N first logical address spaces in the first storage space and any of the M second logical address spaces in the second storage space containing the M hot zone data of the second hot file, wherein the second storage space is the storage space for storing the second hot file; and... The N hot zone data of the first hot file are identical to the N logical address spaces in the target storage space and the N first logical address spaces, and the M hot zone data of the second hot file are identical to the M logical address spaces in the target storage space and the M second logical address spaces.

4. The method according to claim 1 or 2, characterized in that, The step of storing N hot zone data from the first hot zone file and M hot zone data from the second hot zone file into the target storage space in memory includes: The N hot zone data of the first hot file are stored in the first target storage space of the target storage space, wherein the N hot zone data of the first hot file in the N logical address spaces of the first target storage space are the same as the N first logical address spaces of the N hot zone data of the first hot file in the first storage space. The M hot zone data of the second hot file are stored in the second target storage space within the target storage space. The M hot zone data of the second hot file resides in the same M logical address spaces within the second target storage space as the M second logical address spaces within the second storage space. The second storage space is the storage space for storing the second hot file. At least one of the N first logical address spaces overlaps with at least one of the M second logical address spaces, and... The base address of the second target storage space is the base address of the first target storage space plus the first length.

5. The method according to claim 3 or 4, characterized in that, The logical address space of the hot zone data in the corresponding storage space is determined based on the following parameters: the initial offset of the hot zone data relative to the base address of the storage space and the data length of the hot zone data.

6. The method according to any one of claims 1 to 5, characterized in that, The number of accesses within the first time interval is determined based on the number of times the file pages of the hot files are read into memory within the first time interval; or, The number of accesses within the first time interval is determined based on the number of access requests for the address information of the storage space storing the hot files within the first time interval.

7. The method according to any one of claims 1 to 6, characterized in that, The step of acquiring N hotspot data of a first hotspot file and M hotspot data of a second hotspot file stored in the memory of the electronic device includes: The data stored in the N first sub-storage spaces with access counts greater than the second access threshold are designated as the N hot zones of the first hot file; the data stored in the M second sub-storage spaces with access counts greater than the second access threshold are designated as the M hot zones of the second hot file; wherein, The first storage space includes the N first sub-storage spaces, and the second storage space includes the M second sub-storage spaces. The second storage space is the storage space for storing the second hot file. The first sub-storage space is determined based on the address information of multiple first data access requests, which are multiple access requests within the first time interval that include the address information of the first storage space storing the first hot file. The second sub-storage space is determined based on the address information of multiple second data access requests, which are multiple access requests within the first time interval that include the address information of the second storage space storing the second hot file.

8. The method according to any one of claims 1 to 7, characterized in that, The method further includes: A first access request for at least one hotspot data of the first hotspot file was detected. Read the first target data corresponding to the first access request from the target storage space.

9. The method according to any one of claims 1 to 8, characterized in that, The method further includes: In response to a recycling command, the first hot file and the second hot file in the memory are stored in the external storage space of the electronic device.

10. The method according to claim 9, characterized in that, The method further includes: A second access request for at least one cold zone data of the first hot file is detected, and the first hot file is not stored in the memory of the electronic device; The first hot file is read from the external storage space of the electronic device into the memory, and the second target data corresponding to the second access request is read from the memory.

11. The method according to any one of claims 1 to 10, characterized in that, The method further includes: Obtain a third hotspot file and L hotspot data of the third hotspot file stored in the memory of the electronic device, where L is an integer greater than 0; Store the L hotspot data of the third hotspot file into the target storage space; or... The L hot zone data of the third hot file are stored in the third target storage space, and the third target storage space is marked as non-recoverable, wherein the third target storage space includes the target storage space.

12. The method according to claim 11, characterized in that, The address information of at least one hot zone data in the L hot zone data of the third hot zone file in the target storage space corresponds to the address information of a region in the target storage space other than the N hot zone data of the first hot zone file and the M hot zone data of the second hot zone file; or, The address information of at least one hot zone data in the L hot zone data of the third hot zone file in the third target storage space corresponds to the address information of the area in the target storage space other than the N hot zone data of the first hot zone file and the M hot zone data of the second hot zone file.

13. The method according to claim 11 or 12, characterized in that, Any one of the N+M logical address spaces and any one of the L third logical address spaces within the third storage space containing the L hotspot data of the third hotspot file do not overlap. The N+M logical address spaces are determined based on the N logical address spaces within the target storage space containing the N hotspot data of the first hotspot file and the M logical address spaces within the target storage space containing the M hotspot data of the second hotspot file. The third storage space is the storage space for storing the third hotspot file. The L hot zone data of the third hot file are the same as the L logical address spaces of the target storage space.

14. The method according to claim 11 or 12, characterized in that, At least one logical address space from N+M logical address spaces overlaps with at least one third logical address space from L hot zone data of the third hot file within the third storage space. The N+M logical address spaces are determined based on the N logical address spaces of the first hot file's N hot zone data in the target storage space and the M logical address spaces of the second hot file's M hot zone data in the target storage space. The third storage space is the storage space for the third hot file. The fourth target storage space in the third target storage space stores L hot zone data of the third hot file, wherein the L hot zone data of the third hot file are the same in the L logical address spaces of the fourth target storage space as the L third logical address spaces, and the base address of the fourth target storage space is the base address of the target storage space plus the second length.

15. An electronic device, characterized in that, include: A memory for storing instructions executed by one or more processing units of the electronic device; as well as The processor is one of the processors of the electronic device, used to execute instructions stored in the memory to implement the method of any one of claims 1 to 14.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on the device, cause the device to perform the method of any one of claims 1 to 14.

17. A computer program product, characterized in that, The computer program product includes instructions that, when executed on the device, cause the device to perform the method of any one of claims 1 to 14.

18. A communication device, characterized in that, Includes a module for performing the method as described in any one of claims 1 to 14.

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