CN116243850B - Memory management method and electronic equipment - Google Patents
Memory management method and electronic equipment Download PDFInfo
- Publication number
- CN116243850B CN116243850B CN202211549506.9A CN202211549506A CN116243850B CN 116243850 B CN116243850 B CN 116243850B CN 202211549506 A CN202211549506 A CN 202211549506A CN 116243850 B CN116243850 B CN 116243850B
- Authority
- CN
- China
- Prior art keywords
- memory
- data
- storage space
- electronic device
- compressed
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0608—Saving storage space on storage systems
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0629—Configuration or reconfiguration of storage systems
- G06F3/0631—Configuration or reconfiguration of storage systems by allocating resources to storage systems
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/0644—Management of space entities, e.g. partitions, extents, pools
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/10—Providing a specific technical effect
- G06F2212/1041—Resource optimization
- G06F2212/1044—Space efficiency improvement
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/17—Embedded application
- G06F2212/171—Portable consumer electronics, e.g. mobile phone
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/40—Specific encoding of data in memory or cache
- G06F2212/401—Compressed data
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Memory System Of A Hierarchy Structure (AREA)
- Memory System (AREA)
Abstract
本申请提供一种存储器管理方法及电子设备,涉及计算机技术领域,解决了在用户开启的应用较多的情况下,电子设备换出的数据逐渐增多,压缩后的数据会占用大量的存储空间,导致RAM剩余的存储空间仍较少的问题。该方法包括:在第一存储器的可用存储空间小于第一阈值的情况下,电子设备将数据中的第一数据压缩后存储在第一存储器中;电子设备释放压缩前第一数据占用的存储空间;在第一存储器中压缩后的数据占用的存储空间大于第二阈值的情况下,电子设备将第二数据存储在第二存储器,第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据,第一存储器中压缩后的数据包括第一数据;电子设备释放第二数据占用的存储空间。
The present application provides a memory management method and electronic device, which relates to the field of computer technology, and solves the problem that when a user opens many applications, the data swapped out by the electronic device gradually increases, and the compressed data will occupy a large amount of storage space, resulting in less remaining storage space in the RAM. The method includes: when the available storage space of the first memory is less than a first threshold, the electronic device compresses the first data in the data and stores it in the first memory; the electronic device releases the storage space occupied by the first data before compression; when the storage space occupied by the compressed data in the first memory is greater than a second threshold, the electronic device stores the second data in the second memory, the second data is the data whose compression rate meets the threshold condition in the compressed data in the first memory, and the compressed data in the first memory includes the first data; the electronic device releases the storage space occupied by the second data.
Description
本申请要求于2021年06月08日提交国家知识产权局、申请号为202110640318.6、申请名称为“一种存储器管理方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on June 8, 2021, with application number 202110640318.6 and application name “A Memory Management Method and Electronic Device”, all contents of which are incorporated by reference in this application.
本申请是分案申请,原申请的申请号是202110751464.6,原申请日是2021年7月2日,原申请的全部内容通过引用结合在本申请中。This application is a divisional application. The application number of the original application is 202110751464.6, and the original application date is July 2, 2021. The entire contents of the original application are incorporated into this application by reference.
技术领域Technical Field
本申请涉及计算机技术领域,尤其涉及一种存储器管理方法及电子设备。The present application relates to the field of computer technology, and in particular to a memory management method and an electronic device.
背景技术Background technique
目前,用户可通过在如手机等电子设备中安装应用程序(以下简称为应用),以丰富其功能。如,手机中安装了视频应用,手机在接收到用户开启该视频应用的操作后,可在前台显示该视频应用的界面,供用户使用其对应功能,如观看视频。之后,在用户需切换至其他应用或桌面时,可通过执行对应操作,将该视频应用切换到后台运行。一般的,在应用开启时,电子设备可为其分配用于存储该应用的相关数据的存储空间。在该应用切换到后台运行时,其仍会继续占用该存储空间,用于存储相关数据,如切换到后台运行前最后显示界面的数据,以便在用户将该应用切换到前台运行时能及时显示界面供用户查看。若用户打开了多个的应用,并在使用后未关闭(如切换至后台运行),此时手机会保存用户打开的每个应用的相关数据,导致随机存取存储器(random access memory,RAM)中的大量存储空间被后台运行的应用所占用,进而使得RAM的可用存储空间较低。At present, users can install application programs (hereinafter referred to as applications) in electronic devices such as mobile phones to enrich their functions. For example, a video application is installed in a mobile phone. After receiving the user's operation to open the video application, the mobile phone can display the interface of the video application in the foreground for the user to use its corresponding functions, such as watching videos. Afterwards, when the user needs to switch to other applications or desktops, the video application can be switched to the background by performing corresponding operations. Generally, when the application is turned on, the electronic device can allocate storage space for storing relevant data of the application. When the application is switched to the background, it will continue to occupy the storage space for storing relevant data, such as the data of the last displayed interface before switching to the background, so that when the user switches the application to the foreground, the interface can be displayed in time for the user to view. If the user opens multiple applications and does not close them after use (such as switching to the background), the mobile phone will save the relevant data of each application opened by the user, resulting in a large amount of storage space in the random access memory (RAM) being occupied by the background running applications, thereby making the available storage space of the RAM low.
发明内容Summary of the invention
本申请提供一种存储器管理方法及电子设备,解决了在用户开启的应用较多的情况下,电子设备换出的数据逐渐增多,压缩后的数据会占用大量的存储空间,导致RAM剩余的存储空间仍较少的问题。The present application provides a memory management method and electronic device, which solves the problem that when a user opens many applications, the data swapped out by the electronic device gradually increases, and the compressed data takes up a large amount of storage space, resulting in less remaining storage space in the RAM.
为达到上述目的,本申请采用如下技术方案:In order to achieve the above objectives, this application adopts the following technical solutions:
第一方面,本申请实施例提供存储器管理方法,应用于电子设备,电子设备包括第一存储器和第二存储器,第一存储器中存储有在后台运行的应用的数据;该方法包括:在第一存储器的可用存储空间小于第一阈值的情况下,电子设备将数据中的第一数据压缩后存储在第一存储器中;电子设备释放压缩前第一数据占用的存储空间;在第一存储器中压缩后的数据占用的存储空间大于第二阈值的情况下,电子设备将第二数据存储在第二存储器,第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据,第一存储器中压缩后的数据包括第一数据;电子设备释放第二数据占用的存储空间。In a first aspect, an embodiment of the present application provides a memory management method, which is applied to an electronic device, wherein the electronic device includes a first memory and a second memory, and the first memory stores data of an application running in the background; the method includes: when the available storage space of the first memory is less than a first threshold, the electronic device compresses the first data in the data and stores it in the first memory; the electronic device releases the storage space occupied by the first data before compression; when the storage space occupied by the compressed data in the first memory is greater than a second threshold, the electronic device stores the second data in the second memory, the second data being the data in the compressed data in the first memory whose compression rate meets the threshold condition, and the compressed data in the first memory includes the first data; the electronic device releases the storage space occupied by the second data.
在上述实施例中,在第一存储器的可用存储空间小于第一阈值的情况下,电子设备将数据中的第一数据压缩后存储在第一存储器中,并释放压缩前第一数据占用的存储空间。由于压缩后的数据所占用的存储空间小于压缩前的数据所占用的存储空间,因此可以释放出更多存储空间。之后,在第一存储器中压缩后的数据占用的存储空间大于第二阈值的情况下,说明此时第一存储器中存储的压缩后的第一冷数据过多,导致第一存储器的可用存储空间较小。为此,本申请实施例提供的存储器管理方法,通过将第一存储器中压缩后的数据中压缩率满足阈值条件的数据存储在第二存储器。从而使得第一存储器中存储的第一数据更小,同时电子设备释放第二数据占用的存储空间,如此使得第一存储器的可用存储空间更大。解决了在用户开启的应用较多的情况下,电子设备100换出的数据逐渐增多,压缩后的数据会占用大量的存储空间,导致RAM剩余的存储空间仍较少的问题。In the above embodiment, when the available storage space of the first memory is less than the first threshold, the electronic device compresses the first data in the data and stores it in the first memory, and releases the storage space occupied by the first data before compression. Since the storage space occupied by the compressed data is less than the storage space occupied by the data before compression, more storage space can be released. Afterwards, when the storage space occupied by the compressed data in the first memory is greater than the second threshold, it means that there are too many compressed first cold data stored in the first memory at this time, resulting in a small available storage space in the first memory. To this end, the memory management method provided by the embodiment of the present application is to store the data whose compression rate meets the threshold condition in the compressed data in the first memory in the second memory. Thereby, the first data stored in the first memory is smaller, and the electronic device releases the storage space occupied by the second data, so that the available storage space of the first memory is larger. It solves the problem that when the user opens more applications, the data swapped out by the electronic device 100 gradually increases, and the compressed data will occupy a large amount of storage space, resulting in less remaining storage space in the RAM.
结合第一方面,在一种可能实现方式中,电子设备将数据中的第一数据压缩后存储在第一存储器中,包括:电子设备对第一数据进行压缩;电子设备将压缩后的第一数据以交换单元的形式存储在第一存储器中;其中,同一交换单元中的压缩后的第一数据的压缩率差值小于第三阈值。In combination with the first aspect, in a possible implementation, the electronic device compresses the first data in the data and stores it in the first memory, including: the electronic device compresses the first data; the electronic device stores the compressed first data in the form of an exchange unit in the first memory; wherein the compression rate difference of the compressed first data in the same exchange unit is less than a third threshold.
在上述实施例中,通过将压缩率差值小于第三阈值的第一数据存储在同一交换单元,从而可以更加方便地对第一数据进行管理。同时,在交换单元大小相同的情况下,对应第一数据的压缩率越高,该交换单元内存储的第一数据越少,这样该交换单元的换入概率越低,从而可以降低由于换入换出造成数据颠簸的问题。In the above embodiment, by storing the first data whose compression ratio difference is less than the third threshold value in the same exchange unit, the first data can be managed more conveniently. At the same time, when the exchange units are of the same size, the higher the compression ratio of the corresponding first data, the less the first data stored in the exchange unit, so the probability of the exchange unit being swapped in is lower, thereby reducing the problem of data jitter caused by swapping in and out.
结合第一方面,在一种可能实现方式中,电子设备将第二数据存储在第二存储器,包括:电子设备确定压缩率大于第四阈值的交换单元中所有压缩后的第一数据为第二数据;电子设备将第二数据存储在第二存储器;其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的。In combination with the first aspect, in a possible implementation, the electronic device stores the second data in a second memory, including: the electronic device determines that all compressed first data in an exchange unit whose compression rate is greater than a fourth threshold is the second data; the electronic device stores the second data in the second memory; wherein the compression rate of each exchange unit is determined based on the compression rate of the compressed first data in the exchange unit.
在上述实施例中,交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的。如此,在交换单元大小相同的情况下,该交换单元对应的压缩率越大,说明该交换单元内存储的第一数据越少,这样该交换单元的换入概率越低,从而可以降低由于换入换出造成数据颠簸的问题。In the above embodiment, the compression rate of the exchange unit is determined according to the compression rate of the first data compressed in the exchange unit. Thus, when the exchange units are of the same size, the greater the compression rate corresponding to the exchange unit, the less the first data stored in the exchange unit, and thus the lower the probability of swapping in the exchange unit, thereby reducing the problem of data jitter caused by swapping in and out.
结合第一方面,在一种可能实现方式中,电子设备将第二数据存储在第二存储器,包括:电子设备确定压缩率大于第四阈值,且换入概率小于第五阈值的交换单元中所有压缩后的第一数据为第二数据;电子设备将第二数据存储在第二存储器;其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的,各交换单元的换入概率是根据交换单元中压缩后的第一数据被访问的概率确定的。In combination with the first aspect, in a possible implementation, the electronic device stores the second data in a second memory, including: the electronic device determines that all compressed first data in the switching units whose compression rate is greater than a fourth threshold and whose swap-in probability is less than a fifth threshold are second data; the electronic device stores the second data in the second memory; wherein the compression rate of each switching unit is determined based on the compression rate of the compressed first data in the switching unit, and the swap-in probability of each switching unit is determined based on the probability of the compressed first data in the switching unit being accessed.
在上述实施例中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的,各交换单元的换入概率是根据交换单元中压缩后的第一数据被访问的概率确定的。如此,在交换单元大小相同的情况下,该交换单元对应的压缩率越大,说明该交换单元内存储的第一数据越少,这样该交换单元的换入概率越低,从而可以降低由于换入换出造成数据颠簸的问题。In the above embodiment, the compression rate of each exchange unit is determined according to the compression rate of the first data compressed in the exchange unit, and the swap-in probability of each exchange unit is determined according to the probability of the first data compressed in the exchange unit being accessed. In this way, when the exchange units are of the same size, the larger the compression rate corresponding to the exchange unit, the less the first data stored in the exchange unit, and thus the lower the swap-in probability of the exchange unit, thereby reducing the problem of data jitter caused by swapping in and out.
结合第一方面,在一种可能实现方式中,电子设备将第二数据存储在第二存储器,包括:电子设备根据各交换单元的压缩率,确定第二数据依次为按照从大到小的顺序将交换单元中压缩后的第一数据;电子设备依次将第二数据存储在第二存储器中,直至第一存储器的可用存储空间大于第一阈值。In combination with the first aspect, in a possible implementation, the electronic device stores the second data in a second memory, including: the electronic device determines, based on the compression rate of each exchange unit, that the second data is the first data compressed in the exchange unit in order from large to small; the electronic device stores the second data in the second memory in sequence until the available storage space of the first memory is greater than a first threshold.
在上述实施例中,依次根据每个交换单元对应的压缩率,按照从大到小的顺序将交换单元存储在第二存储器中,直至第一存储器的可用存储空间大于第一阈值。如此。在交换单元大小相同的情况下,对应第一数据的压缩率越高,该交换单元内存储的第一数据越少,这样该交换单元的换入概率越低,从而可以降低由于换入换出造成数据颠簸的问题。In the above embodiment, the exchange units are stored in the second memory in descending order according to the compression rate corresponding to each exchange unit, until the available storage space of the first memory is greater than the first threshold. In this way. When the exchange units are of the same size, the higher the compression rate of the corresponding first data, the less the first data stored in the exchange unit, so that the probability of the exchange unit being swapped in is lower, thereby reducing the problem of data jitter caused by swapping in and out.
结合第一方面,在一种可能实现方式中,第一存储器为内存,第二存储器为外部存储器。In combination with the first aspect, in a possible implementation, the first memory is a memory, and the second memory is an external memory.
结合第一方面,在一种可能实现方式中,电子设备包括ZRAM块设备,zspage模块,交换(Swap)块设备和内存管理模块,方法包括:内存管理模块在第一存储器的可用存储空间小于第一阈值的情况下,通过ZRAM块设备将数据中的第一数据存储至第一存储器设置的交换空间(Swap space);ZRAM块设备对Swap space中的第一数据进行压缩,并将压缩后的第一数据发送中至zspage模块;zspage模块将压缩后的第一数据存储在第一存储器中;内存管理模块释放压缩前第一数据占用的存储空间;ZRAM块设备在第一存储器中压缩后的数据占用的存储空间大于第二阈值的情况下,通过接口通知Swap块设备;Swap块设备通过接口从zspage模块中获取第二数据;zspage模块确定第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据;zspage模块将第二数据发送给Swap块设备;Swap块设备将第二数据存储在第二存储器,第一存储器中压缩后的数据包括第一数据;内存管理模块释放第二数据占用的存储空间。In combination with the first aspect, in a possible implementation, an electronic device includes a ZRAM block device, a zspage module, a swap block device and a memory management module, and the method includes: when the available storage space of the first memory is less than a first threshold, the memory management module stores the first data in the data in the swap space (Swap space) set in the first memory through the ZRAM block device; the ZRAM block device compresses the first data in the Swap space and sends the compressed first data to the zspage module; the zspage module stores the compressed first data in the first memory; the memory management module releases the storage space occupied by the first data before compression; when the storage space occupied by the compressed data in the first memory by the ZRAM block device is greater than a second threshold, the Swap block device is notified through an interface; the Swap block device obtains the second data from the zspage module through the interface; the zspage module determines that the second data is the data whose compression rate meets the threshold condition in the compressed data in the first memory; the zspage module sends the second data to the Swap block device; the Swap block device stores the second data in the second memory, and the compressed data in the first memory includes the first data; the memory management module releases the storage space occupied by the second data.
在上述实施例中,内存管理模块在第一存储器的可用存储空间小于第一阈值的情况下,通过ZRAM块设备将数据中的第一数据存储至第一存储器设置的Swap space;ZRAM块设备对Swap space中的第一数据进行压缩,并将压缩后的第一数据发送中至zspage模块;zspage模块将压缩后的第一数据存储在第一存储器中;内存管理模块释放压缩前第一数据占用的存储空间。由于压缩后的数据所占用的存储空间小于压缩前的数据所占用的存储空间,因此可以释放出更多存储空间。之后,ZRAM块设备在第一存储器中压缩后的数据占用的存储空间大于第二阈值的情况下,说明此时第一存储器中存储的压缩后的第一冷数据过多,导致第一存储器的可用存储空间较小。为此,本申请实施例提供的存储器管理方法,ZRAM块设备通过接口通知Swap块设备;Swap块设备通过接口从zspage模块中获取第二数据;zspage模块确定第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据;zspage模块将第二数据发送给Swap块设备;Swap块设备将第二数据存储在第二存储器,第一存储器中压缩后的数据包括第一数据;内存管理模块释放第二数据占用的存储空间,使得第一存储器中存储的第一数据更小,同时电子设备释放第二数据占用的存储空间,如此使得第一存储器的可用存储空间更大。In the above embodiment, when the available storage space of the first memory is less than the first threshold, the memory management module stores the first data in the data to the Swap space set in the first memory through the ZRAM block device; the ZRAM block device compresses the first data in the Swap space and sends the compressed first data to the zspage module; the zspage module stores the compressed first data in the first memory; the memory management module releases the storage space occupied by the first data before compression. Since the storage space occupied by the compressed data is less than the storage space occupied by the data before compression, more storage space can be released. Afterwards, when the storage space occupied by the compressed data in the first memory by the ZRAM block device is greater than the second threshold, it means that there are too many compressed first cold data stored in the first memory at this time, resulting in a small available storage space in the first memory. To this end, the memory management method provided in the embodiment of the present application is as follows: the ZRAM block device notifies the Swap block device through an interface; the Swap block device obtains the second data from the zspage module through the interface; the zspage module determines that the second data is data whose compression rate meets the threshold condition in the compressed data in the first memory; the zspage module sends the second data to the Swap block device; the Swap block device stores the second data in the second memory, and the compressed data in the first memory includes the first data; the memory management module releases the storage space occupied by the second data, so that the first data stored in the first memory is smaller, and at the same time the electronic device releases the storage space occupied by the second data, so that the available storage space of the first memory is larger.
结合第一方面,在一种可能实现方式中,zspage模块将压缩后的第一数据存储在第一存储器中,包括:zspage模块将压缩后的第一数据以交换单元的形式存储在第一存储器中;其中,同一交换单元中的压缩后的第一数据的压缩率差值小于第三阈值。In combination with the first aspect, in a possible implementation, the zspage module stores the compressed first data in the first memory, including: the zspage module stores the compressed first data in the first memory in the form of an exchange unit; wherein the compression rate difference of the compressed first data in the same exchange unit is less than a third threshold.
在上述实施例中,zspage模块通过将压缩率差值小于第三阈值的第一数据存储在同一交换单元,从而可以更加方便地对第一数据进行管理。同时,在交换单元大小相同的情况下,对应第一数据的压缩率越高,该交换单元内存储的第一数据越少,这样该交换单元的换入概率越低,从而可以降低由于换入换出造成数据颠簸的问题。In the above embodiment, the zspage module stores the first data whose compression ratio difference is less than the third threshold value in the same exchange unit, so that the first data can be managed more conveniently. At the same time, when the exchange units are of the same size, the higher the compression ratio of the corresponding first data, the less the first data stored in the exchange unit, so that the probability of swapping in the exchange unit is lower, thereby reducing the problem of data jitter caused by swapping in and out.
结合第一方面,在一种可能实现方式中,zspage模块确定第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据,包括:zspage模块确定第二数据为压缩率大于第四阈值的交换单元中所有压缩后的第一数据;其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的。In combination with the first aspect, in a possible implementation, the zspage module determines that the second data is data in the compressed data in the first memory whose compression rate meets the threshold condition, including: the zspage module determines that the second data is all compressed first data in the exchange unit whose compression rate is greater than a fourth threshold; wherein the compression rate of each exchange unit is determined based on the compression rate of the compressed first data in the exchange unit.
在上述实施例中,各交换单元的压缩率zspage模块是根据交换单元中压缩后的第一数据的压缩率确定的,各交换单元的换入概率是根据交换单元中压缩后的第一数据被访问的概率确定的。如此,在交换单元大小相同的情况下,该交换单元对应的压缩率越大,说明该交换单元内存储的第一数据越少,这样该交换单元的换入概率越低,从而可以降低由于换入换出造成数据颠簸的问题。In the above embodiment, the compression rate zspage module of each exchange unit is determined according to the compression rate of the first data compressed in the exchange unit, and the swap-in probability of each exchange unit is determined according to the probability of the first data compressed in the exchange unit being accessed. In this way, when the exchange units are of the same size, the larger the compression rate corresponding to the exchange unit, the less the first data stored in the exchange unit, and thus the lower the swap-in probability of the exchange unit, thereby reducing the problem of data jitter caused by swapping in and out.
结合第一方面,在一种可能实现方式中,zspage模块确定第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据,包括:zspage模块确定第二数据为压缩率大于第四阈值,且换入概率小于第五阈值的交换单元中所有压缩后的第一数据;其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的,各交换单元的换入概率是根据交换单元中压缩后的第一数据被访问的概率确定的。In combination with the first aspect, in a possible implementation, the zspage module determines that the second data is data in the compressed data in the first memory whose compression rate meets the threshold condition, including: the zspage module determines that the second data is all compressed first data in the exchange unit whose compression rate is greater than a fourth threshold and whose swap-in probability is less than a fifth threshold; wherein the compression rate of each exchange unit is determined based on the compression rate of the compressed first data in the exchange unit, and the swap-in probability of each exchange unit is determined based on the probability of the compressed first data in the exchange unit being accessed.
在上述实施例中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的,各交换单元的换入概率是根据交换单元中压缩后的第一数据被访问的概率确定的。如此,在交换单元大小相同的情况下,该交换单元对应的压缩率越大,说明该交换单元内存储的第一数据越少,这样该交换单元的换入概率越低,从而可以降低由于换入换出造成数据颠簸的问题。In the above embodiment, the compression rate of each exchange unit is determined according to the compression rate of the first data compressed in the exchange unit, and the swap-in probability of each exchange unit is determined according to the probability of the first data compressed in the exchange unit being accessed. In this way, when the exchange units are of the same size, the larger the compression rate corresponding to the exchange unit, the less the first data stored in the exchange unit, and thus the lower the swap-in probability of the exchange unit, thereby reducing the problem of data jitter caused by swapping in and out.
结合第一方面,在一种可能实现方式中,zspage模块确定第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据,包括:zspage模块根据各交换单元的压缩率,确定第二数据依次为按照从大到小的顺序将交换单元中压缩后的第一数据;Swap块设备将第二数据存储在第二存储器,包括:Swap块设备依次将从zspage模块获取的第二数据存储在第二存储器中,直至第一存储器的可用存储空间大于第一阈值。In combination with the first aspect, in a possible implementation, the zspage module determines that the second data is data whose compression rate satisfies a threshold condition in the compressed data in the first memory, including: the zspage module determines, based on the compression rate of each exchange unit, that the second data is the first data compressed in the exchange unit in order from large to small; the Swap block device stores the second data in the second memory, including: the Swap block device stores the second data obtained from the zspage module in the second memory in turn until the available storage space of the first memory is greater than the first threshold.
在上述实施例中,依次根据每个交换单元对应的压缩率,按照从大到小的顺序将交换单元存储在第二存储器中,直至第一存储器的可用存储空间大于第一阈值。如此。在交换单元大小相同的情况下,对应第一数据的压缩率越高,该交换单元内存储的第一数据越少,这样该交换单元的换入概率越低,从而可以降低由于换入换出造成数据颠簸的问题。In the above embodiment, the exchange units are stored in the second memory in descending order according to the compression rate corresponding to each exchange unit, until the available storage space of the first memory is greater than the first threshold. In this way. When the exchange units are of the same size, the higher the compression rate of the corresponding first data, the less the first data stored in the exchange unit, so that the probability of the exchange unit being swapped in is lower, thereby reducing the problem of data jitter caused by swapping in and out.
第二方面,本申请实施例提供一种电子设备,包括处理单元。In a second aspect, an embodiment of the present application provides an electronic device, including a processing unit.
处理单元,用于在第一存储器的可用存储空间小于第一阈值的情况下,将数据中的第一数据压缩后存储在第一存储器中。处理单元,还用于释放压缩前第一数据占用的存储空间。处理单元,还用于在第一存储器中压缩后的数据占用的存储空间大于第二阈值的情况下,将第二数据存储在第二存储器,第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据,第一存储器中压缩后的数据包括第一数据。处理单元,还用于释放第二数据占用的存储空间。The processing unit is used to compress the first data in the data and store it in the first memory when the available storage space of the first memory is less than the first threshold. The processing unit is also used to release the storage space occupied by the first data before compression. The processing unit is also used to store the second data in the second memory when the storage space occupied by the compressed data in the first memory is greater than the second threshold, the second data being the data whose compression rate meets the threshold condition among the compressed data in the first memory, and the compressed data in the first memory includes the first data. The processing unit is also used to release the storage space occupied by the second data.
结合第二方面,在一种可能实现方式中,处理单元,具体用于对第一数据进行压缩;处理单元,具体用于将压缩后的第一数据以交换单元的形式存储在第一存储器中。其中,同一交换单元中的压缩后的第一数据的压缩率差值小于第三阈值。In conjunction with the second aspect, in a possible implementation, the processing unit is specifically configured to compress the first data; and the processing unit is specifically configured to store the compressed first data in the first memory in the form of an exchange unit. The difference in compression rate of the compressed first data in the same exchange unit is less than a third threshold.
结合第二方面,在一种可能实现方式中,处理单元,具体用于确定压缩率大于第四阈值的交换单元中所有压缩后的第一数据为第二数据。处理单元,具体用于将第二数据存储在第二存储器。其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的。In conjunction with the second aspect, in a possible implementation, the processing unit is specifically configured to determine that all compressed first data in the switching unit whose compression rate is greater than a fourth threshold value is the second data. The processing unit is specifically configured to store the second data in the second memory. The compression rate of each switching unit is determined according to the compression rate of the compressed first data in the switching unit.
结合第二方面,在一种可能实现方式中,处理单元,具体用于确定压缩率大于第四阈值,且换入概率小于第五阈值的交换单元中所有压缩后的第一数据为第二数据。处理单元,具体用于将第二数据存储在第二存储器。其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的,各交换单元的换入概率是根据交换单元中压缩后的第一数据被访问的概率确定的。In conjunction with the second aspect, in a possible implementation, the processing unit is specifically configured to determine that all compressed first data in the switching unit whose compression rate is greater than a fourth threshold value and whose swap-in probability is less than a fifth threshold value is the second data. The processing unit is specifically configured to store the second data in the second memory. The compression rate of each switching unit is determined based on the compression rate of the compressed first data in the switching unit, and the swap-in probability of each switching unit is determined based on the probability of the compressed first data in the switching unit being accessed.
结合第二方面,在一种可能实现方式中,处理单元,具体用于根据各交换单元的压缩率,确定第二数据依次为按照从大到小的顺序将交换单元中压缩后的第一数据;处理单元,具体用于依次将第二数据存储在第二存储器中,直至第一存储器的可用存储空间大于第一阈值。In combination with the second aspect, in one possible implementation, the processing unit is specifically used to determine, based on the compression rate of each exchange unit, that the second data is the first data compressed in the exchange unit in order from large to small; the processing unit is specifically used to store the second data in the second memory in sequence until the available storage space of the first memory is greater than the first threshold.
结合第二方面,在一种可能实现方式中,第一存储器为内存,第二存储器为外部存储器。In conjunction with the second aspect, in a possible implementation, the first memory is a memory, and the second memory is an external memory.
第三方面,本申请实施例提供一种电子设备,包括ZRAM块设备,zspage模块,Swap块设备、内存管理模块、第一存储器和第二存储器。内存管理模块,用于在第一存储器的可用存储空间小于第一阈值的情况下,通过ZRAM块设备将数据中的第一数据存储至第一存储器设置的Swap space;ZRAM块设备,用于对Swap space中的第一数据进行压缩,并将压缩后的第一数据发送中至zspage模块;zspage模块,用于将压缩后的第一数据存储在第一存储器中;内存管理模块释放压缩前第一数据占用的存储空间;ZRAM块设备,还用于在第一存储器中压缩后的数据占用的存储空间大于第二阈值的情况下,通过接口通知Swap块设备;Swap块设备,还用于通过接口从zspage模块中获取第二数据;zspage模块,还用于确定第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据;zspage模块,还用于将第二数据发送给Swap块设备;Swap块设备,还用于将第二数据存储在第二存储器,第一存储器中压缩后的数据包括第一数据;内存管理模块释放第二数据占用的存储空间。In a third aspect, an embodiment of the present application provides an electronic device, including a ZRAM block device, a zspage module, a Swap block device, a memory management module, a first memory and a second memory. A memory management module is used to store the first data in the data to the Swap space set in the first memory through a ZRAM block device when the available storage space of the first memory is less than a first threshold value; the ZRAM block device is used to compress the first data in the Swap space and send the compressed first data to the zspage module; the zspage module is used to store the compressed first data in the first memory; the memory management module releases the storage space occupied by the first data before compression; the ZRAM block device is also used to notify the Swap block device through an interface when the storage space occupied by the compressed data in the first memory is greater than a second threshold value; the Swap block device is also used to obtain the second data from the zspage module through the interface; the zspage module is also used to determine that the second data is the data whose compression rate meets the threshold condition in the compressed data in the first memory; the zspage module is also used to send the second data to the Swap block device; the Swap block device is also used to store the second data in the second memory, and the compressed data in the first memory includes the first data; the memory management module releases the storage space occupied by the second data.
结合第三方面,在一种可能实现方式中,zspage模块,具体用于将压缩后的第一数据以交换单元的形式存储在第一存储器中;其中,同一交换单元中的压缩后的第一数据的压缩率差值小于第三阈值。In combination with the third aspect, in a possible implementation, the zspage module is specifically used to store the compressed first data in the form of an exchange unit in the first memory; wherein the compression rate difference of the compressed first data in the same exchange unit is less than a third threshold.
结合第三方面,在一种可能实现方式中,zspage模块,具体用于确定第二数据为压缩率大于第四阈值的交换单元中所有压缩后的第一数据;其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的。In combination with the third aspect, in one possible implementation, the zspage module is specifically used to determine that the second data is all compressed first data in the exchange unit whose compression rate is greater than a fourth threshold; wherein the compression rate of each exchange unit is determined based on the compression rate of the compressed first data in the exchange unit.
结合第三方面,在一种可能实现方式中,zspage模块,具体用于确定第二数据为压缩率大于第四阈值,且换入概率小于第五阈值的交换单元中所有压缩后的第一数据;其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的,各交换单元的换入概率是根据交换单元中压缩后的第一数据被访问的概率确定的。In combination with the third aspect, in one possible implementation, the zspage module is specifically used to determine that the second data is all compressed first data in the exchange unit whose compression rate is greater than a fourth threshold and whose swap-in probability is less than a fifth threshold; wherein the compression rate of each exchange unit is determined based on the compression rate of the compressed first data in the exchange unit, and the swap-in probability of each exchange unit is determined based on the probability of the compressed first data in the exchange unit being accessed.
结合第三方面,在一种可能实现方式中,zspage模块,具体用于根据各交换单元的压缩率,确定第二数据依次为按照从大到小的顺序将交换单元中压缩后的第一数据;Swap块设备,具体用于依次将从zspage模块获取的第二数据存储在第二存储器中,直至第一存储器的可用存储空间大于第一阈值。In combination with the third aspect, in a possible implementation, the zspage module is specifically used to determine, based on the compression rate of each exchange unit, that the second data is the first data compressed in the exchange unit in order from large to small; the Swap block device is specifically used to store the second data obtained from the zspage module in the second memory in sequence until the available storage space of the first memory is greater than the first threshold.
结合第三方面,在一种可能实现方式中,第一存储器为内存,第二存储器为外部存储器。In combination with the third aspect, in a possible implementation, the first memory is a memory and the second memory is an external memory.
第四方面,本申请实施例提供一种电子设备,包括:通信接口、处理器、存储器、总线;所述存储器用于存储计算机执行指令,所述处理器与所述存储器通过所述总线连接;当所述电子设备运行时,所述处理器执行所述存储器存储的计算机执行指令,以使所述电子设备执行如上述第一方面及其任一种可能的设计方式所述的方法。In a fourth aspect, an embodiment of the present application provides an electronic device, comprising: a communication interface, a processor, a memory, and a bus; the memory is used to store computer execution instructions, and the processor is connected to the memory through the bus; when the electronic device is running, the processor executes the computer execution instructions stored in the memory, so that the electronic device executes the method described in the first aspect above and any possible design method thereof.
第五方面,本申请实施例提供一种计算机可读存储介质,当所述存储介质中的指令由电子设备的处理器执行时,使得所述电子设备能够执行如上述第一方面及其任一种可能的设计方式所述的方法。In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the method described in the first aspect above and any possible design method thereof.
第六方面,本申请实施例提供一种计算机程序产品,包括,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如上述第一方面及其任一种可能的设计方式所述的方法。In a sixth aspect, an embodiment of the present application provides a computer program product, including, when the computer program product is run on a computer, enabling the computer to execute the method described in the first aspect above and any possible design method thereof.
可以理解地,上述提供的第二方面、第三方面、第四方面及其任一种可能的设计方式所述的电子设备,第五方面所述的计算机存储介质,第六方面所述的计算机程序产品所能达到的有益效果,可参考第一方面及其任一种可能的设计方式中的有益效果,此处不再赘述。It can be understood that the beneficial effects that can be achieved by the electronic device described in the second aspect, the third aspect, the fourth aspect and any possible design method thereof, the computer storage medium described in the fifth aspect, and the computer program product described in the sixth aspect can be referred to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为现有技术中手机开机显示的界面示意图之一。FIG. 1 is one of the interface schematic diagrams of a mobile phone startup display in the prior art.
图2为现有技术中手机开机显示的界面示意图之二。FIG. 2 is a second schematic diagram of an interface displayed when a mobile phone is turned on in the prior art.
图3为现有技术中电子设备100的结构示意图之一。FIG. 3 is a schematic diagram of a structure of an electronic device 100 in the prior art.
图4为现有技术中电子设备100的结构示意图之二。FIG. 4 is a second structural schematic diagram of an electronic device 100 in the prior art.
图5为现有技术中电子设备100的结构示意图之三。FIG. 5 is a third structural schematic diagram of an electronic device 100 in the prior art.
图6为现有技术中电子设备100的结构示意图之四。FIG. 6 is a fourth structural diagram of the electronic device 100 in the prior art.
图7为本申请实施例提供的电子设备200的结构示意图之一。FIG. 7 is one of the structural schematic diagrams of the electronic device 200 provided in an embodiment of the present application.
图8为本申请实施例提供的电子设备200的结构示意图之二。FIG. 8 is a second schematic diagram of the structure of the electronic device 200 provided in an embodiment of the present application.
图9为本申请实施例提供的存储器管理方法的流程示意图。FIG9 is a flow chart of a memory management method provided in an embodiment of the present application.
图10为本申请实施例提供的数据压缩前与压缩后的对比示意图。FIG. 10 is a schematic diagram showing a comparison of data before and after compression provided in an embodiment of the present application.
图11为本申请实施例提供的数据存储的示意图。FIG. 11 is a schematic diagram of data storage provided in an embodiment of the present application.
图12为本申请实施例提供的电子设备200的结构示意图之三。FIG. 12 is a third schematic diagram of the structure of the electronic device 200 provided in an embodiment of the present application.
图13为本申请实施例提供的一种芯片系统的示意图。FIG13 is a schematic diagram of a chip system provided in an embodiment of the present application.
具体实施方式Detailed ways
以下对本申请实施例中涉及的相关概念给出解释:The following explains the relevant concepts involved in the embodiments of the present application:
压缩率(Compression rate),可以是指数据压缩后的大小与压缩前的大小之比。如:把100M的数据进行压缩,并且压缩后的数据大小为90M,则压缩率为即压缩率等于90%。Compression rate refers to the ratio of the size of data after compression to the size before compression. For example, if 100M of data is compressed and the compressed data size is 90M, the compression rate is That is, the compression rate is equal to 90%.
冷页(Cold Page),可以是相对于热页(hot page)的页。可将一段时间内被访问过的页称为热页。相反,将一段时间内未被没有访问过的页称为冷页。热页一般可存储在缓存中。Cold Page can be a page relative to a hot page. A page that has been accessed within a period of time can be called a hot page. Conversely, a page that has not been accessed within a period of time is called a cold page. Hot pages can generally be stored in cache.
LRU算法是一种常用的页面置换算法,用于选择最近没有访问的页予以换出。The LRU algorithm is a commonly used page replacement algorithm that is used to select pages that have not been accessed recently for swapping out.
为了能够释放RAM的更多存储空间供前台运行应用使用,相关技术提供了内存优化技术。以电子设备是手机为例,介绍相关技术中的内存优化技术。In order to free up more RAM storage space for foreground running applications, the related art provides a memory optimization technology. Taking the electronic device being a mobile phone as an example, the memory optimization technology in the related art is introduced.
示例性的,以手机的总存储空间为100M,应用包括应用1,应用2和应用3为例。手机开机后,手机接收到用户开启应用1的操作后,手机启动应用1,手机的系统为其分配了30M的存储空间。之后,用户想要打开应用2时,手机接收到用户的切换操作,将应用1切换至后台运行,并显示桌面。此时,手机确定剩余存储空间70M大于内存回收门限(如40M),此时手机不会强制结束应用1。在接收到用户开启应用2的操作后,手机启动应用2,手机的系统为其分配了35M的存储空间。之后,用户想要打开应用3时,手机接收到用户的切换操作,将应用2切换至后台运行,并显示桌面。由于手机的系统未杀死应用1和应用2,而是在后台中继续运行应用1和应用2,导致应用1和应用2仍然会占用65M存储空间,用于存储相关数据,相关数据如切换到后台运行前最后显示界面的数据。此时,手机确定剩余存储空间35M小于内存回收门限40M,手机可以按照应用的运行时间的先后顺序,强制结束运行时间最早的应用,例如,强制结束应用1,从而释放应用1占用的存储空间,以便手机在开启应用3时,有足够的存储空间分配为应用3,保证户的体验。For example, the total storage space of a mobile phone is 100M, and the applications include application 1, application 2 and application 3. After the mobile phone is turned on, after the mobile phone receives the user's operation to start application 1, the mobile phone starts application 1, and the system of the mobile phone allocates 30M of storage space for it. Later, when the user wants to open application 2, the mobile phone receives the user's switching operation, switches application 1 to the background, and displays the desktop. At this time, the mobile phone determines that the remaining storage space of 70M is greater than the memory recovery threshold (such as 40M), and the mobile phone will not force the end of application 1. After receiving the user's operation to start application 2, the mobile phone starts application 2, and the system of the mobile phone allocates 35M of storage space for it. Later, when the user wants to open application 3, the mobile phone receives the user's switching operation, switches application 2 to the background, and displays the desktop. Because the system of the mobile phone does not kill application 1 and application 2, but continues to run application 1 and application 2 in the background, application 1 and application 2 will still occupy 65M of storage space for storing related data, such as the data of the last displayed interface before switching to the background. At this time, the mobile phone determines that the remaining storage space of 35M is less than the memory recycling threshold of 40M. The mobile phone can forcibly end the application with the earliest running time in the order of the running time of the applications. For example, the mobile phone forcibly ends application 1, thereby releasing the storage space occupied by application 1, so that when the mobile phone starts application 3, there is enough storage space allocated to application 3 to ensure the user experience.
或者,手机开机后,手机接收到用户开启应用1的操作后,手机启动应用1,手机的系统为其分配了30M的存储空间。之后,用户想要打开应用2时,手机接收到用户的切换操作,将应用1切换至后台运行,并显示桌面。在接收到用户开启应用2的操作后,手机启动应用2,手机的系统为其分配了35M的存储空间。之后,用户想要打开应用3时,手机接收到用户的切换操作,将应用2切换至后台运行,并显示桌面。此时,由于手机的系统未杀死应用1和应用2,而是在后台中继续运行应用1和应用2,导致应用1和应用2仍然会占用65M存储空间,用于存储相关数据,相关数据如切换到后台运行前最后显示界面的数据。手机接收到用户开启应用3的操作后,在开启应用3前,应用3会向手机申请存储空间,例如,申请50M的存储空间。手机确定剩余存储空间35M小于应用3需要申请的存储空间50M,为了有足够的存储空间分配为应用3,手机可以按照应用的运行时间的先后顺序,强制结束运行时间最早的应用,例如,强制结束应用1,从而释放应用1占用的存储空间,并将释放的存储空间提供给应用3使用。Alternatively, after the mobile phone is turned on, after the mobile phone receives the user's operation to start application 1, the mobile phone starts application 1, and the mobile phone system allocates 30M of storage space for it. Later, when the user wants to open application 2, the mobile phone receives the user's switching operation, switches application 1 to the background, and displays the desktop. After receiving the user's operation to start application 2, the mobile phone starts application 2, and the mobile phone system allocates 35M of storage space for it. Later, when the user wants to open application 3, the mobile phone receives the user's switching operation, switches application 2 to the background, and displays the desktop. At this time, because the mobile phone system does not kill application 1 and application 2, but continues to run application 1 and application 2 in the background, application 1 and application 2 will still occupy 65M of storage space for storing related data, such as the data of the last display interface before switching to the background. After the mobile phone receives the user's operation to start application 3, before starting application 3, application 3 will apply to the mobile phone for storage space, for example, 50M of storage space. The mobile phone determines that the remaining storage space of 35M is less than the storage space of 50M required by application 3. In order to have enough storage space allocated to application 3, the mobile phone can forcibly end the application with the earliest running time in the order of the running time of the applications. For example, forcibly end application 1, thereby freeing up the storage space occupied by application 1 and providing the freed storage space to application 3.
由上述过程可知,手机强制结束了应用1,释放了对应存储空间,其存储的相关数据也相应的会被删除。因此,在应用1再次启动时,所需的启动的时间过长。例如,应用1再次开启时,显示启动页面,在显示启动页面的过程中加载应用1需要的资源,在加载完需要的资源后,才会显示应用1的界面供用户查看。或者,应用1再次开启时,应用1可能会进行更新检测,并显示正在检查更新的界面(如图1所示),在检查更新完成后,才会显示应用1的界面供用户查看。或者,应用1再次开启时,会先显示广告界面(如图2所示)。之后,才会显示应用1的界面供用户查看。From the above process, it can be seen that the mobile phone forcibly ends application 1, releases the corresponding storage space, and the related data stored in it will be deleted accordingly. Therefore, when application 1 is started again, the startup time required is too long. For example, when application 1 is turned on again, the startup page is displayed, and the resources required by application 1 are loaded in the process of displaying the startup page. After the required resources are loaded, the interface of application 1 will be displayed for the user to view. Alternatively, when application 1 is turned on again, application 1 may perform update detection and display an interface that is checking for updates (as shown in Figure 1). After the update check is completed, the interface of application 1 will be displayed for the user to view. Alternatively, when application 1 is turned on again, the advertising interface will be displayed first (as shown in Figure 2). After that, the interface of application 1 will be displayed for the user to view.
为解决上述问题,一种实现方式如图3所示,以电子设备100包括CPU、RAM和通用闪存(Universal Flash Storage,UFS)为例。其中,CPU在确定RAM的剩余存储空间小于内存回收门限时,根最近最少使用(Least Recently Used,LRU)算法确定RAM中可以换出的冷数据,并将冷数据存储在UFS中。同时,冷数据被访问时,CPU需要从UFS中将冷数据换入至RAM中。由于UFS存在读写速率瓶颈和使用寿命限制,而存储在UFS中的冷数据存在频繁换出换入的情况,这样会缩短UFS的使用寿命,无法大面积的推广。To solve the above problems, an implementation method is shown in Figure 3, taking the electronic device 100 including CPU, RAM and Universal Flash Storage (UFS) as an example. Among them, when the CPU determines that the remaining storage space of RAM is less than the memory recovery threshold, it determines the cold data that can be swapped out in RAM based on the Least Recently Used (LRU) algorithm, and stores the cold data in UFS. At the same time, when the cold data is accessed, the CPU needs to swap the cold data from UFS into RAM. Since UFS has a read and write rate bottleneck and a service life limit, and the cold data stored in UFS is frequently swapped out and in, this will shorten the service life of UFS and cannot be promoted on a large scale.
另一种实现方式如图4所示,以电子设备100包括:中央处理器(centralprocessing unit,CPU)以及RAM为例。其中,RAM上设置有Swap space,并且RAM中存储有后台运行的应用的相关数据。CPU在RAM的剩余存储空间小于阈值时,根据LRU算法,确定RAM中存储的数据中能够换出(swap out)的冷数据。将冷数据换出至Swap space后,CPU在Swapspace中对冷数据进行压缩,并将压缩后的冷数据以交换单元(如称为:zspage)的形式存储在RAM中。由于压缩后的冷数据所需要的存储空间小于压缩前的冷数据所需要的存储空间,因此可以从内部存储器释放出更多存储空间。由于没有了外部存储器(如UFS),可以避免由于外部存储器的读写速率瓶颈和使用寿命限制,无法大面积的推广的问题。但是,在用户开启的应用较多的情况下,电子设备100换出的冷数据逐渐增多,压缩后的冷数据会占用大量的存储空间,导致RAM剩余的存储空间仍较少。Another implementation is shown in FIG. 4 , where an electronic device 100 includes: a central processing unit (CPU) and a RAM as an example. Among them, a Swap space is provided on the RAM, and the RAM stores the relevant data of the application running in the background. When the remaining storage space of the RAM is less than the threshold, the CPU determines the cold data that can be swapped out from the data stored in the RAM according to the LRU algorithm. After swapping the cold data out to the Swap space, the CPU compresses the cold data in the Swap space, and stores the compressed cold data in the RAM in the form of a swap unit (such as: zspage). Since the storage space required for the compressed cold data is less than the storage space required for the cold data before compression, more storage space can be released from the internal memory. Since there is no external memory (such as UFS), the problem of not being able to be promoted on a large scale due to the bottleneck of the read and write rate and the service life limit of the external memory can be avoided. However, when the user opens more applications, the cold data swapped out by the electronic device 100 gradually increases, and the compressed cold data will occupy a large amount of storage space, resulting in less remaining storage space in the RAM.
又一种实现方式如图5所示,以电子设备100包括CPU、RAM和UFS为例。其中,RAM上设置有Swap space,并且RAM中存储有后台运行的应用的相关数据。CPU在确定RAM的剩余存储空间小于内存回收门限时,根据LRU算法确定RAM中可以换出的冷数据,并将冷数据换出至Swap space。CPU在Swap space中对冷数据进行压缩,并将冷数据以一个单元(如称为:zspage)的形式存储在RAM中。CPU确定压缩后的冷数据占用的存储空间大于阈值时,CPU根据LRU算法确定压缩后的冷数据中可换出的指定冷数据,并将指定冷数据存储在UFS中。由于RAM中存储的压缩后的冷数据更少了,因此可以从RAM释放出更多存储空间。但是,将指定冷数据存储在UFS时,是以交换单元(如称为:zspage)的形式进行存储的。当该zspage中某一个冷页被访问时,CPU需要将该zspage中所有的冷数据对应的冷页均换入至RAM进行解压。如此,该zspage会存在频繁换入换出,导致出现数据颠簸的问题。Another implementation is shown in FIG. 5 , taking the electronic device 100 including a CPU, a RAM and a UFS as an example. Among them, a Swap space is provided on the RAM, and the RAM stores the relevant data of the application running in the background. When the CPU determines that the remaining storage space of the RAM is less than the memory recovery threshold, the CPU determines the cold data that can be swapped out in the RAM according to the LRU algorithm, and swaps the cold data out to the Swap space. The CPU compresses the cold data in the Swap space and stores the cold data in the RAM in the form of a unit (such as: zspage). When the CPU determines that the storage space occupied by the compressed cold data is greater than the threshold, the CPU determines the specified cold data that can be swapped out in the compressed cold data according to the LRU algorithm, and stores the specified cold data in the UFS. Since the compressed cold data stored in the RAM is less, more storage space can be released from the RAM. However, when the specified cold data is stored in the UFS, it is stored in the form of a swap unit (such as: zspage). When a cold page in the zspage is accessed, the CPU needs to swap all the cold pages corresponding to the cold data in the zspage into the RAM for decompression. In this case, the zspage will be frequently swapped in and out, resulting in data jitter.
进一步地,在一个实施例中,以电子设备100的操作系统为Android系统为例,如图6所示,电子设备100从逻辑上可划分为应用层11、内核层12和硬件层13。其中,硬件层13可包括图5所示的CPU、RAM和UFS等。应用层11包括一个或多个应用(应用1~应用3等)。应用可以为系统应用,也可以为第三方应用。内核层12作为硬件层13和应用层11之间的软件中间件,用于管理和控制硬件与软件资源,例如,对电子设备100的内存进行管理。其中,内核层12包括内核121、用于提供底层系统服务的交换设备122和用于管理内存的内存管理模块123。例如:交换设备122可以包括ZRAM块设备和Swap块设备。内存管理模块123确定RAM使用量超过阈值时,内存管理模块123根据LRU算法确定冷数据。内存管理模块123通过交换设备122中的ZRAM块设备将冷数据换出至RAM中的ZRAM分区。ZRAM块设备对ZRAM分区中的冷数据进行压缩。ZRAM块设备将ZRAM分区中压缩后的冷数据以交换单元(如称为zspage)的形式存储到RAM中。ZRAM块设备确定压缩数据总量超过压缩阈值时,通过接口通知Swap块设备。Swap块设备通过接口从ZRAM块设备中获取指定冷数据。ZRAM块设备根据LRU算法从zspage中获取指定冷数据。ZRAM块设备将指定冷数据通过接口发送给Swap块设备,Swap块设备将指定冷数据换出到UFS。Further, in one embodiment, taking the operating system of the electronic device 100 as an Android system as an example, as shown in FIG6 , the electronic device 100 can be logically divided into an application layer 11, a kernel layer 12, and a hardware layer 13. Among them, the hardware layer 13 may include the CPU, RAM, and UFS shown in FIG5 . The application layer 11 includes one or more applications (application 1 to application 3, etc.). The application can be a system application or a third-party application. The kernel layer 12 is used as a software middleware between the hardware layer 13 and the application layer 11 to manage and control hardware and software resources, for example, to manage the memory of the electronic device 100. Among them, the kernel layer 12 includes a kernel 121, a switching device 122 for providing underlying system services, and a memory management module 123 for managing memory. For example, the switching device 122 may include a ZRAM block device and a Swap block device. When the memory management module 123 determines that the RAM usage exceeds a threshold, the memory management module 123 determines the cold data according to the LRU algorithm. The memory management module 123 swaps out the cold data to the ZRAM partition in the RAM through the ZRAM block device in the switching device 122. The ZRAM block device compresses the cold data in the ZRAM partition. The ZRAM block device stores the compressed cold data in the ZRAM partition in the form of a swap unit (such as a zspage) in RAM. When the ZRAM block device determines that the total amount of compressed data exceeds the compression threshold, it notifies the Swap block device through the interface. The Swap block device obtains the specified cold data from the ZRAM block device through the interface. The ZRAM block device obtains the specified cold data from the zspage according to the LRU algorithm. The ZRAM block device sends the specified cold data to the Swap block device through the interface, and the Swap block device swaps out the specified cold data to the UFS.
鉴于此,本申请实施例提供一种存储器管理方法,可以应用于包括存储器(如内存)的电子设备,用以提升其可用存储空间。另外,本实施例提供的方法还可以较好的解决存入UFS的数据换入换出的颠簸问题。In view of this, an embodiment of the present application provides a memory management method, which can be applied to an electronic device including a memory (such as a memory) to increase its available storage space. In addition, the method provided in this embodiment can also better solve the problem of jitter in and out of data stored in UFS.
其中,电子设备可以为手机,平板电脑,手持计算机,个人计算机(PersonalComputer,PC),蜂窝电话,个人数字助理(personal digital assistant,PDA),可穿戴式设备(如智能手表),智能家居设备(如电视机),车载电脑,游戏机,以及增强现实(augmentedreality,AR)\虚拟现实(virtual reality,VR)设备等设备,该设备的操作系统包括Linux内核层。本实施例对电子设备的具体设备形态不做特殊限制。The electronic device may be a mobile phone, a tablet computer, a handheld computer, a personal computer (PC), a cellular phone, a personal digital assistant (PDA), a wearable device (such as a smart watch), a smart home device (such as a TV), a car computer, a game console, and an augmented reality (AR) or virtual reality (VR) device, and the operating system of the device includes a Linux kernel layer. This embodiment does not impose any special restrictions on the specific device form of the electronic device.
下面介绍本申请实施例的一种电子设备的结构示意图。图7示出了电子设备200的结构示意图。电子设备200可以包括处理器210,外部存储器接口120,内部存储器,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,显示屏193,用户标识模块(subscriber identification module,SIM)卡接口194,以及摄像头195等。其中,传感器模块180可以包括压力传感器,陀螺仪传感器,气压传感器,磁传感器,加速度传感器,距离传感器,接近光传感器,指纹传感器,温度传感器,触摸传感器,环境光传感器,骨传导传感器等。The following is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. FIG7 shows a schematic diagram of the structure of an electronic device 200. The electronic device 200 may include a processor 210, an external memory interface 120, an internal memory, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a display screen 193, a subscriber identification module (SIM) card interface 194, and a camera 195, etc. Among them, the sensor module 180 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
处理器210可以包括一个或多个处理单元,例如:处理器210可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processingunit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器220,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。其中,控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。存储器220可以用于存储计算机可执行程序代码,例如应用和操作系统对应的计算机程序;处理器210可调用存储器220存储的计算机程序,从而实现该计算机程序定义的功能。存储器220可以包括内部存储器(也可以称为内存)2201和外部存储器2202。其中,在本申请一些实施例中,内存2201用于暂时存放处于运行状态的应用的相关数据,以及操作系统的代码以及数据,外部存储器2202则用于存储处于可换出的数据等。示例性的,如内存2201可以为RAM,外部存储器2202可以为硬盘(Hard Disk,HD),固态硬盘(Solid StateDisk或Solid State Drive,SSD),或者UFS。The processor 210 may include one or more processing units, for example: the processor 210 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory 220, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural-network processing unit (neural-network processing unit, NPU), etc. Among them, different processing units may be independent devices or integrated into one or more processors. Among them, the controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions. The memory 220 may be used to store computer executable program codes, such as computer programs corresponding to applications and operating systems; the processor 210 may call the computer program stored in the memory 220 to implement the functions defined by the computer program. The memory 220 may include an internal memory (also referred to as a memory) 2201 and an external memory 2202. In some embodiments of the present application, the memory 2201 is used to temporarily store the relevant data of the running application and the code and data of the operating system, and the external memory 2202 is used to store the swappable data, etc. For example, the memory 2201 can be a RAM, and the external memory 2202 can be a hard disk (HD), a solid state disk (SSD), or a UFS.
处理器210中还可以设置存储器,用于存储指令和数据。在一些实施例中,存储器可以用于存储计算机可执行程序代码,例如应用和操作系统对应的计算机程序;处理器210可调用存储器存储的计算机程序,从而实现该计算机程序定义的功能。例如,处理器210可以将操作系统对应的代码存储到存储器中,然后执行存储器中操作系统对应的代码,从而在电子设备100上实现操作系统的各种功能,处理器210也可以将应用对应的代码存储到存储器中,然后执行该应用对应的代码,从而在电子设备100上实现该应用的各种功能。操作系统可以为Windows系统、MAC OS系统、Linux系统或者Android系统等,当然也可以是面向未来的计算机系统,本申请实施例中不作限制。A memory may also be provided in the processor 210 for storing instructions and data. In some embodiments, the memory may be used to store computer executable program codes, such as computer programs corresponding to applications and operating systems; the processor 210 may call the computer program stored in the memory to implement the functions defined by the computer program. For example, the processor 210 may store the code corresponding to the operating system in the memory, and then execute the code corresponding to the operating system in the memory, thereby implementing various functions of the operating system on the electronic device 100. The processor 210 may also store the code corresponding to the application in the memory, and then execute the code corresponding to the application, thereby implementing various functions of the application on the electronic device 100. The operating system may be a Windows system, a MAC OS system, a Linux system, an Android system, etc., and of course it may also be a future-oriented computer system, which is not limited in the embodiments of the present application.
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。内部存储器可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The internal memory may be used to store computer executable program codes, which include instructions.
充电管理模块140用于从充电器接收充电输入。电源管理模块141用于连接电池142,充电管理模块140与处理器210。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器210,内部存储器,外部存储器,显示屏193,摄像头195,和无线通信模块160等供电。The charging management module 140 is used to receive charging input from the charger. The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 210. The power management module 141 receives input from the battery 142 and/or the charging management module 140, and provides power to the processor 210, the internal memory, the external memory, the display screen 193, the camera 195, and the wireless communication module 160.
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。天线1和天线2用于发射和接收电磁波信号。移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wirelesslocal area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。The wireless communication function of the electronic device 100 can be implemented by antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modulation and demodulation processor and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. The mobile communication module 150 can provide solutions for wireless communications including 2G/3G/4G/5G applied to the electronic device 100. The wireless communication module 160 can provide solutions for wireless communications including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc. applied to the electronic device 100.
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。耳机接口170D用于连接有线耳机。The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The speaker 170A, also called "speaker", is used to convert audio electrical signals into sound signals. The receiver 170B, also called "earpiece", is used to convert audio electrical signals into sound signals. The microphone 170C, also called "microphone", "microphone", is used to convert sound signals into electrical signals. The headphone interface 170D is used to connect wired headphones.
压力传感器用于感受压力信号,可以将压力信号转换成电信号。陀螺仪传感器可以用于确定电子设备100的运动姿态。气压传感器用于测量气压。磁传感器包括霍尔传感器。加速度传感器可检测电子设备100在各个方向上(一般为三轴)加速度的大小。距离传感器,用于测量距离。接近光传感器可以包括例如发光二极管(LED)和光检测器,例如光电二极管。环境光传感器用于感知环境光亮度。指纹传感器用于采集指纹。温度传感器用于检测温度。触摸传感器,也称“触控面板”。骨传导传感器可以获取振动信号。按键190包括开机键,音量键等。马达191可以产生振动提示。指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。显示屏193用于显示图像,视频等。SIM卡接口194用于连接SIM卡。The pressure sensor is used to sense the pressure signal and can convert the pressure signal into an electrical signal. The gyroscope sensor can be used to determine the motion posture of the electronic device 100. The air pressure sensor is used to measure the air pressure. The magnetic sensor includes a Hall sensor. The acceleration sensor can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). Distance sensor, used to measure the distance. The proximity light sensor can include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The ambient light sensor is used to sense the brightness of the ambient light. The fingerprint sensor is used to collect fingerprints. The temperature sensor is used to detect the temperature. The touch sensor, also known as the "touch panel". The bone conduction sensor can obtain vibration signals. The button 190 includes a power button, a volume button, etc. The motor 191 can generate a vibration prompt. The indicator 192 can be an indicator light, which can be used to indicate the charging status, the change of the power, and can also be used to indicate messages, missed calls, notifications, etc. The display screen 193 is used to display images, videos, etc. The SIM card interface 194 is used to connect the SIM card.
摄像头195用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。Camera 195 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then transmits the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format.
进一步地,在一个实施例中,以电子设备200的操作系统为Android系统为例,如图8所示,电子设备200从逻辑上可划分为应用层21、内核层22和硬件层23。其中,硬件层23可包括图6所示的处理器210和存储器220等。应用层21包括一个或多个应用(应用1~应用3等)。应用可以为系统应用,也可以为第三方应用。内核层22作为硬件层23和应用层21之间的软件中间件,用于管理和控制硬件与软件资源,例如,对电子设备200的内存进行管理。Further, in one embodiment, taking the operating system of the electronic device 200 as the Android system as an example, as shown in FIG8 , the electronic device 200 can be logically divided into an application layer 21, a kernel layer 22, and a hardware layer 23. Among them, the hardware layer 23 may include the processor 210 and the memory 220 shown in FIG6 . The application layer 21 includes one or more applications (application 1 to application 3, etc.). The application can be a system application or a third-party application. The kernel layer 22 serves as a software middleware between the hardware layer 23 and the application layer 21, and is used to manage and control hardware and software resources, for example, to manage the memory of the electronic device 200.
在本申请一些实施例中,内核层22包括内核221、用于提供底层系统服务的交换设备222和用于管理内存的内存管理模块223。例如,交换设备222可以包括ZRAM块设备、zspage模块和Swap块设备。内存管理模块223确定内存2201使用量超过阈值时,内存管理模块223根据LRU算法确定第一冷数据。内存管理模块223通过ZRAM块设备将第一冷数据换出至内存2201中的ZRAM分区。ZRAM块设备(包含压缩算法)对ZRAM分区中的第一冷数据进行压缩。ZRAM块设备将ZRAM分区中压缩后的第一冷数据通过zspage模块以交换单元(如称为zspage)的形式存储到内存2201中。其中,zspage模块中记录了已存储的第一冷数据和每个第一冷数据对应的压缩率。ZRAM块设备确定压缩数据总量超过压缩阈值时,通过接口通知Swap块设备。Swap块设备通过接口(如:get_cold_zspage接口)从zspage模块中获取第二冷数据。zspage模块根据LRU算法和压缩率,确定第一冷数据中可换出的第二冷数据。zspage模块通过接口(如:get_cold_zspage接口)将第二冷数据发送给Swap块设备。Swap块设备将第二冷数据换出到外部存储器2202。In some embodiments of the present application, the kernel layer 22 includes a kernel 221, a switching device 222 for providing underlying system services, and a memory management module 223 for managing memory. For example, the switching device 222 may include a ZRAM block device, a zspage module, and a Swap block device. When the memory management module 223 determines that the usage of the memory 2201 exceeds a threshold, the memory management module 223 determines the first cold data according to the LRU algorithm. The memory management module 223 swaps out the first cold data to the ZRAM partition in the memory 2201 through the ZRAM block device. The ZRAM block device (including a compression algorithm) compresses the first cold data in the ZRAM partition. The ZRAM block device stores the compressed first cold data in the ZRAM partition in the memory 2201 in the form of a switching unit (such as a zspage) through the zspage module. Among them, the zspage module records the stored first cold data and the compression rate corresponding to each first cold data. When the ZRAM block device determines that the total amount of compressed data exceeds the compression threshold, it notifies the Swap block device through the interface. The Swap block device obtains the second cold data from the zspage module through an interface (such as the get_cold_zspage interface). The zspage module determines the second cold data that can be swapped out from the first cold data based on the LRU algorithm and the compression ratio. The zspage module sends the second cold data to the Swap block device through an interface (such as the get_cold_zspage interface). The Swap block device swaps out the second cold data to the external memory 2202.
下面结合附图介绍本申请实施例提供的技术方案。The technical solution provided by the embodiments of the present application is described below in conjunction with the accompanying drawings.
图9为本申请实施例提供的存储器管理方法的一种示例的流程图,该存储器管理方法应用于电子设备200。其中,电子设备200包括的内存2201可以为本申请实施例中的第一存储器,外部存储器2202可以为本申请实施例中的第二存储器。内存2201中存储有在后台运行的应用的数据。FIG9 is a flowchart of an example of a memory management method provided in an embodiment of the present application, and the memory management method is applied to an electronic device 200. The memory 2201 included in the electronic device 200 may be a first memory in the embodiment of the present application, and the external memory 2202 may be a second memory in the embodiment of the present application. The memory 2201 stores data of applications running in the background.
在下面的介绍过程中,以本申请提供的技术方案应用在图7所示的软件架构中为例进行说明。作为一种示例,本申请提供的存储器管理方法可由如图7所示的内核221执行,或者,可以理解为,该方法可以由电子设备200中的处理器210运行内核221的程序来执行。In the following introduction, the application of the technical solution provided by the present application in the software architecture shown in Figure 7 is used as an example for explanation. As an example, the memory management method provided by the present application can be executed by the kernel 221 shown in Figure 7, or it can be understood that the method can be executed by the processor 210 in the electronic device 200 running the program of the kernel 221.
S11、内存管理模块223在内存2201的剩余存储空间小于第一阈值的情况下,根据页面置换算法确定内存2201中的第一冷数据。S11. When the remaining storage space of the memory 2201 is less than a first threshold, the memory management module 223 determines the first cold data in the memory 2201 according to a page replacement algorithm.
需要说明的是,本申请实施例中剩余存储空间也称为可用存储空间,本申请中第一冷数据可以称为第一数据,第二冷数据可以称为第二数据。It should be noted that in the embodiment of the present application, the remaining storage space is also referred to as available storage space. In the present application, the first cold data can be referred to as first data, and the second cold data can be referred to as second data.
在一些示例的实现中,内存管理模块223可以根据内存2201的额定存储空间和已使用的存储空间确定其剩余存储空间。如,剩余存储空间等于内存2201的额定存储空间与已使用存储空间的差值。In some example implementations, the memory management module 223 may determine the remaining storage space of the memory 2201 according to the rated storage space and the used storage space of the memory 2201. For example, the remaining storage space is equal to the difference between the rated storage space and the used storage space of the memory 2201.
一般的,电子设备200开机后,应用1和应用2的开启阶段包括:处理器210接收到用户开启应用1的操作后,处理器210启动应用1,内存管理模块223为其分配了30M的存储空间。之后,用户想要打开应用2时,处理器210接收到用户的切换操作,将应用1切换至后台运行,并显示桌面。此时,内存管理模块223确定剩余存储空间70M大于内存回收门限(如40M),处理器210不会强制结束应用1。处理器210在接收到用户开启应用2的操作后,处理器210启动应用2,内存管理模块223为其分配了35M的存储空间。Generally, after the electronic device 200 is turned on, the start-up phase of application 1 and application 2 includes: after the processor 210 receives the user's operation to start application 1, the processor 210 starts application 1, and the memory management module 223 allocates 30M of storage space for it. Later, when the user wants to open application 2, the processor 210 receives the user's switching operation, switches application 1 to the background, and displays the desktop. At this time, the memory management module 223 determines that the remaining storage space of 70M is greater than the memory recovery threshold (such as 40M), and the processor 210 will not forcibly end application 1. After the processor 210 receives the user's operation to start application 2, the processor 210 starts application 2, and the memory management module 223 allocates 35M of storage space for it.
之后,用户想要打开应用3时,处理器210接收到用户的切换操作,将应用2切换至后台运行,并显示桌面。由于处理器210未杀死应用1和应用2,而是在后台中继续运行应用1和应用2,导致应用1和应用2仍然会占用65M存储空间,用于存储相关数据,相关数据如切换到后台运行前最后显示界面的数据。如此,随着后台运行的应用逐渐增多,这样后台运行的应用占用内存2201的存储空间也会逐渐增大,导致内存2201的剩余存储空间小于第一阈值。内存管理模块223根据页面置换算法确定内存2201中的第一冷数据,并将第一冷数据换出至Swap space。ZRAM块设备对Swap space中的第一冷数据进行压缩,将压缩后的第一冷数据以交换单元(如称为zspage)的形式存储在内存2201中。此时,内存2201可用于存储在后台运行的应用的数据,以及压缩后的第一冷数据。因此,已使用存储空间等于后台运行的应用的数据所占用的存储空间与压缩后的第一冷数据所占用的存储空间之和。示例性的,如内存2201的额定存储空间为4000M,当后台运行的应用的数据所占用的存储空间为1500M,压缩后的第一冷数据所占用的存储空间为300M,则已使用的存储空间等于1500M+300M,剩余存储空间等于4000M-1800M(1500M+300M),即剩余存储空间为2200M。Afterwards, when the user wants to open application 3, the processor 210 receives the user's switching operation, switches application 2 to the background, and displays the desktop. Since the processor 210 does not kill application 1 and application 2, but continues to run application 1 and application 2 in the background, application 1 and application 2 will still occupy 65M storage space for storing relevant data, such as the data of the last display interface before switching to the background. In this way, as the number of applications running in the background gradually increases, the storage space occupied by the applications running in the background in memory 2201 will also gradually increase, resulting in the remaining storage space of memory 2201 being less than the first threshold. The memory management module 223 determines the first cold data in the memory 2201 according to the page replacement algorithm, and swaps the first cold data out to the Swap space. The ZRAM block device compresses the first cold data in the Swap space, and stores the compressed first cold data in the form of a swap unit (such as a zspage) in the memory 2201. At this time, the memory 2201 can be used to store the data of the application running in the background, as well as the compressed first cold data. Therefore, the used storage space is equal to the sum of the storage space occupied by the data of the application running in the background and the storage space occupied by the compressed first cold data. For example, if the rated storage space of the memory 2201 is 4000M, when the storage space occupied by the data of the application running in the background is 1500M, and the storage space occupied by the compressed first cold data is 300M, then the used storage space is equal to 1500M+300M, and the remaining storage space is equal to 4000M-1800M (1500M+300M), that is, the remaining storage space is 2200M.
需要说明的是,在电子设备200开机后,电子设备200未接收到应用的开启操作时,此时内存2201的剩余存储空间大于第一阈值,内存管理模块223无需根据页面置换算法确定内存2201中的第一冷数据,因此内存2201中不会包括压缩后的第一冷数据。It should be noted that after the electronic device 200 is turned on, when the electronic device 200 does not receive an application startup operation, the remaining storage space of the memory 2201 is greater than the first threshold, and the memory management module 223 does not need to determine the first cold data in the memory 2201 according to the page replacement algorithm. Therefore, the memory 2201 will not include the compressed first cold data.
在一些示例的实现中,第一阈值可以根据电子设备200的内存回收门限确定的。In some example implementations, the first threshold may be determined based on a memory recycling threshold of the electronic device 200 .
如,电子设备200包括多个内存回收门限。第一阈值可以为电子设备200的多个内存回收门限中的任一个。或者,第一阈值可以为电子设备200的多个内存回收门限中的最小值。第一阈值可以为电子设备200的多个内存回收门限中的最大值。或者,第一阈值可以为电子设备200的多个内存回收门限中的平均值。或者,第一阈值可以为电子设备200的指定内存回收门限与预设数值之和。此处仅是示例性给出如何根据多个内存回收门限确,确定第一阈值,本申请在此不做限定。For example, the electronic device 200 includes multiple memory recovery thresholds. The first threshold value may be any one of the multiple memory recovery thresholds of the electronic device 200. Alternatively, the first threshold value may be the minimum value of the multiple memory recovery thresholds of the electronic device 200. The first threshold value may be the maximum value of the multiple memory recovery thresholds of the electronic device 200. Alternatively, the first threshold value may be the average value of the multiple memory recovery thresholds of the electronic device 200. Alternatively, the first threshold value may be the sum of the specified memory recovery threshold of the electronic device 200 and a preset value. Here, it is only exemplified how to determine the first threshold value based on multiple memory recovery thresholds, and this application does not limit it here.
示例性的,以第一阈值可以为电子设备200的指定内存回收门限与预设数值之和为例进行说明,假设电子设备包含3个内存回收门限,分别为内存回收门限1、内存回收门限2和内存回收门限3,内存回收门限1小于内存回收门限2,内存回收门限2小于内存回收门限3。在指定内存回收门限为内存回收门限1的情况下,电子设备200确定第一阈值为内存回收门限1与指定数值之和。如:内存回收门限1为1500M,指定数值为500M,则第一阈值为2000M。Exemplarily, the first threshold value may be the sum of the specified memory recovery threshold value of the electronic device 200 and a preset value. Assume that the electronic device includes three memory recovery thresholds, namely, memory recovery threshold 1, memory recovery threshold 2, and memory recovery threshold 3. Memory recovery threshold 1 is less than memory recovery threshold 2, and memory recovery threshold 2 is less than memory recovery threshold 3. When the specified memory recovery threshold is memory recovery threshold 1, the electronic device 200 determines that the first threshold value is the sum of memory recovery threshold 1 and the specified value. For example, if memory recovery threshold 1 is 1500M and the specified value is 500M, the first threshold value is 2000M.
当然,电子设备200仅包含一个内存回收门限时,此时第一阈值等于该内存回收门限。Of course, when the electronic device 200 includes only one memory recycling threshold, the first threshold is equal to the memory recycling threshold.
在一些示例的实现中,Android系统中将内存分成固定大小的管理单元,如4KB、8KB、16KB等的内存块,称为页(Page),即内存中的数据是以页的形式存储的。In some example implementations, the Android system divides memory into fixed-size management units, such as memory blocks of 4KB, 8KB, 16KB, etc., which are called pages. That is, the data in the memory is stored in the form of pages.
一般的,可以将内存中存储的数据简称为内存页。如图9所示,电子设备200的处理器210在接收到开启应用1的操作时,处理器210通过地址映射过程寻找应用1在内存2201中存储的内存页。由于电子设备200已通过Swap模块将存储压缩后的应用1的数据换出至外部存储器2202。此时,处理器210确定内存2201中并不存在应用1的内存页,这样会发生缺页中断。当发生缺页中断时,如果电子设备200的内存2201中没有空闲内存页,则系统必须在内存2201选择一个内存页将其移出内存2201,以便为即将调入的页面让出空间。通常电子设备200根据页面置换算法确定内存2201中的可以换出的内存页,该可被待换出内存页,可以称为第一冷数据。其中,页面置换算法可以为LRU算法、最佳置换算法(OPTimalreplacement,OPT)、先进先出置换算法(First In first Out,FIFO)中的任一项。Generally, the data stored in the memory can be referred to as memory pages. As shown in FIG9 , when the processor 210 of the electronic device 200 receives an operation to start application 1, the processor 210 searches for the memory page stored by application 1 in the memory 2201 through an address mapping process. Since the electronic device 200 has swapped out the compressed data of application 1 to the external memory 2202 through the Swap module. At this time, the processor 210 determines that there is no memory page of application 1 in the memory 2201, so a page fault interruption will occur. When a page fault interruption occurs, if there is no free memory page in the memory 2201 of the electronic device 200, the system must select a memory page in the memory 2201 and move it out of the memory 2201 to make room for the page to be called in. Usually, the electronic device 200 determines the memory page that can be swapped out in the memory 2201 according to the page replacement algorithm. The memory page that can be swapped out can be called the first cold data. Among them, the page replacement algorithm can be any one of the LRU algorithm, the optimal replacement algorithm (OPT), and the first in first out replacement algorithm (FIFO).
示例性的,在页面置换算法为LRU算法的情况下,内存管理模块223可以周期性获取内存2201的剩余存储空间,并判断剩余存储空间是否小于第一阈值。在剩余存储空间小于第一阈值的情况下,内存管理模块223可以根据LRU算法确定内存2201中的待换出数据。如,后台运行的应用包括应用1和应用2,内存管理模块223根据LRU算法确定出内存2201中应用1的数据可以被换出,即第一冷数据为应用1的数据。Exemplarily, when the page replacement algorithm is the LRU algorithm, the memory management module 223 may periodically obtain the remaining storage space of the memory 2201 and determine whether the remaining storage space is less than the first threshold. When the remaining storage space is less than the first threshold, the memory management module 223 may determine the data to be swapped out in the memory 2201 according to the LRU algorithm. For example, the applications running in the background include application 1 and application 2, and the memory management module 223 determines that the data of application 1 in the memory 2201 can be swapped out according to the LRU algorithm, that is, the first cold data is the data of application 1.
S12、内存管理模块223通过ZRAM块设备将第一冷数据换至内存2201中设置的Swapspace。S12. The memory management module 223 swaps the first cold data to the Swapspace set in the memory 2201 through the ZRAM block device.
S13、ZRAM块设备对Swap space中的第一冷数据进行压缩,将压缩后的第一冷数据存储在内存2201中,内存管理模块223释放第一冷数据占用的存储空间。S13. The ZRAM block device compresses the first cold data in the Swap space, stores the compressed first cold data in the memory 2201, and the memory management module 223 releases the storage space occupied by the first cold data.
在一些示例的实现中,在内存管理模块223确定出待换出数据,或者说内存管理模块223确定出可以换出的内存页后,可通过ZRAM块设备将该内存页换出至Swap space。然后,电子设备200可通过ZRAM块设备对Swap space中的内存页进行压缩,并将压缩后的内存页重新存储在内存2201中。之后,内存管理模块223可释放压缩前的内存页所占用的存储空间。如:第一冷数据为应用1的数据,应用1的数据对应内存页1和内存页2。内存管理模块223将内存页1和内存页2换出至Swap space。然后,ZRAM块设备对Swap space中的内存页1和内存页2进行压缩,并将压缩后的内存页1和内存页2重新存储在内存2201中。之后,内存管理模块223还可释放压缩前的内存页1和内存页2在内存2201中所占用的存储空间。In some example implementations, after the memory management module 223 determines the data to be swapped out, or the memory management module 223 determines the memory page that can be swapped out, the memory page can be swapped out to the Swap space through the ZRAM block device. Then, the electronic device 200 can compress the memory page in the Swap space through the ZRAM block device, and store the compressed memory page in the memory 2201 again. Afterwards, the memory management module 223 can release the storage space occupied by the memory page before compression. For example: the first cold data is the data of application 1, and the data of application 1 corresponds to memory page 1 and memory page 2. The memory management module 223 swaps out memory page 1 and memory page 2 to the Swap space. Then, the ZRAM block device compresses the memory page 1 and memory page 2 in the Swap space, and stores the compressed memory page 1 and memory page 2 in the memory 2201 again. Afterwards, the memory management module 223 can also release the storage space occupied by the memory page 1 and memory page 2 in the memory 2201 before compression.
在一些示例的实现中,ZRAM块设备将压缩后的第一冷数据以交换单元的形式存储在第一存储器中,从而方便进行数据管理。In some example implementations, the ZRAM block device stores the compressed first cold data in the first memory in the form of a swap unit, thereby facilitating data management.
一般的,同一交换单元中的压缩后的第一冷数据的压缩率相近,如差值小于第三阈值。如:交换单元称为zspage,ZRAM块设备采用Zsmalloc内存分配器将多个差值小于第三阈值的压缩后的内存页以zspage的形式存储在内存2201中,从而提高内存2201的使用率。其中,zspage在内存2201中存储时不要求物理连续。Generally, the compression ratios of the compressed first cold data in the same exchange unit are similar, such as the difference is less than the third threshold. For example, the exchange unit is called zspage, and the ZRAM block device uses the Zsmalloc memory allocator to store multiple compressed memory pages whose difference is less than the third threshold in the form of zspage in the memory 2201, thereby improving the utilization rate of the memory 2201. Among them, the zspage does not require physical continuity when stored in the memory 2201.
示例性的,以后台运行的应用包括应用1和应用2。并且,应用1的数据对应内存页1,应用2的数据对应内存页2、内存页3和内存页4。内存管理模块223根据LRU算法确定出内存2201中第一冷数据包括内存页1,内存页2、内存页3和内存页4。内存管理模块223通过ZRAM块设备将内存页1,内存页2、内存页3和内存页4换出至内存2201中的Swap space。然后,ZRAM块设备对Swap space中的内存页1,内存页2、内存页3和内存页4进行压缩。内存页1压缩前的大小为4KB,内存页2压缩前的大小为3KB,内存页3压缩前的大小为4KB,内存页4压缩前的大小为2KB,内存页1压缩后的大小为3.5KB,内存页2压缩后的大小为2.5,内存页3压缩后的大小为3.5、内存页4压缩后的大小为2KB。压缩后的内存页1对应的压缩率1为即87.5%;压缩后的内存页2对应的压缩率2为/>即83.3%;压缩后的内存页3对应的压缩率3为/>即87.5%;压缩后的内存页4对应的压缩率4为/>即100%。在第三阈值为5%的情况下,由于压缩率1与压缩率2的差值4.2%小于5%,并且压缩率1与压缩率3的差值0小于5%,而压缩率1与压缩率4的差值12.5%大于5%。因此,采用Zsmalloc内存分配器将压缩后的内存页1、压缩后的内存页2以及压缩后的内存页3存储在同一个zspage(如zspage1),ZRAM块设备将压缩后的内存页4存储在其它zspage(如:除zspage1以外的zspage),内存管理模块223释放压缩前的内存页1,内存页2、内存页3以及内存页4在内存2201中所占用的存储空间。Exemplarily, the applications running in the background include application 1 and application 2. Furthermore, the data of application 1 corresponds to memory page 1, and the data of application 2 corresponds to memory page 2, memory page 3, and memory page 4. The memory management module 223 determines, based on the LRU algorithm, that the first cold data in memory 2201 includes memory page 1, memory page 2, memory page 3, and memory page 4. The memory management module 223 swaps out memory page 1, memory page 2, memory page 3, and memory page 4 to the Swap space in memory 2201 through the ZRAM block device. Then, the ZRAM block device compresses memory page 1, memory page 2, memory page 3, and memory page 4 in the Swap space. The size of memory page 1 before compression is 4KB, the size of memory page 2 before compression is 3KB, the size of memory page 3 before compression is 4KB, the size of memory page 4 before compression is 2KB, the size of memory page 1 after compression is 3.5KB, the size of memory page 2 after compression is 2.5, the size of memory page 3 after compression is 3.5, and the size of memory page 4 after compression is 2KB. The compression ratio of the compressed memory page 1 is 1. That is 87.5%; the compression ratio 2 corresponding to the compressed memory page 2 is/> That is 83.3%; the compression ratio 3 of the compressed memory page 3 is/> That is 87.5%; the compression ratio 4 of the compressed memory page 4 is/> That is, 100%. When the third threshold is 5%, since the difference between compression ratio 1 and compression ratio 2 (4.2%) is less than 5%, and the difference between compression ratio 1 and compression ratio 3 (0) is less than 5%, and the difference between compression ratio 1 and compression ratio 4 (12.5%) is greater than 5%. Therefore, the Zsmalloc memory allocator is used to store compressed memory page 1, compressed memory page 2, and compressed memory page 3 in the same zspage (such as zspage1), the ZRAM block device stores compressed memory page 4 in other zspages (such as zspages other than zspage1), and the memory management module 223 releases the storage space occupied by memory page 1, memory page 2, memory page 3, and memory page 4 in memory 2201 before compression.
结合上述示例,在内存管理模块223确定内存2201的剩余存储空间小于第一阈值时,根据页面置换算法确定内存2201中的第一冷数据。内存管理模块223通过ZRAM块设备将第一冷数据换出至内存2201中设置的Swap space后,ZRAM块设备需要对Swap space中的第一冷数据进行压缩,由于压缩后的第一冷数据占用的存储空间通常小于第一冷数据占用的存储空间。因此,将压缩后的第一冷数据存储在内存2201中,所占用的存储空间小于第一冷数据占用的存储空间。同时,内存管理模块223释放第一冷数据占用的存储空间,如此,可以释放出更多的存储空间,保证电子设备200的正常运行。In combination with the above example, when the memory management module 223 determines that the remaining storage space of the memory 2201 is less than the first threshold, the first cold data in the memory 2201 is determined according to the page replacement algorithm. After the memory management module 223 swaps out the first cold data to the Swap space set in the memory 2201 through the ZRAM block device, the ZRAM block device needs to compress the first cold data in the Swap space, because the storage space occupied by the compressed first cold data is usually smaller than the storage space occupied by the first cold data. Therefore, the compressed first cold data is stored in the memory 2201, and the storage space occupied is smaller than the storage space occupied by the first cold data. At the same time, the memory management module 223 releases the storage space occupied by the first cold data, so that more storage space can be released to ensure the normal operation of the electronic device 200.
示例性的,如图10所示,以内存2201的额定存储空间为100M,第一阈值为25M,内存2201中当前存储的全部数据中有25%的内存页1在ZRAM分区中被ZRAM块设备压缩后占用的存储空间小于1KB,内存2201中当前存储的全部数据中有20%的内存页2在ZRAM分区中被ZRAM块设备压缩后占用的存储空间小于2KB,内存2201中当前存储的全部数据中有19%的内存页3在ZRAM分区中被ZRAM块设备压缩后占用的存储空间小于3KB,内存2201中当前存储的全部数据中有16%的内存页4在ZRAM分区中被ZRAM块设备压缩后占用的存储空间小于4KB为例进行说明:Exemplarily, as shown in FIG10 , the rated storage space of memory 2201 is 100M, the first threshold is 25M, 25% of memory page 1 of all data currently stored in memory 2201 occupies less than 1KB of storage space after being compressed by the ZRAM block device in the ZRAM partition, 20% of memory page 2 of all data currently stored in memory 2201 occupies less than 2KB of storage space after being compressed by the ZRAM block device in the ZRAM partition, 19% of memory page 3 of all data currently stored in memory 2201 occupies less than 3KB of storage space after being compressed by the ZRAM block device in the ZRAM partition, and 16% of memory page 4 of all data currently stored in memory 2201 occupies less than 4KB of storage space after being compressed by the ZRAM block device in the ZRAM partition.
内存管理模块223确定内存2201的剩余存储空间为100M-(25%+20%+19%+16%)×100M=20M。内存管理模块223确定剩余存储空间20M小于第一阈值25M,内存管理模块223根据页面置换算法确定内存2201中的第一冷数据。其中,第一冷数据包括全部内存页1、全部内存页2、全部内存页3和全部内存页4。内存管理模块223通过ZRAM块设备将第一冷数据换出至内存2201中设置的Swap space。ZRAM块设备对Swap space中的第一冷数据进行压缩,将压缩后的第一冷数据存储在内存2201中。其中,压缩后的全部内存页1占用的存储空间为100M×3%=3M,压缩后的全部内存页2占用的存储空间为100M×7%=7M,压缩后的全部内存页3占用的存储空间为100M×14%=14M,压缩后的全部内存页4占用的存储空间为100M×16%=16M。内存管理模块223,释放第一冷数据占用的存储空间后,确定压缩户的第一冷数据占用存储空间的大小为3M+7M+14M+16M=40M。可以看出,内存2201中的第一冷数据在压缩后所占用的存储空间,相较于未压缩前第一冷数据所占用的存储空间,减少了40M的存储空间,即可以节省出40%的存储空间,用户的体验更佳。The memory management module 223 determines that the remaining storage space of the memory 2201 is 100M-(25%+20%+19%+16%)×100M=20M. The memory management module 223 determines that the remaining storage space 20M is less than the first threshold 25M, and the memory management module 223 determines the first cold data in the memory 2201 according to the page replacement algorithm. The first cold data includes all memory pages 1, all memory pages 2, all memory pages 3, and all memory pages 4. The memory management module 223 swaps out the first cold data to the Swap space set in the memory 2201 through the ZRAM block device. The ZRAM block device compresses the first cold data in the Swap space and stores the compressed first cold data in the memory 2201. Among them, the storage space occupied by all memory pages 1 after compression is 100M×3%=3M, the storage space occupied by all memory pages 2 after compression is 100M×7%=7M, the storage space occupied by all memory pages 3 after compression is 100M×14%=14M, and the storage space occupied by all memory pages 4 after compression is 100M×16%=16M. After releasing the storage space occupied by the first cold data, the memory management module 223 determines that the size of the storage space occupied by the first cold data of the compressed user is 3M+7M+14M+16M=40M. It can be seen that the storage space occupied by the first cold data in the memory 2201 after compression is reduced by 40M of storage space compared with the storage space occupied by the first cold data before compression, that is, 40% of the storage space can be saved, and the user experience is better.
S14、ZRAM块设备确定内存2201中存储的压缩后的第一冷数据所占用的存储空间大于第二阈值时,通过接口通知Swap块设备,Swap块设备通过接口从zspage模块中获取第二冷数据。S14. When the ZRAM block device determines that the storage space occupied by the compressed first cold data stored in the memory 2201 is greater than the second threshold, it notifies the Swap block device through the interface, and the Swap block device obtains the second cold data from the zspage module through the interface.
S15、zspage模块根据LRU算法和压缩率,确定第一冷数据中满足预设条件的第二冷数据,通过接口将第二冷数据发送给swap块设备。S15. The zspage module determines, according to the LRU algorithm and the compression ratio, second cold data that meets a preset condition in the first cold data, and sends the second cold data to the swap block device through an interface.
S16、Swap模块从zspage模块中获取第二冷数据,将第二冷数据存储在第二存储器,内存管理模块223释放第二冷数据对应存储空间。S16. The Swap module obtains the second cold data from the zspage module, stores the second cold data in the second memory, and the memory management module 223 releases the storage space corresponding to the second cold data.
当内存2201中存储的压缩后的第一冷数据所占用的存储空间大于第二阈值,此时说明内存2201中存储的压缩后的第一冷数据过多,导致内存2201的可用存储空间较小。为此,本申请实施例提供的存储器管理方法,Swap模块从zspage模块中获取第二冷数据后,将第二冷数据存储在第二存储器。内存管理模块223释放第二冷数据对应存储空间,使得内存2201的可用存储空间更大。When the storage space occupied by the compressed first cold data stored in the memory 2201 is greater than the second threshold, it means that there are too many compressed first cold data stored in the memory 2201, resulting in a small available storage space in the memory 2201. To this end, in the memory management method provided in the embodiment of the present application, after the Swap module obtains the second cold data from the zspage module, the second cold data is stored in the second memory. The memory management module 223 releases the storage space corresponding to the second cold data, so that the available storage space of the memory 2201 is larger.
结合上述示例,压缩后的第一冷数据存储在第一存储器时,是以交换单元的形式存储的。一般的,每个交换单元对应一个压缩率。在一些示例中,本申请的实施例将将第一冷数据中压缩率满足预设条件的交换单元存储在第二存储器,并释放对应存储空间。如此,ZRAM块设备从压缩后的第一冷数据中确定出满足预设条件的第二冷数据后,以交换单元的形式将第二冷数据存储在第二存储器,并释放对应存储空间。In combination with the above example, when the compressed first cold data is stored in the first memory, it is stored in the form of a switching unit. Generally, each switching unit corresponds to a compression rate. In some examples, the embodiments of the present application store the switching units whose compression rates in the first cold data meet the preset conditions in the second memory, and release the corresponding storage space. In this way, after the ZRAM block device determines the second cold data that meets the preset conditions from the compressed first cold data, it stores the second cold data in the second memory in the form of a switching unit, and releases the corresponding storage space.
在一些示例的实现中,电子设备200将压缩率大于第四阈值,且换入概率小于第五阈值的交换单元中所有第一冷数据存储在第二存储器中。In some example implementations, the electronic device 200 stores in the second memory all first cold data in the switching units whose compression rate is greater than a fourth threshold and whose swap-in probability is less than a fifth threshold.
在一种示例中,各交换单元的换入概率可以根据交换单元中第一冷数据被访问的概率确定。如:假设一个内存页的换入概率为p,则该交换单元中所有的压缩后的内存页都不被换入的概率为(1-p)n,n为交换单元中包含的内存页的总数,n为大于或等于1的整数。因此,该交换单元的换入概率为1-(1-p)n。结合上述示例,压缩率的确定方法以上述示例类似,此处不再赘述。In one example, the swap-in probability of each exchange unit can be determined based on the probability of the first cold data in the exchange unit being accessed. For example, assuming that the swap-in probability of a memory page is p, the probability that all compressed memory pages in the exchange unit are not swapped in is (1-p) n , where n is the total number of memory pages contained in the exchange unit, and n is an integer greater than or equal to 1. Therefore, the swap-in probability of the exchange unit is 1-(1-p) n . In conjunction with the above example, the method for determining the compression rate is similar to the above example and will not be repeated here.
示例性的,以第二存储器为UFS,交换单元为zspage,后台运行的应用包括应用1、应用2和应用3,应用1的数据对应内存页1,应用2的数据对应内存页2、内存页3和内存页4,应用3对应内存页5和内存页6,每个内存页在压缩前的大小为4KB,每个zspage的大小为4KB,zspage中包含的每个第一冷数据的压缩率的最大值为该zspage的压缩率,为例进行说明:Exemplarily, the second memory is UFS, the exchange unit is zspage, the applications running in the background include application 1, application 2 and application 3, the data of application 1 corresponds to memory page 1, the data of application 2 corresponds to memory page 2, memory page 3 and memory page 4, application 3 corresponds to memory page 5 and memory page 6, the size of each memory page before compression is 4KB, the size of each zspage is 4KB, and the maximum value of the compression rate of each first cold data contained in the zspage is the compression rate of the zspage. This is described as an example:
如图11所示,内存管理模块223根据LRU算法确定出内存2201中第一冷数据包括内存页1、内存页2、内存页3、内存页4、内存页5和内存页6。内存管理模块223通过ZRAM块设备将内存页1,内存页2、内存页3、内存页4、内存页5和内存页6换出至Swap space。ZRAM块设备对Swap space中的内存页1,内存页2、内存页3、内存页4、内存页5和内存页6进行压缩。其中,压缩后的内存页1的大小为4KB,压缩后的内存页2的大小为2KB,压缩后的内存页3的大小为2KB,压缩后的内存页4的大小为1.3KB,压缩后的内存页5的大小为1.3KB,压缩后的内存页6的大小为1.3KB。则,内存页1的压缩率为即100%;内存页2的压缩率为/>即50%;内存页3的压缩率为/>即50%;内存页4的压缩率为/>即32.5%;内存页5的压缩率为/>即32.5%;内存页6的压缩率为/>即32.5%。ZRAM块设备通常将压缩后的第一冷数据以zspage的形式存储至内存2201中。As shown in Figure 11, the memory management module 223 determines that the first cold data in the memory 2201 includes memory page 1, memory page 2, memory page 3, memory page 4, memory page 5 and memory page 6 according to the LRU algorithm. The memory management module 223 swaps out memory page 1, memory page 2, memory page 3, memory page 4, memory page 5 and memory page 6 to the Swap space through the ZRAM block device. The ZRAM block device compresses memory page 1, memory page 2, memory page 3, memory page 4, memory page 5 and memory page 6 in the Swap space. Among them, the size of the compressed memory page 1 is 4KB, the size of the compressed memory page 2 is 2KB, the size of the compressed memory page 3 is 2KB, the size of the compressed memory page 4 is 1.3KB, the size of the compressed memory page 5 is 1.3KB, and the size of the compressed memory page 6 is 1.3KB. Then, the compression rate of memory page 1 is That is 100%; the compression ratio of memory page 2 is/> That is 50%; the compression ratio of memory page 3 is/> That is 50%; the compression ratio of memory page 4 is/> That is 32.5%; the compression ratio of memory page 5 is/> That is 32.5%; the compression ratio of memory page 6 is/> That is, 32.5%. The ZRAM block device usually stores the compressed first cold data in the memory 2201 in the form of zspage.
如:ZRAM块设备将压缩率相近的内存页存储在内存2201中的同一交换单元中。压缩后的内存页1的压缩率与其它压缩后的内存页的压缩率差距较大,并且压缩后的内存页1的大小与zspage的大小相同,ZRAM块设备将压缩后的内存页1存储在内存2201中的zspage1。压缩后的内存页2的压缩率和压缩后的内存页3的压缩率相同,并且压缩后的内存页2与压缩后的内存页3的大小与zspage的大小相同,ZRAM块设备将压缩后的内存页2以及压缩后的内存页3存储在内存2201中的zspage2。压缩后的内存页4的压缩率、压缩后的内存页5的压缩率以及压缩后的内存页6的压缩率相同,并且压缩后的内存页4、压缩后的内存页5以及压缩后的内存页6的大小与zspage的大小相近,ZRAM块设备将压缩后的内存页4、压缩后的内存页5以及压缩后的内存页6存储在内存2201中的zspage3。可见,zspage1换入概率为1-(1-p),zspage2的换入概率为1-(1-p)2,zspage 3的换入概率为1-(1-p)3。For example, the ZRAM block device stores memory pages with similar compression rates in the same swap unit in memory 2201. The compression rate of compressed memory page 1 is significantly different from that of other compressed memory pages, and the size of compressed memory page 1 is the same as the size of zspage. The ZRAM block device stores compressed memory page 1 in zspage1 in memory 2201. The compression rate of compressed memory page 2 is the same as that of compressed memory page 3, and the sizes of compressed memory page 2 and compressed memory page 3 are the same as the size of zspage. The ZRAM block device stores compressed memory page 2 and compressed memory page 3 in zspage2 in memory 2201. The compression rates of compressed memory page 4, compressed memory page 5, and compressed memory page 6 are the same, and the sizes of compressed memory page 4, compressed memory page 5, and compressed memory page 6 are similar to the size of zspage. The ZRAM block device stores compressed memory page 4, compressed memory page 5, and compressed memory page 6 in zspage3 in memory 2201. It can be seen that the probability of swapping in zspage1 is 1-(1-p), the probability of swapping in zspage2 is 1-(1-p) 2 , and the probability of swapping in zspage 3 is 1-(1-p) 3 .
可见,内存页的压缩率越大,对应zspage中可存储的内存页越少,这样使得该zspage的换入概率越低。如此,本申请实施例提供的存储器管理方法,ZRAM块设备确定压缩后的第一冷数据(也称为压缩数据总量)超过第二阈值时,zspage模块根据LRU算法,确定压缩后的第一冷数据中可换出的第二冷数据。然后,根据每个zspage的换入概率,确定第二冷数据中可以被换出的数据。如:zspage模块根据LRU算法,确定压缩后的第一冷数据中可换出的第二冷数据包括:zspage1,zspage2和zspage3。由于zspage1中包含的内存页最少,对应zspage1的换入概率最低,所以优先将压缩后的应用1的数据,即zspage1换出至UFS,以避免数据颠簸的问题。It can be seen that the greater the compression rate of the memory page, the fewer memory pages that can be stored in the corresponding zspage, which makes the swap-in probability of the zspage lower. In this way, in the memory management method provided by the embodiment of the present application, when the ZRAM block device determines that the compressed first cold data (also called the total amount of compressed data) exceeds the second threshold, the zspage module determines the second cold data that can be swapped out in the compressed first cold data according to the LRU algorithm. Then, according to the swap-in probability of each zspage, determine the data that can be swapped out in the second cold data. For example: the zspage module determines that the second cold data that can be swapped out in the compressed first cold data includes: zspage1, zspage2 and zspage3 according to the LRU algorithm. Since zspage1 contains the least memory pages and the corresponding swap-in probability of zspage1 is the lowest, the compressed data of application 1, i.e. zspage1, is preferentially swapped out to UFS to avoid the problem of data thrashing.
在另一些示例的实现中,电子设备200根据各交换单元的压缩率,确定各交换单元存储在第二存储器中的顺序,直至第一存储器的可用存储空间大于第一阈值。In some other example implementations, the electronic device 200 determines the order in which the switching units are stored in the second memory according to the compression rate of each switching unit until the available storage space of the first memory is greater than the first threshold.
在一种示例中,交换单元对应的压缩率可以根据该交换单元中压缩后的第一冷数据的压缩率确定。如:将交换单元中包含的每个第一冷数据的压缩率的平均值作为该交换单元的压缩率;或者,将一个交换单元中包含的每个第一冷数据的压缩率的最大值为该交换单元的压缩率;或者,将一个交换单元中包含的每个第一冷数据的压缩率的方差为该交换单元的压缩率。此处仅是示例性给出如何根据交换单元中包含的每个第一冷数据的压缩率,确定一个交换单元的压缩率,本申请在此不做限定。In one example, the compression rate corresponding to the exchange unit can be determined based on the compression rate of the compressed first cold data in the exchange unit. For example, the average value of the compression rate of each first cold data contained in the exchange unit is used as the compression rate of the exchange unit; or, the maximum value of the compression rate of each first cold data contained in an exchange unit is used as the compression rate of the exchange unit; or, the variance of the compression rate of each first cold data contained in an exchange unit is used as the compression rate of the exchange unit. Here, it is only an example of how to determine the compression rate of an exchange unit based on the compression rate of each first cold data contained in the exchange unit, and this application does not limit it here.
在一种示例中,zspage模块根据各交换单元的压缩率,按照从大到小的顺序将交换单元中压缩后的第二冷数据。Swap模块从zspage模块中获取第二冷数据后,将第二冷数据存储在第二存储器,直至第一存储器的可用存储空间大于第一阈值。In one example, the zspage module stores the compressed second cold data in the exchange unit in descending order according to the compression rate of each exchange unit. After the Swap module obtains the second cold data from the zspage module, it stores the second cold data in the second memory until the available storage space of the first memory is greater than the first threshold.
示例性的,以将交换单元中包含的每个第一冷数据的压缩率的平均值作为该交换单元的压缩率为例进行说明。根据上述示例的描述可知,zspage1的压缩率最大,因此zspage模块先将zspage1发送至Swap模块。Swap模块从zspage模块中获取zspage1后,将zspage1存储在UFS,内存管理模块223释放zspage1在内存2201中占有的存储空间,此时内存管理模块223确定内存2201的剩余存储空间大于第一阈值,则zspage1无需再换出zspage。若Swap模块将zspage1存储在UFS后,内存管理模块223确定内存2201的剩余存储空间小于第一阈值,则zspage模块继续将zspage2发送至Swap模块。Swap模块从zspage模块中获取zspage2后,将zspage2存储在UFS,内存管理模块223释放zspage2在内存2201中占有的存储空间,此时内存管理模块223确定内存2201的剩余存储空间大于第一阈值,则无需zspage模块再换出zspage。以此类推,此处不再赘述。Exemplarily, the example of taking the average compression rate of each first cold data contained in the exchange unit as the compression rate of the exchange unit is used for explanation. According to the description of the above example, it can be seen that the compression rate of zspage1 is the largest, so the zspage module first sends zspage1 to the Swap module. After the Swap module obtains zspage1 from the zspage module, it stores zspage1 in the UFS, and the memory management module 223 releases the storage space occupied by zspage1 in the memory 2201. At this time, the memory management module 223 determines that the remaining storage space of the memory 2201 is greater than the first threshold, and zspage1 does not need to be swapped out. If the Swap module stores zspage1 in the UFS, and the memory management module 223 determines that the remaining storage space of the memory 2201 is less than the first threshold, the zspage module continues to send zspage2 to the Swap module. After the Swap module obtains zspage2 from the zspage module, it stores zspage2 in the UFS, and the memory management module 223 releases the storage space occupied by zspage2 in the memory 2201. At this time, the memory management module 223 determines that the remaining storage space of the memory 2201 is greater than the first threshold, and the zspage module does not need to swap out zspage. And so on, no further details are given here.
在又一些示例的实现中,zspage模块根据页面置换算法,确定内存2201中待换出交换单元,然后根据各交换单元的压缩率,确定各交换单元存储在第二存储器中的顺序,直至第一存储器的可用存储空间大于第一阈值。In some other example implementations, the zspage module determines the swap units to be swapped out in the memory 2201 according to a page replacement algorithm, and then determines the order in which the swap units are stored in the second memory according to the compression rate of each swap unit, until the available storage space of the first memory is greater than a first threshold.
在一种示例中,zspage模块根据LRU算法,确定内存2201中待换出交换单元,然后根据每个待换出交换单元的压缩率,按照从大到小的顺序将交换单元中第一冷数据存储在第二存储器中,直至第一存储器的可用存储空间大于第一阈值。In one example, the zspage module determines the switching units to be swapped out in the memory 2201 according to the LRU algorithm, and then stores the first cold data in the switching units in the second memory in descending order according to the compression rate of each switching unit to be swapped out until the available storage space of the first memory is greater than the first threshold.
示例性的,当内存2201中存储的待换出交换单元较多时,此时zspage模块需要确定每个待换出交换单元的压缩率,这样会耗费大量的计算资源。为此,本申请实施例提供的存储器管理方法,zspage模块根据LRU算法,确定内存2201中待换出交换单元,然后根据每个待换出交换单元的压缩率,按照从大到小的顺序将交换单元中压缩后的第一冷数据存储在第二存储器中,直至第一存储器的可用存储空间大于第一阈值。从而无需计算每个待换出交换单元的压缩率,在降低占用计算资源的同时,提高了电子设备200的换出效率。Exemplarily, when there are many exchange units to be swapped out stored in the memory 2201, the zspage module needs to determine the compression rate of each exchange unit to be swapped out, which will consume a lot of computing resources. To this end, in the memory management method provided by the embodiment of the present application, the zspage module determines the exchange units to be swapped out in the memory 2201 according to the LRU algorithm, and then stores the compressed first cold data in the exchange unit in the second memory in a descending order according to the compression rate of each exchange unit to be swapped out, until the available storage space of the first memory is greater than the first threshold. There is no need to calculate the compression rate of each exchange unit to be swapped out, and while reducing the occupied computing resources, the swapping efficiency of the electronic device 200 is improved.
一般的,每个交换单元对应一个活跃度。在一些示例中,本申请的实施例将将第一冷数据中活跃度满足预设条件的交换单元存储在第二存储器,并释放对应存储空间。Generally, each switching unit corresponds to an activity. In some examples, the embodiments of the present application store the switching units whose activities satisfy the preset conditions in the first cold data in the second memory, and release the corresponding storage space.
在又一些示例的实现中,电子设备200根据将未访问过的内存页,如将最近一段时间内未访问的内存页从活跃LRU链表(Active LRU List)移动到不活跃LRU链表(InactiveLRU List)头部,并在不活跃LRU链表中确定出可换出的内存页。In some other example implementations, the electronic device 200 moves unaccessed memory pages, such as memory pages that have not been accessed in a recent period of time, from an active LRU list (Active LRU List) to the head of an inactive LRU list (InactiveLRU List), and determines the swappable memory pages in the inactive LRU list.
在一种示例中,电子设备200从不活跃LRU链表的尾部开始依次换出内存页。In one example, the electronic device 200 swaps out memory pages in sequence starting from the end of the inactive LRU linked list.
示例性的,以页面置换算法为LRU算法为例,当电子设备200确定内存2201的剩余存储空间小于第一阈值的情况下,电子设备200根据LRU算法确定压缩后的zspage3可以被换出,此时电子设备200将如表1所示的活跃LRU链表中的zspage3移动到如表2所示的不活跃LRU链表头部。Exemplarily, taking the page replacement algorithm as the LRU algorithm as an example, when the electronic device 200 determines that the remaining storage space of the memory 2201 is less than the first threshold, the electronic device 200 determines according to the LRU algorithm that the compressed zspage3 can be swapped out. At this time, the electronic device 200 moves the zspage3 in the active LRU linked list shown in Table 1 to the head of the inactive LRU linked list shown in Table 2.
表1活跃LRU链表Table 1 Active LRU linked list
表2不活跃LRU链表Table 2 Inactive LRU linked list
表3不活跃LRU链表Table 3 Inactive LRU linked list
表4不活跃LRU链表Table 4 Inactive LRU linked list
此时,将zspage3移动到如表2所示的不活跃LRU链表头部后,不活跃LRU链表如表3所示。表3中zspage5位于不活跃LRU链表的尾部,电子设备200将zspage5存储在UFS,并释放zspage5在内存2201中所占有的存储空间,更新后的不活跃LRU链表如表4所示。若内存2201的剩余存储空间大于第一阈值,则电子设备200无需再换出zspage。若电子设备200将zspage5存储在UFS后,内存2201的剩余存储空间仍小于第一阈值,电子设备200将zspage4存储在UFS,并释放zspage4在内存2201中所占有的存储空间。若内存2201的剩余存储空间大于第一阈值,则电子设备200无需再换出zspage。以此类推,此处不再赘述。At this time, after zspage3 is moved to the head of the inactive LRU linked list as shown in Table 2, the inactive LRU linked list is as shown in Table 3. In Table 3, zspage5 is located at the tail of the inactive LRU linked list. The electronic device 200 stores zspage5 in the UFS and releases the storage space occupied by zspage5 in the memory 2201. The updated inactive LRU linked list is shown in Table 4. If the remaining storage space of the memory 2201 is greater than the first threshold, the electronic device 200 does not need to swap out the zspage. If the remaining storage space of the memory 2201 is still less than the first threshold after the electronic device 200 stores zspage5 in the UFS, the electronic device 200 stores zspage4 in the UFS and releases the storage space occupied by zspage4 in the memory 2201. If the remaining storage space of the memory 2201 is greater than the first threshold, the electronic device 200 does not need to swap out the zspage. And so on, it will not be repeated here.
需要说明的是,如图9所示,换入应用1的数据阶段包括:处理210向内存管理模块223获取应用1的数据。内存管理模块223确定内存2201中不存在应用1的数据。内存管理模块223确定Swap块设备中存在应用1的数据。Swap块设备从外部存储器2202中获取压缩后的应用1的数据。Swap块设备从外部存储器2202接收压缩后的应用1的数据。Swap块设备将压缩后的应用1的数据发送至zspage模块。ZRAM块设备从Swap块设备获取压缩后的应用1的数据。ZRAM块设备从Swap块设备中接收压缩后的应用1的数据。ZRAM块设备将压缩后的应用1的数据存储至内存2201中的Swap spac,也称为ZRAM分区。ZRAM块设备对ZRAM分区中压缩后的应用1的数据进行解压。ZRAM块设备将解压后的应用1的数据换出至内存2201。内存2201接收ZRAM块设备发送的解压后的应用1的数据。内存管理模块223将内存2201中的解压后的应用1的数据发送至处理210。处理器210根据内存管理模块223发送的解压后的应用1的数据,显示应用1最后显示界面的数据。It should be noted that, as shown in FIG9 , the data phase of swapping in application 1 includes: processing 210 obtains data of application 1 from memory management module 223. Memory management module 223 determines that data of application 1 does not exist in memory 2201. Memory management module 223 determines that data of application 1 exists in Swap block device. Swap block device obtains compressed data of application 1 from external memory 2202. Swap block device receives compressed data of application 1 from external memory 2202. Swap block device sends compressed data of application 1 to zspage module. ZRAM block device obtains compressed data of application 1 from Swap block device. ZRAM block device receives compressed data of application 1 from Swap block device. ZRAM block device stores compressed data of application 1 in Swap spac in memory 2201, also called ZRAM partition. ZRAM block device decompresses compressed data of application 1 in ZRAM partition. ZRAM block device swaps out decompressed data of application 1 to memory 2201. Memory 2201 receives decompressed data of application 1 sent by ZRAM block device. The memory management module 223 sends the decompressed data of the application 1 in the memory 2201 to the processor 210. The processor 210 displays the data of the last display interface of the application 1 according to the decompressed data of the application 1 sent by the memory management module 223.
可以理解的是,上述电子设备为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请实施例能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。本领域技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请实施例的范围。It is understandable that, in order to realize the above functions, the above electronic device includes hardware structures and/or software modules corresponding to the execution of each function. Those skilled in the art should be aware that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the embodiments of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments of the present application.
本申请实施例可以根据上述方法示例对上述电子设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。The embodiment of the present application can divide the functional modules of the above-mentioned electronic device according to the above-mentioned method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
在一种示例中,请参考图12,为本申请实施例提供一种电子设备10的组成示意图。如图12所示,该电子设备10可以包括:处理单元101。In an example, please refer to FIG12 , which is a schematic diagram of the composition of an electronic device 10 provided in an embodiment of the present application. As shown in FIG12 , the electronic device 10 may include: a processing unit 101 .
处理单元101,用于在第一存储器的可用存储空间小于第一阈值的情况下,将数据中的第一数据压缩后存储在第一存储器中。处理单元101,还用于释放压缩前第一数据占用的存储空间。处理单元101,还用于在第一存储器中压缩后的数据占用的存储空间大于第二阈值的情况下,将第二数据存储在第二存储器,第二数据为第一存储器中压缩后的数据中压缩率满足阈值条件的数据,第一存储器中压缩后的数据包括第一数据。处理单元101,还用于释放第二数据占用的存储空间。The processing unit 101 is used to compress the first data in the data and store it in the first memory when the available storage space of the first memory is less than the first threshold. The processing unit 101 is also used to release the storage space occupied by the first data before compression. The processing unit 101 is also used to store the second data in the second memory when the storage space occupied by the compressed data in the first memory is greater than the second threshold, the second data being the data in the compressed data in the first memory whose compression rate meets the threshold condition, and the compressed data in the first memory includes the first data. The processing unit 101 is also used to release the storage space occupied by the second data.
在一种可能实现方式中,处理单元101,具体用于对第一数据进行压缩;处理单元101,具体用于将压缩后的第一数据以交换单元的形式存储在第一存储器中。其中,同一交换单元中的压缩后的第一数据的压缩率差值小于第三阈值。In a possible implementation, the processing unit 101 is specifically configured to compress the first data; the processing unit 101 is specifically configured to store the compressed first data in the form of an exchange unit in the first memory, wherein the compression rate difference of the compressed first data in the same exchange unit is less than a third threshold.
在一种可能实现方式中,处理单元101,具体用于确定压缩率大于第四阈值的交换单元中所有压缩后的第一数据为第二数据。处理单元101,具体用于将第二数据存储在第二存储器。其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的。In a possible implementation, the processing unit 101 is specifically configured to determine that all compressed first data in the switching unit whose compression rate is greater than a fourth threshold value is the second data. The processing unit 101 is specifically configured to store the second data in the second memory. The compression rate of each switching unit is determined according to the compression rate of the compressed first data in the switching unit.
在一种可能实现方式中,处理单元101,具体用于确定压缩率大于第四阈值,且换入概率小于第五阈值的交换单元中所有压缩后的第一数据为第二数据。处理单元101,具体用于将第二数据存储在第二存储器。其中,各交换单元的压缩率是根据交换单元中压缩后的第一数据的压缩率确定的,各交换单元的换入概率是根据交换单元中压缩后的第一数据被访问的概率确定的。In a possible implementation, the processing unit 101 is specifically configured to determine that all compressed first data in the switching unit whose compression rate is greater than a fourth threshold value and whose swap-in probability is less than a fifth threshold value is the second data. The processing unit 101 is specifically configured to store the second data in the second memory. The compression rate of each switching unit is determined based on the compression rate of the compressed first data in the switching unit, and the swap-in probability of each switching unit is determined based on the probability of the compressed first data in the switching unit being accessed.
在一种可能实现方式中,处理单元101,具体用于根据各交换单元的压缩率,确定第二数据依次为按照从大到小的顺序将交换单元中压缩后的第一数据;处理单元101,具体用于依次将第二数据存储在第二存储器中,直至第一存储器的可用存储空间大于第一阈值。In one possible implementation, the processing unit 101 is specifically used to determine, based on the compression rate of each exchange unit, that the second data is the first data compressed in the exchange unit in order from large to small; the processing unit 101 is specifically used to store the second data in the second memory in sequence until the available storage space of the first memory is greater than the first threshold.
在一种可能实现方式中,第一存储器为内存,第二存储器为外部存储器。In a possible implementation, the first memory is a memory, and the second memory is an external memory.
当然,本发明实施例提供的电子设备10包括但不限于上述模块,例如电子设备10还可以包括存储单元102。存储单元102可以用于存储该电子设备10的程序代码,还可以用于存储电子设备10在运行过程中生成的数据,如写请求中的数据等。Of course, the electronic device 10 provided in the embodiment of the present invention includes but is not limited to the above modules, for example, the electronic device 10 may also include a storage unit 102. The storage unit 102 may be used to store the program code of the electronic device 10, and may also be used to store data generated by the electronic device 10 during operation, such as data in a write request.
本申请实施例还提供一种电子设备,该电子设备可以包括:处理器和存储器,该存储器包括内部存储器和外部存储器。该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令。当处理器执行计算机指令时,电子设备可执行上述方法实施例中手机执行的各个功能或者步骤。当然,该电子设备包括但不限于上述显示屏、存储器和一个或多个处理器。例如,该电子设备的结构可以参考图5所示的手机的结构。The embodiment of the present application also provides an electronic device, which may include: a processor and a memory, wherein the memory includes an internal memory and an external memory. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device can execute the various functions or steps executed by the mobile phone in the above method embodiment. Of course, the electronic device includes but is not limited to the above display screen, memory and one or more processors. For example, the structure of the electronic device can refer to the structure of the mobile phone shown in Figure 5.
本申请实施例还提供一种芯片系统,该芯片系统可以应用于前述实施例中的电子设备。如图13所示,该芯片系统包括至少一个处理器1501和至少一个接口电路1502。该处理器1501可以是上述电子设备中的处理器。处理器1501和接口电路1502可通过线路互联。该处理器1501可以通过接口电路1502从上述电子设备的存储器接收并执行计算机指令。当计算机指令被处理器1501执行时,可使得电子设备执行上述实施例中手机执行的各个步骤。当然,该芯片系统还可以包含其他分立器件,本申请实施例对此不作具体限定。The embodiment of the present application also provides a chip system, which can be applied to the electronic devices in the aforementioned embodiments. As shown in Figure 13, the chip system includes at least one processor 1501 and at least one interface circuit 1502. The processor 1501 can be the processor in the above-mentioned electronic device. The processor 1501 and the interface circuit 1502 can be interconnected through a line. The processor 1501 can receive and execute computer instructions from the memory of the above-mentioned electronic device through the interface circuit 1502. When the computer instructions are executed by the processor 1501, the electronic device can execute the various steps executed by the mobile phone in the above-mentioned embodiment. Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiment of the present application.
本申请实施例还提供一种计算机可读存储介质,用于存储上述电子设备(如手机)运行的计算机指令。The embodiment of the present application also provides a computer-readable storage medium for storing computer instructions executed by the above-mentioned electronic device (such as a mobile phone).
本申请实施例还提供一种计算机程序产品,包括上述电子设备(如手机)运行的计算机指令。An embodiment of the present application also provides a computer program product, including computer instructions executed by the above-mentioned electronic device (such as a mobile phone).
通过以上实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims (7)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211549506.9A CN116243850B (en) | 2021-06-08 | 2021-07-02 | Memory management method and electronic equipment |
Applications Claiming Priority (4)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202110640318 | 2021-06-08 | ||
| CN2021106403186 | 2021-06-08 | ||
| CN202211549506.9A CN116243850B (en) | 2021-06-08 | 2021-07-02 | Memory management method and electronic equipment |
| CN202110751464.6A CN113885787B (en) | 2021-06-08 | 2021-07-02 | Memory management method and electronic equipment |
Related Parent Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202110751464.6A Division CN113885787B (en) | 2021-06-08 | 2021-07-02 | Memory management method and electronic equipment |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN116243850A CN116243850A (en) | 2023-06-09 |
| CN116243850B true CN116243850B (en) | 2024-05-28 |
Family
ID=79010553
Family Applications (2)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202211549506.9A Active CN116243850B (en) | 2021-06-08 | 2021-07-02 | Memory management method and electronic equipment |
| CN202110751464.6A Active CN113885787B (en) | 2021-06-08 | 2021-07-02 | Memory management method and electronic equipment |
Family Applications After (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202110751464.6A Active CN113885787B (en) | 2021-06-08 | 2021-07-02 | Memory management method and electronic equipment |
Country Status (1)
| Country | Link |
|---|---|
| CN (2) | CN116243850B (en) |
Families Citing this family (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114579050B (en) * | 2022-02-14 | 2024-04-02 | 阿里巴巴(中国)有限公司 | Method and device for processing compressed data |
| US12386551B2 (en) * | 2022-12-15 | 2025-08-12 | Rambus Inc. | Low overhead page recompression |
| CN116560587B (en) * | 2023-07-10 | 2023-10-13 | 北京小米移动软件有限公司 | Data management system and terminal equipment |
| CN119311601A (en) * | 2023-07-14 | 2025-01-14 | 荣耀终端有限公司 | Memory management method, electronic device and storage medium |
| CN117707422B (en) * | 2023-07-14 | 2025-02-18 | 荣耀终端有限公司 | Storage method, electronic device and medium |
| CN117806986B (en) * | 2023-12-29 | 2024-10-15 | 深圳大普微电子股份有限公司 | Multi-stream management method for application data and flash memory device |
Citations (11)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR20110070429A (en) * | 2009-12-18 | 2011-06-24 | 한국과학기술원 | Memory Management System and Management Method of Virtual Machine |
| CN103729249A (en) * | 2012-10-11 | 2014-04-16 | 财团法人工业技术研究院 | Method and computer system for memory management of virtual machine |
| KR20150018690A (en) * | 2013-08-08 | 2015-02-24 | 삼성전자주식회사 | Storage device, computer system comprising the same, and operating method thereof |
| WO2015085732A1 (en) * | 2013-12-10 | 2015-06-18 | 中兴通讯股份有限公司 | Terminal memory processing method and apparatus, and terminal |
| JP2018063505A (en) * | 2016-10-12 | 2018-04-19 | 富士通株式会社 | Memory management control unit, memory management control method and memory management control program |
| CN109284187A (en) * | 2018-08-29 | 2019-01-29 | 维沃移动通信有限公司 | Application processing method, device and mobile terminal |
| KR20190036277A (en) * | 2017-09-27 | 2019-04-04 | 엘지전자 주식회사 | A method for controlling an air conditioner |
| CN110837343A (en) * | 2019-09-27 | 2020-02-25 | 华为技术有限公司 | Snapshot processing method and device and terminal |
| CN110865884A (en) * | 2019-09-30 | 2020-03-06 | 华为技术有限公司 | A memory management method and device |
| CN111290848A (en) * | 2018-12-06 | 2020-06-16 | 中兴通讯股份有限公司 | A memory optimization method, terminal and computer-readable storage medium |
| CN111880928A (en) * | 2020-07-06 | 2020-11-03 | Oppo广东移动通信有限公司 | Method for selecting process to release and terminal equipment |
Family Cites Families (17)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20060184719A1 (en) * | 2005-02-16 | 2006-08-17 | Sinclair Alan W | Direct data file storage implementation techniques in flash memories |
| CN104113759B (en) * | 2013-04-17 | 2018-03-23 | 展讯通信(上海)有限公司 | Video system, video frame buffer recompression/decompression method and device |
| CN104281528B (en) * | 2013-07-09 | 2018-02-16 | 浙江大华技术股份有限公司 | A kind of date storage method and device |
| CN104516821B (en) * | 2013-09-29 | 2017-12-19 | 晨星半导体股份有限公司 | Memory management method and memory management device |
| CN104503740A (en) * | 2014-12-01 | 2015-04-08 | 小米科技有限责任公司 | Memory management method and device |
| US10474385B2 (en) * | 2016-02-23 | 2019-11-12 | Google Llc | Managing memory fragmentation in hardware-assisted data compression |
| KR102337966B1 (en) * | 2017-05-19 | 2021-12-13 | 삼성전자주식회사 | Electronic device for compressing data and method for operation thereof |
| CN108932163A (en) * | 2018-06-15 | 2018-12-04 | 奇酷互联网络科技(深圳)有限公司 | EMS memory management process, device, readable storage medium storing program for executing and terminal |
| CN111064471B (en) * | 2018-10-16 | 2023-04-11 | 阿里巴巴集团控股有限公司 | Data processing method and device and electronic equipment |
| TWI707230B (en) * | 2018-11-22 | 2020-10-11 | 瑞昱半導體股份有限公司 | Computer system, memory management method, and non-transitory computer readable medium |
| CN112306974B (en) * | 2019-07-30 | 2024-10-22 | 深信服科技股份有限公司 | A data processing method, device, equipment and storage medium |
| CN112748863B (en) * | 2019-10-31 | 2024-04-19 | 伊姆西Ip控股有限责任公司 | Method, electronic device and computer program product for processing data |
| CN110895492B (en) * | 2019-12-11 | 2023-01-10 | Oppo(重庆)智能科技有限公司 | Device control method, device, storage medium and electronic device |
| CN111352861B (en) * | 2020-02-19 | 2023-09-29 | Oppo广东移动通信有限公司 | Memory compression method and device and electronic equipment |
| CN111966492B (en) * | 2020-08-05 | 2024-02-02 | Oppo广东移动通信有限公司 | Memory recycling method and device, electronic equipment and computer readable storage medium |
| CN111949564B (en) * | 2020-08-13 | 2024-05-17 | Vidaa(荷兰)国际控股有限公司 | Memory exchange method and display device |
| CN112162780B (en) * | 2020-09-24 | 2022-03-25 | 联想(北京)有限公司 | Application operation control method and device and electronic equipment |
-
2021
- 2021-07-02 CN CN202211549506.9A patent/CN116243850B/en active Active
- 2021-07-02 CN CN202110751464.6A patent/CN113885787B/en active Active
Patent Citations (11)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR20110070429A (en) * | 2009-12-18 | 2011-06-24 | 한국과학기술원 | Memory Management System and Management Method of Virtual Machine |
| CN103729249A (en) * | 2012-10-11 | 2014-04-16 | 财团法人工业技术研究院 | Method and computer system for memory management of virtual machine |
| KR20150018690A (en) * | 2013-08-08 | 2015-02-24 | 삼성전자주식회사 | Storage device, computer system comprising the same, and operating method thereof |
| WO2015085732A1 (en) * | 2013-12-10 | 2015-06-18 | 中兴通讯股份有限公司 | Terminal memory processing method and apparatus, and terminal |
| JP2018063505A (en) * | 2016-10-12 | 2018-04-19 | 富士通株式会社 | Memory management control unit, memory management control method and memory management control program |
| KR20190036277A (en) * | 2017-09-27 | 2019-04-04 | 엘지전자 주식회사 | A method for controlling an air conditioner |
| CN109284187A (en) * | 2018-08-29 | 2019-01-29 | 维沃移动通信有限公司 | Application processing method, device and mobile terminal |
| CN111290848A (en) * | 2018-12-06 | 2020-06-16 | 中兴通讯股份有限公司 | A memory optimization method, terminal and computer-readable storage medium |
| CN110837343A (en) * | 2019-09-27 | 2020-02-25 | 华为技术有限公司 | Snapshot processing method and device and terminal |
| CN110865884A (en) * | 2019-09-30 | 2020-03-06 | 华为技术有限公司 | A memory management method and device |
| CN111880928A (en) * | 2020-07-06 | 2020-11-03 | Oppo广东移动通信有限公司 | Method for selecting process to release and terminal equipment |
Non-Patent Citations (1)
| Title |
|---|
| "Linux Swap 与 Zram 详解";Zhizhou Tian;《泰晓科技》;1-24 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN116243850A (en) | 2023-06-09 |
| CN113885787B (en) | 2022-12-13 |
| CN113885787A (en) | 2022-01-04 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN116243850B (en) | Memory management method and electronic equipment | |
| US20230418736A1 (en) | Virtual Memory Management Method and Electronic Device | |
| KR20200074067A (en) | Electronic device and method for processing image | |
| CN111555825B (en) | Radio frequency resource allocation method and device | |
| CN114025410A (en) | Method and device for establishing network connection and electronic equipment | |
| CN110413383B (en) | Event processing method, device, terminal and storage medium | |
| EP4513334A1 (en) | Memory management method and electronic device | |
| WO2022078105A1 (en) | Memory management method, electronic device, and computer-readable storage medium | |
| CN115292052A (en) | Memory recovery method, electronic device and computer-readable storage medium | |
| CN112437341B (en) | Video stream processing method and electronic equipment | |
| CN106412625B (en) | multimedia synchronous playing method, device, terminal and system | |
| CN106412664A (en) | Multimedia synchronous playing method, device, terminal and system | |
| CN116126744B (en) | A memory recovery method, device and terminal equipment | |
| CN115858046B (en) | Method, electronic device and chip system for preloading memory pages | |
| CN114461375A (en) | Memory resource management method and electronic equipment | |
| CN114490127B (en) | Inter-core communication method, device, electronic device and storage medium | |
| CN116954876A (en) | Memory management method and electronic device | |
| WO2025139137A1 (en) | Construction method and apparatus for hybrid virtual device | |
| CN115525404A (en) | Method, device and storage medium for releasing memory | |
| CN118550689A (en) | A shared memory allocation method, device, electronic device and storage medium | |
| CN113760191B (en) | Data reading method, data reading apparatus, storage medium, and program product | |
| CN114253737B (en) | Electronic device and memory recovery method and medium thereof | |
| WO2023051056A1 (en) | Memory management method, electronic device, computer storage medium, and program product | |
| CN116709453A (en) | A communication method and electronic device | |
| CN116737356B (en) | Memory management method and electronic device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CP03 | Change of name, title or address |
Address after: Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040 Patentee after: Honor Terminal Co.,Ltd. Country or region after: China Address before: 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong Patentee before: Honor Device Co.,Ltd. Country or region before: China |
|
| CP03 | Change of name, title or address |