Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
In a mobile terminal, a memory is one of important components, and the memory is a bridge for communicating with a CPU. All programs in the mobile terminal are operated in the memory, so the performance of the memory has a large influence on the mobile terminal. The Memory is generally formed of a DRAM (Dynamic Random Access Memory), and the DRAM has a low integration level and a limited capacity.
With the development of the technology level and the increasing demand of people, Applications (APPs) installed on mobile terminals are more and more abundant. However, the cache of various application programs and the background running of useless processes make the available memory of the mobile terminal become less and less, and the problem of insufficient memory occurs. The traditional mode of managing the memory is that a kernel of the mobile terminal compresses some memory pages and stores the memory pages in the memory, so that the memory occupation is saved.
The inventor has found that, although some memory pages are compressed in the conventional method, the conventional method still occupies a large memory space.
In view of the above problems, the inventor proposes a data storage method, an apparatus, a mobile terminal, and a storage medium provided in the embodiments of the present application, which can compress memory pages that satisfy historical use conditions among currently compressed memory pages in a memory again, thereby saving memory space and improving memory utilization. Specific data storage methods are described in detail in the following embodiments.
Referring to fig. 1, fig. 1 is a schematic flow chart illustrating a data storage method according to an embodiment of the present application. The data storage method is used for carrying out secondary compression on the memory pages which meet the historical use conditions in the currently compressed memory pages in the memory, so that the memory space is saved, and the memory utilization rate is improved. In a specific embodiment, the data storage method is applied to the data storage apparatus 400 shown in fig. 5 and the mobile terminal 100 (fig. 9) configured with the data storage apparatus 400. The following will describe a specific process of this embodiment by taking a mobile terminal as an example, and it is understood that the mobile terminal applied in this embodiment may be a smart phone, a tablet computer, an electronic book, a smart watch, and the like, which is not limited herein. As will be described in detail with respect to the flow shown in fig. 1, the data storage method may specifically include the following steps:
step S110: and acquiring the current compressed memory page in the memory.
In the embodiment of the present application, the memory page that has been currently compressed refers to a memory page that has been previously compressed and then stored in the memory. Memory (also known as random access memory, RAM) refers to memory used in running programs (i.e., running memory) that can only temporarily store data for exchanging cache data with the processor, but the memory itself cannot be used for storing data for a long period of time. The applications need to occupy memory space to store data in the operating process in the operating state, and the memory space occupied by different applications in different operating states is not necessarily the same in size. The memory page is a unit of the memory managed by the operating system, where the size of the unit memory occupied by the memory page may not be limited, and the sizes of the unit memories occupied by the memory pages set by different mobile terminals may be different.
The memory pages may include anonymous pages, file pages, and the like, and are not limited herein. Wherein, the anonymous page refers to a page without file background, such as heap, stack, data segment, etc.; the file page refers to a page with a file background, a program reads a file and then generates a cache in a memory, and the file page is also called a file cache. Generally, a system kernel of a mobile terminal compresses some memory pages and stores the compressed memory pages in a memory to save memory occupation, and therefore, the compressed memory pages usually exist in the memory. For example, the least recently used anonymous pages are compressed and stored in memory.
In some embodiments, the mobile terminal may record the operation of compressing the memory page, so as to record the compressed memory page, and the mobile terminal may obtain the currently compressed memory page according to the record of compressing the memory page.
In other embodiments, the mobile terminal may add a tag to the compressed memory page, for example, tag a name of the memory page, and the like, which is not limited herein. The mobile terminal acquires the memory pages in the memory, and then can acquire the currently compressed memory pages in the memory according to the marks.
Of course, the manner in which the mobile terminal acquires the currently compressed memory page in the memory may not be limited.
As an implementation manner, the mobile terminal may set a duration every interval, acquire a currently compressed memory page in the memory, determine a subsequent memory page that may be compressed again from the memory pages, and compress the determined memory page again, that is, execute the data storage method provided in the embodiment of the present application once every interval of the set duration.
As another embodiment, the mobile terminal may also execute, according to a trigger instruction input by a user, to acquire a currently compressed memory page in the memory, to determine a subsequent memory page that can be compressed again from the memory pages, and to compress the determined memory page again, that is, to execute the data storage method provided in the embodiment of the present application according to the trigger instruction of the user.
Of course, the specific manner of triggering step S110 may not be limited in the embodiment of the present application.
Step S120: and acquiring historical use data of the memory pages.
The mobile terminal may record the historical usage data of the memory pages so that the memory pages may be managed according to the record. In some embodiments, the mobile terminal may record the usage time, usage times, usage duration, etc. of the memory page, so as to record the historical usage data of the memory page. For example, the mobile terminal may determine the usage time, the usage times, the usage duration, and the like of the memory page according to the access to the address of the memory page and thus according to the time, the number, the duration, and the like of the access. Of course, the specific historical usage data may not be limiting in the embodiments of the present application. The historical use time may be a time when the memory page is used each time, the historical use times may be a total number of times that the memory page is used, and the historical use duration may be a total duration that the memory page is used.
Step S130: and acquiring memory pages meeting the historical use conditions in the memory pages according to the historical use data as target memory pages.
After acquiring the historical usage data of the currently compressed memory pages, the mobile terminal may determine, according to the historical usage data of the memory pages, the memory pages that satisfy the historical usage conditions among the memory pages, so as to compress the memory pages that satisfy the historical usage conditions again.
In this embodiment of the present application, the mobile terminal may determine, according to the historical usage data of each memory page in the currently compressed memory pages, whether one or more of the historical usage time, the historical usage times, and the historical usage duration of the memory pages meet the historical usage condition. In this regard, the mobile terminal may be provided with a history use condition for a history use time, a history use condition for a history use number, and a history use condition for a history use time length.
In some embodiments, the historical usage condition of the historical usage time may be whether an interval between the historical usage times of the two adjacent memory pages is greater than a first preset interval, for example, for a memory page a, if the interval between the historical usage times of the two adjacent memory pages a is 60 hours, and the preset time interval is 50 hours, the historical usage time of the memory page a satisfies the historical usage condition; the historical usage condition of the historical usage time may be that whether an interval between the latest usage time and the current time is greater than a second preset interval, for example, if the interval between the latest usage time of the memory page B and the current time is 30 hours, and the second preset interval is 20 hours, the historical usage time of the memory page B satisfies the historical usage condition. Of course, the specific historical use condition corresponding to the historical use time may not be limited.
In some embodiments, the historical usage condition for the historical usage times may be whether the historical usage times of the memory page is less than a preset time, for example, if the historical usage times of the memory page a is less than 3 times, the historical usage times of the memory page a satisfies the historical usage condition; the historical usage condition of the historical usage number may be that the historical usage number of the memory page is the smallest, for example, if the historical usage number of the memory page B is the smallest in the currently compressed memory pages, the historical usage number of the memory page B satisfies the historical usage condition.
In some embodiments, the historical use condition of the historical use duration may be whether the historical use duration of the memory page is less than a preset duration, for example, if the historical use duration of the memory page a is less than 10 minutes, the historical use duration of the memory page a meets the historical use condition; the historical usage condition of the historical usage duration may also be that the historical usage duration of the memory page is the smallest, for example, if the historical usage duration of the memory page B is the smallest in the currently compressed memory pages, the historical usage duration of the memory page B satisfies the historical usage condition.
It can be understood that, the mobile terminal determines a memory page satisfying the historical usage condition in the currently compressed memory pages, and may determine that one or more of the historical usage time, the historical usage times, and the historical usage duration satisfies the historical usage condition, for example, if the historical usage time and the historical usage times of the memory page a satisfy the historical usage condition at the same time, it indicates that the memory page a satisfies the historical usage condition, which is not limited herein.
Of course, in the embodiment of the present application, a specific historical usage condition may not be used as a limitation, and the historical usage condition may be used to obtain a memory page that is used less or will not be used in a longer time later from a currently compressed memory page.
After determining the memory pages meeting the historical use conditions from the currently compressed memory pages, the mobile terminal may use the memory pages meeting the historical use conditions as target memory pages, where the target memory pages are the subsequent memory pages that can be compressed again.
Step S140: and compressing and storing the target memory page again.
In this embodiment of the present application, after determining, from the currently compressed memory pages, the memory pages that satisfy the historical usage condition, the mobile terminal may compress the target memory pages again, so as to reduce the memory occupied by the target memory pages. Therefore, multi-level (multiple) compression of the memory page can be realized, and the specific compression level and the compression size can be set according to actual requirements.
According to the data storage method provided by the embodiment of the application, the historical use data of the memory pages are obtained by obtaining the currently compressed memory pages in the memory, the memory pages meeting the historical use conditions in the memory pages are obtained according to the historical use data and serve as the target memory pages, and the target memory pages are compressed and stored again, so that the deep compression of the memory pages is realized, the memory space can be saved, and the memory utilization rate is improved.
Referring to fig. 2, fig. 2 is a schematic flow chart illustrating a data storage method according to another embodiment of the present application. The method is applied to the mobile terminal, and will be described in detail with respect to the flow shown in fig. 2, where the data storage method may specifically include the following steps:
step S210: and acquiring the current compressed memory page in the memory.
Step S220: and acquiring historical use data of the memory pages.
In the embodiment of the present application, step S210 and step S220 may refer to the contents of the foregoing embodiments, and are not described herein again. The acquired historical usage data of the current compressed memory page may include at least historical usage time.
Step S230: and acquiring the latest used time of each memory page of the memory pages according to the historical used time.
In this embodiment of the present application, the mobile terminal may determine whether the historical use time of the memory pages meets the historical use condition according to the historical use time of the currently compressed memory pages, so as to obtain the memory pages meeting the historical use condition from the memory pages.
In some embodiments, the mobile terminal may obtain the last used time of each memory page in the currently compressed memory pages according to the historical used time of the currently compressed memory pages. For example, the currently compressed memory pages include a memory page C, the acquired historical use time of the memory page C includes 16 o ' clock at 10/2019, 45 o ' clock at 10 o ' clock at 15/2019, 30 o ' clock at 10 o ' clock at 15/18/2019, 12 o ' clock at 17 o ' clock at 18/2019, the current time when the mobile terminal executes the data storage method is 19 o ' clock at 18/20 o ' clock at 2019/2019, and the last use time of the memory page C is 12 o ' clock at 17 o ' clock at 18/2019.
Step S240: and sequencing the latest used time of each memory page according to the time sequence to obtain a sequencing result.
In this embodiment of the present application, after obtaining the last used time of each memory page in the currently compressed memory pages, the mobile terminal may sequence the last used times according to the time sequence, so as to determine memory pages meeting the historical use condition according to the sequencing result in the following. For example, the currently compressed memory pages include a memory page a, a memory page B, and a memory page C, the last time of use of the memory page a is 9/17/08 in 2019, the last time of use of the memory page B is 16/16 in 2019/16/2019, and the last time of use of the memory page C is 19/00 in 2019/18/19, the last time of use of the memory page a, the last time of use of the memory page B, and the last time of use of the memory page C are sorted in chronological order, and the sorting result is 16/24 in 2019/16/2019/17/9, 08 in 2019, and 19/18/19 in 2019.
Step S250: and acquiring a memory page corresponding to the head in the sequencing result as a target memory page.
In this embodiment of the present application, after the mobile terminal sorts, according to the time sequence, the most recently used time corresponding to each memory page in the currently compressed memory pages, the memory pages that satisfy the historical use condition may be determined according to the sorting result. Specifically, the mobile terminal may obtain the most recently used time ranked at the head from the ranking result, determine the memory page corresponding to the head as the memory page meeting the historical use condition, and use the memory page corresponding to the head as the target memory page, that is, the subsequent memory page that can be compressed again. It can be understood that the time of the last use of the target memory page is longest from the current time, which indicates that the memory page is not used for a long time and may not be used subsequently, so that the memory page may be used as the target memory page that can be compressed again.
Step S260: and compressing and storing the target memory page again.
In this embodiment of the present application, after determining the target memory page, the mobile terminal may further determine whether the target memory page meets a condition that the target memory page can be compressed again, for example, whether a compression rate of the target memory page reaches a set threshold, that is, whether the target memory page is compressed to a minimum and cannot be compressed again. If the target memory page meets the condition of being compressed again, the target memory page can be compressed again, and multi-level compression of the memory page is achieved.
The data storage method provided by the embodiment of the application obtains the historical use data of the memory pages by obtaining the currently compressed memory pages in the memory, sorts the latest used time of each memory page in the memory pages according to the time sequence of the latest used time of each compressed memory page in the historical use data to obtain a sorting result, uses the memory page corresponding to the first bit in the sorting result as a target memory page, and then compresses and stores the target memory page again, thereby realizing the deep compression of the memory pages which are not used for a long time, saving the memory space and improving the memory utilization rate.
Referring to fig. 3, fig. 3 is a schematic flow chart illustrating a data storage method according to another embodiment of the present application. The method is applied to the mobile terminal, and will be described in detail with respect to the flow shown in fig. 3, where the data storage method may specifically include the following steps:
step S310: and acquiring the current compressed memory page in the memory.
Step S320: and acquiring historical use data of the memory pages.
In the embodiment of the present application, step S310 and step S320 may refer to the contents of the foregoing embodiments, and are not described herein again.
Step S330: and acquiring memory pages meeting the historical use conditions in the memory pages according to the historical use data as target memory pages.
In the embodiment of the present application, the historical usage condition may include: the method comprises the steps that the historical use times in a preset time period are smaller than a first set time, the historical use time in the preset time period is smaller than a set time, the historical use times in the preset time period are minimum, or the historical use time in the preset time period is minimum.
In some embodiments, the preset time period may be a time period within a preset time period before the current time, that is, a time period within a latest preset time period, and the preset time period may be 24 hours, 36 hours, or the like, which is not limited herein. It can be understood that, in a preset time period, if a memory page whose historical usage times is less than a first set time exists in the currently compressed memory pages, this indicates that the memory page is not frequently used in a recent time period after being compressed, and therefore the memory page may be compressed again, and the memory page is used as the target memory page. In a preset time period, if there is a history use duration less than a set duration in the currently compressed memory page, it indicates that the used time of the memory page in the last time period is short after the memory page is compressed, that is, the memory page is not frequently used, so that the memory page may be compressed again, and the memory page is used as the target memory page. In the preset time period, the history use frequency corresponding to the target memory page is the minimum, and may also indicate that the memory page is not frequently used, so that the memory page may be compressed again, and the memory page may be used as the target memory page. In the preset time period, the history use time corresponding to the target memory page is the smallest, which may also indicate that the memory page is not frequently used, so that the memory page may be compressed again, and the memory page is used as the target memory page. The specific first set number of times and the set time period may not be limited, and for example, the first set number of times may be 1 or 2, and the set time period may be 0.1 minute or 2 minutes.
In the embodiment of the present application, the historical usage condition may also be a combination of the above historical usage conditions, for example, the historical usage condition may be that the historical duration is the smallest and the historical usage duration is less than a set duration, the historical usage condition may also be that the historical frequency duration is the smallest and the historical usage frequency is less than a first set frequency, and a specific historical usage condition may not be limited.
Step S340: and acquiring the compressed times of the target memory page.
In this embodiment of the present application, after determining, from currently compressed memory pages, a target memory page that meets a historical usage condition, before compressing the target memory page again, the mobile terminal may further obtain the number of times that the target memory page has been compressed, so as to determine whether the target memory page can be compressed again according to the number of times that the target memory page has been compressed.
In some embodiments, the number of times the target memory page is compressed refers to the number of times the target memory page is compressed relative to an uncompressed state. For example, for a memory page a, the original size before being compressed is 150 Mega (MB), the original size is compressed to 50MB at 10: 10/9/2019, the original size is compressed to 50MB, the original size is used at 12: 10/11/2019/9, the memory page is decompressed and then used, the size is recovered to 150MB, the original size is compressed to 50MB at 11: 12/13/2019, and the memory page a is not compressed and decompressed before the current time, so that the corresponding compression times of the memory page is 1; for another example, if the original size of the memory page B before compression is 300MB, the memory page B is compressed to 100MB at 11: 00 at 12: 9/2019, and is compressed again at 20: 20 at 11: 14: 9/2019, and is compressed from 100MB to 30MB, but the memory page B is not compressed and decompressed before the current time, the number of times of compression corresponding to the memory page is 2.
In some embodiments, the mobile terminal may obtain the number of times that the target memory page has been compressed according to the recorded compression record of the memory page. It can be understood that, each time the mobile terminal compresses the memory page, the compression record may be recorded, so that the mobile terminal may obtain the number of times that the target memory page has been compressed according to the compression record.
Step S350: and judging whether the compression times are less than a second set time.
In this embodiment of the present application, after obtaining the compressed compression times, the mobile terminal may determine whether the compressed compression times of the target memory page is less than a second set time. The second set number of times may be a preset number of times that the memory page may be compressed, that is, a set level that the memory page may be compressed, and the specific number of times of compression may be set according to an actual requirement, for example, may be set to 3 times, and may also be set to 4 times. If the compression times reaches a second set time (equal to or greater than the second set time), the level of the current memory page which is compressed reaches the set level and can not be compressed any more; if the compression frequency does not reach the second set frequency (less than the second set frequency), the current memory page can be compressed again if the compressed hierarchy does not reach the set hierarchy.
Step S360: and if the compression times are less than a second set time, performing the second compression and storage on the target memory page.
In this embodiment of the application, if it is determined in step S350 that the number of times of compression is smaller than the second set number of times, the target memory page may be compressed again and stored in the memory.
In this embodiment of the present application, if the number of times that the target memory page is compressed is less than the second set number of times, the compressing and storing the target memory page again may include:
if the compression times are smaller than a second set time, acquiring a compression rate corresponding to the compression times; and according to the compression rate, compressing and storing the target memory page again.
It can be understood that, after the memory page is compressed for multiple times, the deeper the hierarchy of the memory page that is compressed (the more the compression times), the greater the difficulty of each compression, and the smaller the compression size, therefore, the corresponding relationship between the compression times and the compression ratio, that is, the corresponding relationship between the compression hierarchy and the compression ratio, may be set, and the greater the compression times, the higher the compression ratio. The compression ratio refers to the ratio of the size of the file after compression to the size before compression. For example, the compression rate of the memory page may be 0.33 when the first tier compression is performed, the compression rate of the memory page may be 0.44 when the second tier compression is performed, and the compression rate may be 0.5 when the third tier compression is performed.
Further, the mobile terminal may obtain a compression ratio corresponding to the compression frequency of the target memory page according to the corresponding relationship between the compression frequency and the compression ratio, and then compress and store the target memory page again according to the obtained compression ratio.
In some embodiments, the data storage method may further include: if the number of times of compressing the currently compressed memory page is equal to or greater than the second set number of times, the target memory page may not be compressed.
In further embodiments, the data storage method may further include: if the compression times are equal to or greater than the second set times and the compression times are less than a third set times, judging whether the residual memory of the memory is less than a memory threshold value or not, wherein the third set times are greater than the second set times; and if the residual memory is smaller than the memory threshold, compressing and storing the target memory page again.
It can be understood that, if the number of times that the target memory page is compressed is equal to or greater than the second set number of times, it indicates that the number of times that the target memory page is compressed reaches the set number of times, in this case, the target memory page may still be compressed by a certain size, but the difficulty of compression is relatively large, so that the target memory page may not be compressed in a normal case, and in a case that the system remaining memory of the mobile terminal is low, the target memory page may be compressed, so as to reduce the memory usage and increase the remaining memory of the system.
Therefore, if the mobile terminal determines that the compression frequency of the target memory page is equal to or greater than the second set frequency, the current remaining memory of the mobile terminal may be obtained to determine whether the remaining memory is smaller than the memory threshold. For example, when an operating system of the mobile terminal is an Android system, the current available memory amount of the memory of the mobile terminal can be obtained by an activitymanager.
After the mobile terminal acquires the remaining memory, it may determine whether the remaining memory is smaller than a memory threshold, where the size of the memory threshold may not be limited, for example, the size may be set to compress the target memory page for a second set number of times, and the size may not affect the operation of the mobile terminal. If the residual memory of the mobile terminal is smaller than the memory threshold, the residual memory of the mobile terminal is less, so that the target memory page can be compressed, the occupation of the memory is reduced, and the available memory of the mobile terminal is increased. If the residual memory of the mobile terminal is equal to or greater than the memory threshold, it indicates that the residual memory of the mobile terminal is more, so that the target memory page is not compressed any more, and the problem that the compression difficulty is higher and the system load is increased when the compression frequency reaches the second set frequency is avoided.
In an embodiment of the present application, the data storage method may further include: after the preset duration, the step of obtaining the currently compressed memory page in the memory is executed again, to the step of compressing and storing the target memory page again, until the compression ratio of the target memory page is smaller than the set compression ratio. It can be understood that the mobile terminal can execute the data storage method provided by the embodiment of the present application once every preset time interval, so that multi-level compression on the memory page can be realized, an effect of deep compression on the memory page is achieved, and the memory utilization rate is improved.
The data storage method provided by the embodiment of the application obtains the historical use data of each memory page in the current compressed memory page by obtaining the current compressed memory page in the memory, obtains the memory page meeting the historical use condition in the current compressed memory page as the target memory page according to the historical use data, obtains the compressed compression times of the target memory page again, then judges whether the compression times is less than the second set times, if the compression times of the target memory page is less than the second set times, executes to compress and store the target memory page again, thereby realizing the deep compression of the compressed memory page meeting the historical use condition, saving the memory space and improving the memory utilization rate.
Referring to fig. 4, fig. 4 is a schematic flowchart illustrating a data storage method according to still another embodiment of the present application. The method is applied to the mobile terminal, and will be described in detail with respect to the flow shown in fig. 4, where the data storage method may specifically include the following steps:
step S410: and acquiring the current compressed memory page in the memory.
Step S420: and acquiring historical use data of the memory pages.
Step S430: and acquiring memory pages meeting the historical use conditions in the memory pages according to the historical use data as target memory pages.
In the embodiment of the present application, steps S410 to S430 may refer to the memory of the foregoing embodiment, and are not described herein again.
Step S440: and determining a compression rate corresponding to the historical use data according to the historical use data.
In this embodiment of the present application, after determining, from the currently compressed memory pages, a target memory page that meets the historical usage condition, when the target memory page is compressed again, the mobile terminal may determine, according to the historical usage data, a compression ratio corresponding to the historical usage data, so that the current compression ratio corresponds to the historical usage data of the target memory page.
In some embodiments, the mobile terminal may determine a compression rate corresponding to the historical usage data according to historical usage time, historical usage times, historical usage duration, and the like in the historical usage data. In one embodiment, the greater the number of historical uses of the target memory page, the higher the probability that the target memory page is used, and therefore, the greater the number of historical uses, the higher the compression rate of this time, so as to avoid the difficulty in decompressing the target memory page when it is used again, which increases the system load of the mobile terminal. As another mode, the shorter the interval of the historical use time when the target memory page is used twice next to each other, the higher the probability that the target memory page is used is, and therefore, the shorter the interval, the higher the compression rate of this time is, so as to avoid that the difficulty of decompression when the target memory page is used again is large, and the system load of the mobile terminal is increased. In another mode, the longer the historical use time of the target memory page is, the higher the possibility that the target memory page is used is, so that the longer the historical use time is, the higher the compression rate of the current time is, so as to avoid that the difficulty of decompression when the target memory page is used again is large, and the system load of the mobile terminal is increased. Of course, the specific manner of determining the compression rate according to the historical usage data may not be limited, and for example, the compression rate of the target memory page may also be determined together according to the historical usage time, the historical usage times, and the historical usage duration, so that the possibility that the target memory page is used may be evaluated more comprehensively.
Step S450: and according to the compression rate, compressing and storing the target memory page again.
In the data storage method provided in the embodiment of the present application, by obtaining the currently compressed memory pages in the memory, historical usage data of each memory page in the currently compressed memory pages is obtained, according to the historical use data, obtaining the memory pages meeting the historical use conditions in the current compressed memory pages as target memory pages, then determining the compression rate corresponding to the historical use data according to the historical use data, finally compressing the target memory page according to the compression rate, so that the compression rate of the current target memory page compression corresponds to the historical usage data of the target memory page, therefore, the compressed memory pages meeting the historical use conditions are deeply compressed, the memory space can be saved, the memory utilization rate is improved, the problem that the target memory pages are difficult to decompress when being used again is avoided, and the system burden of the mobile terminal is increased.
Referring to fig. 5, a block diagram of a data storage device 400 according to an embodiment of the present disclosure is shown. The data storage device 400 is applied to the mobile terminal, and the data storage device 400 includes: the memory page compression module 440 includes a first memory page obtaining module 410, a used data obtaining module 420, a second memory page obtaining module 430, and a memory page compression module. The first memory page obtaining module 410 is configured to obtain a currently compressed memory page in a memory; the usage data obtaining module 420 is configured to obtain historical usage data of the memory page; the second memory page obtaining module 430 is configured to obtain, according to the historical usage data, a memory page that meets a historical usage condition in the memory pages, as a target memory page; the memory page compression module 440 is configured to compress and store the target memory page again.
In some embodiments, the historical usage data may include historical usage times. Referring to fig. 6, the second memory page obtaining module 430 may include a time obtaining unit 431, a time sorting unit 432, and a memory page determining unit 433. The time obtaining unit 431 is configured to obtain, according to the historical use time, a last used time of each memory page of the memory pages; the time sorting unit 432 is configured to sort the time, used for the last time, of each memory page according to a time sequence to obtain a sorting result; the memory page determining unit 433 is configured to obtain a memory page corresponding to a first bit in the sorting result, and use the memory page as a target memory page.
In other embodiments, the historical usage conditions may include: the method comprises the steps that the historical use times in a preset time period are smaller than a first set time, the historical use time in the preset time period is smaller than a set time, the historical use times in the preset time period are minimum, or the historical use time in the preset time period is minimum.
In the embodiment of the present application, please refer to fig. 7, the data storage apparatus 400 may further include: a compression number obtaining module 450 and a compression number judging module 460. The compression frequency obtaining module 450 is configured to obtain the compressed compression frequency of the target memory page before the memory page compression module 440 compresses and stores the target memory page again; the compression frequency judging module 460 is configured to judge whether the compression frequency is smaller than a second set frequency; if the compression frequency is smaller than a second set frequency, the memory page compression module 440 compresses and stores the target memory page again.
Further, the memory page compression module 440 may be specifically configured to: if the compression times are smaller than a second set time, acquiring a compression rate corresponding to the compression times; and according to the compression rate, compressing and storing the target memory page again.
In some embodiments, the data storage device 400 may further include a memory determination module. The memory judgment module is used for judging whether the residual memory of the memory is smaller than a memory threshold value or not if the compression times are equal to or larger than the second set times and the compression times are smaller than a third set times, wherein the third set times are larger than the second set times; the memory page compression module 440 may be further configured to compress and store the target memory page again if the remaining memory is smaller than the memory threshold.
In some embodiments, referring to fig. 8, the memory page compression module 440 may include: a compression rate acquisition unit 441 and a compression execution unit 442. The compression rate obtaining unit 441 is used for determining the compression rate corresponding to the historical use data according to the historical use data; the compression execution unit 442 is configured to compress and store the target memory page again according to the compression rate.
In the embodiment of the present application, the data storage device 400 may further include a re-execution module. The re-execution module is configured to, after a preset duration, re-execute the step of obtaining the currently compressed memory page in the memory to the step of compressing and storing the target memory page again until a compression ratio of the target memory page is smaller than a set compression ratio.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses and modules may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, the coupling between the modules may be electrical, mechanical or other type of coupling.
In addition, functional modules in the embodiments of the present application may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
To sum up, the scheme that this application provided acquires the historical use data of RAM page through acquiring the present compressed RAM page in the memory, according to historical use data, acquires the RAM page that satisfies historical service conditions in the RAM page, as the target RAM page, compresses and stores target RAM page once more to the realization is to the deep compression of memory page, can save the memory space, promotes the memory utilization ratio.
Referring to fig. 9, a block diagram of a mobile terminal according to an embodiment of the present application is shown. The mobile terminal 100 may be an electronic device capable of running an application, such as a smart phone, a tablet computer, an electronic book, and a smart wearable device. The mobile terminal 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by the one or more processors 110, the one or more programs configured to perform a method as described in the aforementioned method embodiments.
Processor 110 may include one or more processing cores. The processor 110 interfaces with various components throughout the mobile terminal 100 using various interfaces and lines, and performs various functions of the mobile terminal 100 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 120 and invoking data stored in the memory 120. Alternatively, the processor 110 may be implemented in hardware using at least one of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 110 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing display content; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 110, but may be implemented by a communication chip.
The Memory 120 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). The memory 120 may be used to store instructions, programs, code sets, or instruction sets. The memory 120 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing various method embodiments described below, and the like. The storage data area may also store data created by the terminal 100 in use, such as a phonebook, audio-video data, chat log data, and the like.
Referring to fig. 10, a block diagram of a computer-readable storage medium according to an embodiment of the present application is shown. The computer-readable medium 800 has stored therein a program code that can be called by a processor to execute the method described in the above-described method embodiments.
The computer-readable storage medium 800 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. Alternatively, the computer-readable storage medium 800 includes a non-volatile computer-readable storage medium. The computer readable storage medium 800 has storage space for program code 810 to perform any of the method steps of the method described above. The program code can be read from or written to one or more computer program products. The program code 810 may be compressed, for example, in a suitable form.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not necessarily depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.