Method and device for memory defragmentation

By predicting device usage behavior information and memory status information, memory defragmentation is carried out in advance, the performance problems caused by memory fragmentation of smart devices are solved and the user experience is improved.

CN111949563BActive Publication Date: 2024-12-17SHANGHAI LONGCHEER TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010809381.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-12
Publication Date
2024-12-17
Estimated Expiration
2040-08-12

AI Technical Summary

Technical Problem

The smart device has memory fragmentation after the system runs for a long time, resulting in the inability to apply for a large continuous page frame, affecting the user's performance experience. The existing defragmentation method is not conducive to performance optimization.

Method used

By determining the user's prediction device usage behavior information and current memory status information, predict whether memory defragmentation is required, and when necessary, call the memory defragmentation program for sorting, setting the number of defragmentation threshold to avoid resource waste.

Benefits of technology

Memory defragmentation is carried out in advance to improve user performance experience and avoid performance degradation caused by improper defragmentation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111949563B_ABST
    Figure CN111949563B_ABST
Patent Text Reader

Abstract

The purpose of this application is to provide a method and device for memory defragmentation. Compared with the prior art, this application determines the user's predicted device usage behavior information, wherein the user's predicted device usage behavior information is the user's device usage behavior information after a preset time interval, and then determines whether memory defragmentation is required based on the user's predicted device usage behavior information and current memory status information. When memory defragmentation is required, a memory defragmentation program is called to perform memory defragmentation. In this way, by obtaining the predicted device usage behavior information to determine whether to perform memory defragmentation, it is possible to perform defragmentation in advance and improve the user's performance experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a technology for memory defragmentation. Background Art

[0002] After a smart device has been running in the system for a long time, memory fragmentation will occur. That is, in a section of free page frames, there will be some scattered page frames in use, causing this section of page frames to be divided into small sections of continuous page frames by these scattered pages in use. In this case, when memory application requires a large section of continuous page frames, it cannot be applied for. The current defragmentation call timing is mainly when continuous page frames cannot be obtained or when memory is short, and defragmentation is passively called. This method is not conducive to user performance experience. Summary of the invention

[0003] The purpose of this application is to provide a method and device for memory defragmentation.

[0004] According to one aspect of the present application, a method for memory defragmentation is provided, wherein the method comprises:

[0005] Determining predicted device usage behavior information of the user, wherein the predicted device usage behavior information of the user is the user's device usage behavior information after a preset time interval;

[0006] Determining whether memory defragmentation is required based on the user's predicted device usage behavior information and current memory status information;

[0007] When memory defragmentation is needed, call the memory defragmentation program to perform memory defragmentation.

[0008] Further, the determining of the predicted device usage behavior information of the user includes:

[0009] Obtaining historical device usage behavior information corresponding to the user;

[0010] The predicted device usage behavior information of the user is determined based on the historical device usage behavior information corresponding to the user.

[0011] Furthermore, the determining whether memory defragmentation is required based on the predicted device usage behavior information and current memory status information of the user includes:

[0012] determining predicted memory usage information based on the predicted device usage behavior information of the user;

[0013] Based on the predicted memory usage information and the current memory state information, it is determined whether memory defragmentation is required.

[0014] Further, the determining whether memory defragmentation is required based on the predicted memory usage information and the current memory state information includes:

[0015] When the predicted memory usage information is greater than the preset memory usage information, determining whether the current memory state information is greater than the preset memory state information;

[0016] When the current memory state information is greater than the preset memory state information, it is determined that memory defragmentation is required.

[0017] Further, the preset memory state information includes a preset fragmentation index threshold and / or a preset page frame number threshold, the current memory state information includes a corresponding current fragmentation index and / or a current page frame number, wherein the determining whether memory defragmentation is required based on the predicted memory usage information and the current memory state information includes:

[0018] The current fragmentation index and / or the current number of page frames are compared with a preset fragmentation index threshold and / or a preset page frame number threshold to determine whether memory defragmentation is required.

[0019] Further, when memory defragmentation is required, calling a memory defragmentation program to perform memory defragmentation includes:

[0020] When memory defragmentation is required, it is determined whether the current number of defragmentation times reaches the defragmentation times threshold;

[0021] If the current defragmentation times do not reach the defragmentation times threshold, the memory defragmentation program is called to perform memory defragmentation.

[0022] Furthermore, the method further comprises:

[0023] After the memory defragmentation is completed, the current defragmentation count is increased by one, and whether memory defragmentation is needed is continuously determined based on the predicted device usage behavior information of the user and the current memory state information, until the current defragmentation count reaches the defragmentation count threshold.

[0024] According to another aspect of the present application, a device for memory defragmentation is also provided, wherein the device comprises:

[0025] A first device is used to determine predicted device usage behavior information of a user, wherein the predicted device usage behavior information of the user is the user's device usage behavior information after a preset time interval;

[0026] A second device is used to determine whether memory defragmentation is required based on the predicted device usage behavior information of the user and the current memory state information;

[0027] The third device is used for calling a memory defragmentation program to perform memory defragmentation when memory defragmentation is needed.

[0028] According to another aspect of the present application, a computer-readable medium is provided, on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement the operations of the aforementioned method.

[0029] Compared with the prior art, the present application determines the user's predicted device usage behavior information, wherein the user's predicted device usage behavior information is the user's device usage behavior information after a preset time interval, and then determines whether memory defragmentation is required based on the user's predicted device usage behavior information and current memory status information. When memory defragmentation is required, the memory defragmentation program is called to perform memory defragmentation. In this way, by obtaining the predicted device usage behavior information to determine whether to perform memory defragmentation, it is possible to perform defragmentation in advance and improve the user's performance experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0031] Figure 1 A flow chart of a method for memory defragmentation according to one aspect of the present application is shown;

[0032] Figure 2 A schematic diagram of a device for memory defragmentation according to another aspect of the present application is shown.

[0033] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION

[0034] The present invention is further described in detail below in conjunction with the accompanying drawings.

[0035] In a typical configuration of the present application, the terminal, the device of the service network and the trusted party all include one or more processors (CPU), input / output interfaces, network interfaces and memories.

[0036] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0037] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory media such as modulated data signals and carrier waves.

[0038] Figure 1 A flow chart of a method for memory defragmentation provided by one aspect of the present application is shown. The method is executed by a device 1 and includes the following steps:

[0039] S11 determines the predicted device usage behavior information of the user, wherein the predicted device usage behavior information of the user is the user's device usage behavior information after a preset time interval;

[0040] S12 determines whether memory defragmentation is required based on the user's predicted device usage behavior information and current memory status information;

[0041] S13 When memory defragmentation is required, a memory defragmentation program is called to perform memory defragmentation.

[0042] In the present application, the method is performed by device 1, where device 1 includes a network device or a user terminal device. For example, device 1 is a computer device and / or a cloud, where the computer device includes but is not limited to a personal computer, a laptop computer, an industrial computer, a network host, a single network server, and a plurality of network server sets; the cloud is composed of a large number of computers or network servers based on cloud computing, where cloud computing is a type of distributed computing, a virtual supercomputer composed of a group of loosely coupled computer sets. For another example, device 1 includes a user terminal device capable of running various applications, such as device 1 including but not limited to any mobile electronic product that can interact with a user through a touchpad, such as a smart phone, a tablet computer, etc., and the mobile electronic product can use any operating system, such as an Android operating system, an iOS operating system, etc.

[0043] Here, the network device or user terminal device is only an example. Other existing or future network devices or user terminal devices that are applicable to the present application should also be included in the protection scope of the present application and are included herein by reference.

[0044] In this embodiment, in the step S11, the predicted device usage behavior information of the user is determined, wherein the predicted device usage behavior information of the user is the user's device usage behavior information after a preset time interval.

[0045] Among them, the predicted device usage behavior information refers to the relevant operation information on the device after a preset time interval, such as the relevant operation information of opening various applications on the mobile phone, etc. For example, here, the preset time interval is a pre-set time interval, and the specific value can be set according to the actual experience value, and is not limited here. Specifically, the method of determining the user's predicted device usage behavior information can be based on the user's current device usage behavior information. For example, the user currently opens the map application on the mobile phone, and it can be predicted that the user will use the map navigation function next. Therefore, the predicted device usage information can be determined as map navigation.

[0046] Preferably, the step S11 includes: S111 (not shown) acquiring historical device usage behavior information corresponding to the user; S112 (not shown) determining predicted device usage behavior information of the user based on the historical device usage behavior information corresponding to the user.

[0047] In this embodiment, the predicted device usage behavior information of the user will be determined through the historical device usage behavior information corresponding to the user. For example, the device usage behavior information of the user over a period of time will be counted, and the running memory requirements of commonly used applications will be recorded. For example, through the historical device usage behavior information of the user, it is found that the user is accustomed to going out at eight o'clock in the morning and needs to use the map navigation function. Therefore, the predicted device usage behavior information at eight o'clock in the morning can be determined to be map navigation. Then, according to the running memory requirements of the navigation function on the user's device, defragmentation is performed in advance to prepare the memory for opening the navigation application, so as to achieve zero delay in starting the application in the sense of user experience. Here, the above-mentioned method of determining the predicted device usage behavior information of the user is only an example, and other existing or future methods that are applicable to this application should also be included in the scope of protection of this application, and are included here by reference.

[0048] Continuing with this embodiment, in step S12, it is determined whether memory defragmentation is required based on the predicted device usage behavior information of the user and / or the current memory status information.

[0049] Specifically, since memory defragmentation is to obtain continuous page frames, it is possible to determine whether memory defragmentation is necessary by determining the user's predicted device usage behavior information and / or current memory status information. For example, certain device usage behavior information may be pre-set, and when the predicted device usage behavior information is the pre-set device usage behavior information, it may be confirmed that memory defragmentation is necessary; or, the judgment may be made based on the current memory status information, and if the current available memory is greater than the preset value, memory defragmentation is not necessary; or, the judgment may be made based on the user's predicted device usage behavior information and the current memory status information, for example, when the predicted device usage behavior information is the pre-set device usage behavior information and the current memory is lower than the preset value, memory defragmentation may be performed.

[0050] Preferably, the step S12 includes: S121 (not shown) determining predicted memory usage information based on the user's predicted device usage behavior information; S122 determining whether memory defragmentation is required based on the predicted memory usage information and the current memory status information.

[0051] In this embodiment, when the predicted device usage behavior information of the user is determined, the predicted memory usage information corresponding to the execution of the predicted device usage behavior can be further determined based on the predicted device usage behavior information. For example, here, the predicted memory usage information includes the memory size for executing the predicted device usage behavior, or can be represented by the size of a continuous memory page. Among them, the current memory state information refers to the available memory information corresponding to the device, for example, the current remaining available memory size, or it can also be represented by the size of a continuous memory page.

[0052] Preferably, the step S122 includes: S1221 (not shown) when the predicted memory usage information is greater than the preset memory usage information, determining whether the current memory status information is greater than the preset memory status information; S1222 (not shown) when the current memory status information is greater than the preset memory status information, determining that memory defragmentation is required.

[0053] Specifically, whether memory defragmentation is needed can be determined by comparing the predicted memory usage information with the current memory status information. For example, if the current memory status information is greater than or exceeds the predicted memory usage information by a preset value, it is determined that memory defragmentation is not needed; if the current memory status information does not exceed the predicted memory usage information, it is determined that memory defragmentation is needed, and so on.

[0054] Here, the method of determining whether memory defragmentation is needed is only an example, and other existing or future possible methods, if applicable to the present application, should also be included in the protection scope of the present application, and are included here by reference.

[0055] Preferably, the preset memory state information includes a preset fragmentation index threshold and / or a preset page frame number threshold, and the current memory state information includes a corresponding current fragmentation index and / or a current page frame number, wherein step S122 includes:

[0056] The current fragmentation index and / or the current number of page frames are compared with a preset fragmentation index threshold and / or a preset page frame number threshold to determine that memory defragmentation is required.

[0057] Specifically, the preset fragmentation index threshold and the preset page frame number threshold can be determined according to the specific device conditions after a large number of experiments. Because memory defragmentation consumes CPU resources and will inevitably increase power consumption, when the fragmentation index reaches a certain level to start defragmentation, it is necessary to take into account both performance and power consumption. Therefore, on different devices and different CPU chips, this value should be obtained based on experimental data to achieve a balance between power consumption and performance. Among them, the current number of page frames refers to the number of page frames currently available.

[0058] Specifically, when determining whether memory defragmentation is required, the determination can be made by comparing the current fragmentation index and / or the current number of page frames with a preset fragmentation index threshold and / or a preset number of page frames threshold. For example, if the current fragmentation index is greater than the preset fragmentation index threshold, it is determined that memory defragmentation is required, or if the current number of page frames is less than the preset number of page frames threshold, it is determined that memory defragmentation is required, or if the current fragmentation index is greater than the preset fragmentation index threshold and the current number of page frames is less than the preset number of page frames threshold, it is determined that memory defragmentation is required.

[0059] Continuing with this embodiment, in step S13, when memory defragmentation is required, a memory defragmentation program is called to perform memory defragmentation.

[0060] Preferably, the step S13 includes: S131 (not shown) when memory defragmentation is required, determining whether the current defragmentation times reaches the defragmentation times threshold; S132 (not shown) if the current defragmentation times does not reach the defragmentation times threshold, calling the memory defragmentation program to perform memory defragmentation.

[0061] In this embodiment, a defragmentation times threshold value needs to be set in advance, and the memory defragmentation program will be called to perform memory defragmentation only when the defragmentation times threshold value is not reached.

[0062] Since defragmentation itself consumes system resources, it requires performance and power consumption to reach a balance point. Therefore, after we have defragmented many times in a row, if the fragmentation index cannot reach our expected goal due to too many non-recyclable pages and anonymous pages in the system, at this time, we should stop defragmentation when the maximum number limit is reached, wait for the system to recycle memory, kill the process, and then defragment again. Therefore, set the defragmentation number threshold to avoid wasting resources.

[0063] Preferably, the method also includes: S14 (not shown) after the memory defragmentation is completed, the current defragmentation count is increased by one, and whether memory defragmentation is needed is continued based on the user's predicted device usage behavior information and current memory status information, until the current defragmentation count reaches the defragmentation count threshold.

[0064] In this embodiment, in step S14, the number of defragmentation times is recorded after each memory defragmentation is completed, and is incremented by one each time the defragmentation is completed until the current number of defragmentation times reaches the defragmentation times threshold. If the defragmentation is successful when the current number of defragmentation times reaches the defragmentation times threshold, the current number of defragmentation times is reset to zero to facilitate subsequent defragmentation.

[0065] After each defragmentation is completed, the current fragmentation index and the number of consecutive page frames are re-determined to defragment again until the current fragmentation index is better than the preset fragmentation index threshold or the current defragmentation times reach the preset defragmentation times threshold, then exit and wait for the next time the algorithm predicts that defragmentation is needed.

[0066] In addition, an embodiment of the present application also provides a computer-readable medium on which computer-readable instructions are stored, and the computer-readable instructions can be executed by a processor to implement the aforementioned method.

[0067] Figure 2 A schematic diagram of a device for memory defragmentation according to another aspect of the present application is shown, wherein the device 1 comprises:

[0068] The first device 11 is used to determine the predicted device usage behavior information of the user, wherein the predicted device usage behavior information of the user is the user's device usage behavior information after a preset time interval;

[0069] The second device 12 is used to determine whether memory defragmentation is needed based on the predicted device usage behavior information of the user and the current memory state information;

[0070] The third device 13 is used for calling a memory defragmentation program to perform memory defragmentation when memory defragmentation is needed.

[0071] The embodiment of the present application also provides a device for memory defragmentation, wherein the device includes:

[0072] one or more processors; and

[0073] A memory storing computer readable instructions which, when executed, cause the processor to perform the operations of the aforementioned method.

[0074] For example, when the computer-readable instructions are executed, the one or more processors: determine the user's predicted device usage behavior information, wherein the user's predicted device usage behavior information is the user's device usage behavior information after a preset time interval; determine whether memory defragmentation is required based on the user's predicted device usage behavior information and current memory status information; and when memory defragmentation is required, call a memory defragmentation program to perform memory defragmentation.

[0075] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

Claims

1. A method for memory defragmentation, wherein: The method comprises: Determining predicted device usage behavior information of the user, wherein the predicted device usage behavior information of the user is the user's device usage behavior information after a preset time interval; Determining whether memory defragmentation is required based on the predicted device usage behavior information and / or current memory state information of the user; When memory defragmentation is needed, call the memory defragmentation program to perform memory defragmentation; Wherein, when memory defragmentation is required, calling a memory defragmentation program to perform memory defragmentation includes: When memory defragmentation is required, it is determined whether the current number of defragmentation times reaches the defragmentation times threshold; If the current defragmentation times do not reach the defragmentation times threshold, call the memory defragmentation program to perform memory defragmentation; After the memory defragmentation is completed, the current defragmentation count is increased by one, and whether memory defragmentation is needed is continuously determined based on the predicted device usage behavior information of the user and the current memory state information, until the current defragmentation count reaches the defragmentation count threshold.

2. The method according to claim 1, wherein: The determining of the predicted device usage behavior information of the user includes: Obtaining historical device usage behavior information corresponding to the user; The predicted device usage behavior information of the user is determined based on the historical device usage behavior information corresponding to the user.

3. The method according to claim 1 or 2, wherein: The determining whether memory defragmentation is required based on the predicted device usage behavior information and / or current memory state information of the user includes: determining predicted memory usage information based on the predicted device usage behavior information of the user; Based on the predicted memory usage information and the current memory state information, it is determined whether memory defragmentation is required.

4. The method according to claim 3, wherein: The determining whether memory defragmentation is required based on the predicted memory usage information and the current memory state information includes: When the predicted memory usage information is greater than the preset memory usage information, determining whether the current memory state information is greater than the preset memory state information; When the current memory state information is greater than the preset memory state information, it is determined that memory defragmentation is required.

5. The method according to claim 4, wherein: The preset memory state information includes a preset fragmentation index threshold and / or a preset page frame number threshold, and the current memory state information includes a corresponding current fragmentation index and / or a current page frame number, wherein the determining whether memory defragmentation is required based on the predicted memory usage information and the current memory state information includes: The current fragmentation index and / or the current number of page frames are compared with a preset fragmentation index threshold and / or a preset page frame number threshold to determine whether memory defragmentation is required.

6. A device for memory defragmentation, wherein: The device comprises: A first device is used to determine predicted device usage behavior information of a user, wherein the predicted device usage behavior information of the user is the user's device usage behavior information after a preset time interval; A second device is used to determine whether memory defragmentation is required based on the predicted device usage behavior information of the user and the current memory state information; The third device is used for calling the memory defragmentation program to perform memory defragmentation when memory defragmentation is needed; When memory defragmentation is required, calling a memory defragmentation program to perform memory defragmentation includes: When memory defragmentation is required, it is determined whether the current number of defragmentation times reaches the defragmentation times threshold; If the current defragmentation times do not reach the defragmentation times threshold, call the memory defragmentation program to perform memory defragmentation; After the memory defragmentation is completed, the current defragmentation count is increased by one, and whether memory defragmentation is needed is continuously determined based on the predicted device usage behavior information of the user and the current memory state information, until the current defragmentation count reaches the defragmentation count threshold.

7. A computer-readable medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the method according to any one of claims 1 to 5.

8. A device for memory defragmentation, wherein: The equipment includes: one or more processors; and A memory storing computer readable instructions which, when executed, cause the processor to perform the operations of the method as claimed in any one of claims 1 to 5.