Method and apparatus for memory defragmentation
By predicting future application demands and memory fragmentation levels, memory fragmentation is addressed in advance, resolving application performance issues caused by memory fragmentation, ensuring application speed and smoothness, and improving user experience.
Patent Information
- Application Number
- CN201911220114.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-12-03
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2039-12-03
AI Technical Summary
In existing technologies, memory fragmentation causes applications to malfunction, and it is impossible to predict and defragment memory fragments in advance, thus affecting user experience.
By predicting the applications that users may launch in the future, and judging the memory status based on the memory fragmentation index, memory defragmentation is performed in advance to release unnecessary memory resources and ensure that applications run normally.
Effectively predict and defragment memory fragments to ensure fast and smooth application startup and improve user experience.
Smart Images

Figure CN110968523B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular to a method and apparatus for memory defragmentation. Background Technology
[0002] Memory is a crucial component of a computer system, serving as both a data storage unit and a cache between high-speed execution units and external, slower storage components. Memory management is a fundamental function in computer software systems; effective memory management ensures efficient memory utilization and reduces memory fragmentation (multiple small blocks of free memory). After a period of operation, memory fragmentation typically occurs, and excessive fragmentation can prevent certain software modules from functioning correctly.
[0003] Current technology first determines whether the memory state is abnormal, and only performs memory defragmentation if the memory state is abnormal.
[0004] If a user launches an application before memory defragmentation is complete, the current memory will be insufficient to meet the application's normal operating requirements. Summary of the Invention
[0005] This application provides a method and apparatus for memory defragmentation, which can predict memory fragmentation problems in advance and perform memory defragmentation to ensure the normal operation of applications and thus improve user experience.
[0006] In a first aspect, embodiments of this application provide a method for defragmenting memory, comprising: predicting applications that a user may launch within a preset time period after the current moment; and performing memory defragmentation if the memory resources required for the application to run are greater than the preset memory resources.
[0007] In one possible implementation, before performing memory defragmentation, the method further includes: obtaining the fragmentation state of the memory; and performing memory defragmentation based on the fragmentation state of the memory.
[0008] In one possible implementation, obtaining the fragmentation state of the memory includes: obtaining the number of consecutive available page frames for different page numbers of the memory; and determining the fragmentation state of the memory based on the number of consecutive available page frames for different page numbers of the memory.
[0009] In one possible implementation, determining the state of the memory based on the number of consecutive available page frames for different page numbers includes: determining the fragmentation index of the memory based on the number of consecutive available page frames for different page numbers; wherein, the larger the fragmentation index of the memory, the more severe the fragmentation of the memory.
[0010] In one possible implementation, performing memory defragmentation based on the memory fragmentation state includes: performing memory defragmentation if the memory fragmentation index is greater than a preset index threshold.
[0011] In one possible implementation, performing memory defragmentation includes: performing memory defragmentation if the memory resources required for the application to run are less than the available memory resources.
[0012] In one possible implementation, the memory defragmentation process further includes: if the memory resources required for the application to run are greater than the available memory resources, then releasing the memory resources occupied by the application that are not currently in use.
[0013] In one possible implementation, the preset exponential threshold is related to the size of the memory.
[0014] In one possible implementation, predicting the applications that a user may launch within a preset time period after the current time includes: obtaining the user's historical behavior in using the applications; and predicting the applications that a user may launch within a preset time period after the current time based on the user's historical behavior in using the applications.
[0015] Secondly, embodiments of this application provide a memory defragmentation device, comprising:
[0016] The prediction module is used to predict the applications that the user may launch within a preset time period after the current moment.
[0017] The processing module is used to perform memory defragmentation if the memory resources required for the application to run are greater than the preset memory resources.
[0018] In one possible implementation, the apparatus of this application embodiment may further include an acquisition module;
[0019] The acquisition module is used to acquire the fragmentation status of the memory before the processing module performs memory defragmentation.
[0020] The processing module is specifically used to: perform memory defragmentation based on the memory fragmentation state.
[0021] In one possible implementation, the acquisition module is specifically used to: acquire the number of consecutive available page frames for different page numbers of the memory; and determine the fragmentation state of the memory based on the number of consecutive available page frames for different page numbers of the memory.
[0022] In one possible implementation, the acquisition module is specifically used to: determine the fragmentation index of the memory based on the number of consecutive available page frames for different page numbers of the memory; wherein, the larger the fragmentation index of the memory, the more severe the fragmentation of the memory.
[0023] In one possible implementation, the processing module is specifically used to: perform memory defragmentation if the memory fragmentation index is greater than a preset index threshold.
[0024] In one possible implementation, the processing module is specifically used to: perform memory defragmentation if the memory resources required for the application to run are less than the available memory resources.
[0025] In one possible implementation, the processing module is further configured to: if the memory resources required for the application to run are greater than the available memory resources, then release the memory resources occupied by the application that are not currently in use.
[0026] In one possible implementation, the preset exponential threshold is related to the size of the memory.
[0027] In one possible implementation, the prediction module is specifically used to: acquire the user's historical behavior in using the application; and predict the application that the user may launch within a preset time period after the current time based on the user's historical behavior in using the application.
[0028] Thirdly, embodiments of this application provide an electronic device, including a memory and a processor; the memory is coupled to the processor; the memory is used to store program instructions; the processor is used to invoke the program instructions in the memory to execute the method as described in any one of the first aspects and its possible implementations.
[0029] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed, implements the method as described in any one of the first aspects and its possible implementations.
[0030] Fifthly, embodiments of this application provide a program product comprising a computer program stored in a readable storage medium, wherein at least one processor can read the computer program from the readable storage medium, and the at least one processor executes the computer program to implement the method as described in any one of the first aspects and its possible implementations.
[0031] The memory defragmentation method and apparatus provided in this application can predict memory fragmentation problems in advance and perform memory defragmentation, thereby ensuring the normal operation of applications and improving user experience. Attached Figure Description
[0032] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0033] Figure 1 An application scenario diagram provided for one embodiment of this application;
[0034] Figure 2 A flowchart illustrating a method for defragmenting memory fragments provided in an embodiment of this application;
[0035] Figure 3 A flowchart illustrating a method for defragmenting memory fragments provided in another embodiment of this application;
[0036] Figure 4 A flowchart illustrating a method for defragmenting memory fragments provided in another embodiment of this application;
[0037] Figure 5 A schematic diagram of a memory defragmentation apparatus provided in an embodiment of this application;
[0038] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0039] Figure 7 A block diagram of an electronic device 800 provided in an embodiment of this application. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0041] Figure 1 An application scenario diagram provided for one embodiment of this application, such as... Figure 1As shown, the memory defragmentation method and apparatus provided in this embodiment can be applied to electronic devices with memory, including: mobile terminal devices and computer devices, such as mobile phones, tablet computers, home computers, etc.
[0042] Figure 2 A flowchart of a memory defragmentation method provided in an embodiment of this application is shown below. Figure 2 As shown, the method in this embodiment may include:
[0043] S201, Predict the applications that the user may launch within a preset time period after the current moment.
[0044] This application embodiment can be applied to electronic devices that have applications installed on them, allowing users to launch these applications to perform corresponding operations. In this embodiment, it is possible to predict which applications the user may launch within a preset time period after the current moment; for example, it is possible to predict that the user may launch an application within the next 5 minutes.
[0045] In some embodiments, one possible implementation of S201 is: obtaining the user's historical behavior in using the application; and based on the user's historical behavior in using the application, predicting the application that the user may launch within a preset time period after the current time.
[0046] Optionally, S201 can statistically analyze a user's behavioral habits based on their historical behavior over a month, such as needing to launch the Baidu Maps application for navigation on their way to work at 8:00 AM and launching a game application at 9:00 PM.
[0047] S202. If the memory resources required for the application to run are greater than the preset memory resources, then memory defragmentation is performed.
[0048] In some embodiments, one possible implementation of S202 is as follows: after predicting that an application that the user may launch within a preset time period after the current time, it is determined whether the memory resources required for the application to run are greater than the preset memory resources. If the memory resources required for the application to run are greater than the preset memory resources, it indicates that the application requires a lot of memory resources to run. Then, memory defragmentation is performed to ensure that the memory after defragmentation meets the requirements for the application to run, and to ensure that the application starts up quickly and smoothly.
[0049] Optionally, if the memory resources required for the application to run are less than or equal to the preset memory resources, it indicates that the memory resources required for the application to run are small, there is no need to perform memory defragmentation, and the current memory will meet the requirements for the application to run.
[0050] The memory defragmentation method provided in this embodiment predicts the applications that a user may launch within a preset time period after the current moment. If the memory resources required for the application to run are greater than the preset memory resources, then memory defragmentation is performed. Therefore, this embodiment can perform memory defragmentation before the application starts, ensuring that the defragmented memory meets the requirements for the application to run, ensuring that the application starts quickly and smoothly, and improving the user experience.
[0051] Figure 3 A flowchart of a memory defragmentation method provided in another embodiment of this application is shown below. Figure 3 As shown, the embodiments of this application can be applied to electronic devices, and the method of this embodiment may include:
[0052] S301, Predict the applications that the user may launch within a preset time period after the current moment.
[0053] In this embodiment, the specific implementation process of S301 can be found in [reference needed]. Figure 2 The relevant descriptions in the illustrated embodiments will not be repeated here.
[0054] S302. If the memory resources required for the application to run are greater than the preset memory resources, obtain the fragmentation status of the memory.
[0055] In this embodiment, if the predicted memory resources required for the application to run are greater than the preset memory resources, since electronic devices generally develop memory fragmentation after working for a period of time, a large number of memory fragments may prevent the application from running normally. Therefore, memory fragmentation defragmentation is required. Before defragmenting the memory fragmentation, the memory fragmentation status of the electronic device needs to be obtained.
[0056] In some embodiments, one possible implementation of obtaining the fragmentation state of the memory in S302 above is: obtaining the number of consecutive available page frames of different page numbers of the memory respectively; and determining the fragmentation state of the memory based on the number of consecutive available page frames of different page numbers of the memory.
[0057] In this embodiment, the number of consecutive available page frames for one page, two pages, four pages, etc., is obtained, and then the memory fragmentation state is determined based on these consecutive available page frames. Specifically, this embodiment divides all available memory into 11 block linked lists in the form of powers of 2, corresponding to consecutive available page frames of 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, and 1024 pages, respectively. When there is no memory fragmentation problem, the number of consecutive available page frames for different page numbers is at its maximum. As memory fragmentation occurs, the number of consecutive available page frames for different page numbers gradually decreases, and memory fragmentation becomes increasingly severe. Therefore, this embodiment can determine the memory fragmentation state based on the number of consecutive available page frames for different page numbers.
[0058] In some embodiments, one possible implementation of determining the state of the memory based on the number of consecutive available page frames of different page numbers is as follows: determining the fragmentation index of the memory based on the number of consecutive available page frames of different page numbers; wherein, the larger the fragmentation index of the memory, the more severe the fragmentation of the memory.
[0059] In this embodiment, the function used to calculate the memory fragmentation index is, for example, `__fragmentation_index`. The input value of this function is the number of consecutive available page frames at different page numbers, and the return value is the memory fragmentation index. The closer the return value is to 1000, the more severe the memory fragmentation, and the less available contiguous memory resources there are. A return value of -1000 indicates sufficient memory, and the current memory state can guarantee the normal operation of the aforementioned application. Therefore, it can be seen that the higher the memory fragmentation index, the more severe the memory fragmentation.
[0060] Optionally, the function may return a value of 0, indicating that there is no free memory resource left. In this case, even if memory defragmentation is performed, the normal operation of the application cannot be guaranteed.
[0061] S303. Perform memory defragmentation based on the memory fragmentation status.
[0062] In this embodiment, after obtaining the fragmentation state of the memory, it is determined whether memory defragmentation needs to be performed based on the fragmentation state. If it is needed, memory defragmentation is performed; otherwise, the process ends.
[0063] In some embodiments, one possible implementation of S303 is: if the memory fragmentation index is greater than a preset index threshold, then memory defragmentation is performed.
[0064] In this embodiment, the electronic device stores a preset index threshold. After obtaining the memory fragmentation index, it is determined whether the memory fragmentation index is greater than the preset index threshold. If the memory fragmentation index is greater than the preset index threshold, it indicates that the memory fragmentation is severe and the available contiguous memory resources are scarce. Therefore, memory defragmentation is performed to increase the available contiguous memory resources. When the memory fragmentation index is less than or equal to the preset index threshold, it indicates that the memory fragmentation is not severe and memory defragmentation is not required.
[0065] Optionally, the preset index threshold is related to the size of the memory. For example, the preset index threshold corresponding to 4G of memory is greater than the preset index threshold corresponding to 2G of memory.
[0066] Optionally, the preset index threshold is an index threshold determined based on startup speed and smoothness when performing performance tests on electronic devices.
[0067] The memory defragmentation method provided in this embodiment predicts the applications that a user may launch within a preset time period after the current moment; if the memory resources required for the application to run are greater than the preset memory resources, the fragmentation state of the memory is obtained; and memory defragmentation is performed based on the memory fragmentation state. This embodiment can determine whether memory defragmentation needs to be performed before the application starts based on the memory fragmentation state. If memory fragmentation is severe, memory defragmentation needs to be performed first to ensure that the defragmented memory meets the requirements for application operation, ensuring rapid and smooth application startup and improving user experience.
[0068] Figure 4 A flowchart of a memory defragmentation method provided in another embodiment of this application is shown below. Figure 4 As shown, the method in this embodiment may include:
[0069] S401, Predict the applications that the user may launch within a preset time period after the current moment.
[0070] In this embodiment, the specific implementation process of S401 can be found in [reference needed]. Figure 2 The relevant descriptions in the illustrated embodiments will not be repeated here.
[0071] S402. If the memory resources required for the application to run are greater than the preset memory resources, determine whether the memory resources required for the application to run are less than the available memory resources. If yes, proceed to S403; otherwise, proceed to S404.
[0072] S403, Perform memory defragmentation.
[0073] S404. Release memory resources occupied by applications that are not currently in use.
[0074] In this embodiment, if the memory resources required for the application to run are greater than the preset memory resources, it is further determined whether the memory resources required for the application to run are less than the available memory resources. If the memory resources required for the application to run are less than the available memory resources, it means that all available memory resources can meet the memory resource requirements for starting the application. Then, memory fragmentation is performed to organize the fragmented memory resources into continuous available memory resources that can be used by the application, so as to ensure the normal operation of the application.
[0075] Optionally, if the memory resources required for the application to run are greater than or equal to the available memory resources, the available memory resources will not increase even if memory fragmentation is performed. To ensure that the application can run normally, memory resources occupied by applications that the user is not currently using can be released to increase the available memory resources.
[0076] Before releasing memory resources from applications the user is not currently using, the process includes: determining which applications the user will not use at the current time, and then releasing the memory resources of those applications. For example, if the user will not use games or video applications during work hours, then the memory resources of those applications can be released to increase available free memory resources. The determination of which applications the user will not use at the current time can be based on the user's historical behavior.
[0077] The memory defragmentation method provided in this embodiment predicts the applications that the user may launch within a preset time period after the current moment; it then determines whether the memory resources required for the application to run are less than the available memory resources. If so, memory defragmentation is performed; otherwise, memory resources occupied by currently unused applications are released. This ensures that the available memory resources can meet the requirements for application operation, guaranteeing rapid and smooth application startup and improving the user experience.
[0078] Figure 5 A schematic diagram of the structure of a memory defragmentation apparatus provided in an embodiment of this application is shown below. Figure 5 As shown, the memory defragmentation device provided in this embodiment includes a prediction module 501 and a processing module 502.
[0079] The prediction module 501 is used to predict the applications that the user may launch within a preset time period after the current moment.
[0080] The processing module 502 is used to perform memory defragmentation based on the fragmentation state of the memory.
[0081] In one possible implementation, the memory defragmentation apparatus of this application embodiment may further include an acquisition module 503.
[0082] The acquisition module 503 is used to acquire the fragmentation status of the memory before the processing module 502 performs memory defragmentation.
[0083] In one possible implementation, the acquisition module 503 is specifically used to: acquire the number of consecutive available page frames for different page numbers of the memory; and determine the fragmentation state of the memory based on the number of consecutive available page frames for different page numbers of the memory.
[0084] In one possible implementation, the acquisition module 503 is specifically used to: determine the fragmentation index of the memory based on the number of consecutive available page frames for different page numbers of the memory; wherein, the larger the fragmentation index of the memory, the more severe the fragmentation of the memory.
[0085] In one possible implementation, the processing module 502 is specifically used to: perform memory defragmentation if the memory fragmentation index is greater than a preset index threshold.
[0086] In one possible implementation, the processing module 502 is specifically used to: if the memory resources required for the application to run are less than the available memory resources, then perform memory defragmentation.
[0087] In one possible implementation, the processing module 502 is further configured to: if the memory resources required for the application to run are greater than the available memory resources, then release the memory resources occupied by the application that are not currently in use.
[0088] In one possible implementation, the preset exponential threshold is related to the size of the memory.
[0089] In one possible implementation, the prediction module 501 is specifically used to: acquire the user's historical behavior in using the application; and predict the application that the user may launch within a preset time period after the current time based on the user's historical behavior in using the application.
[0090] The memory defragmentation device provided in this embodiment can be used to perform... Figures 2 to 4 The technical solutions of any of the method embodiments shown in the text are similar in implementation principle and technical effect, and will not be described again here.
[0091] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, as shown below. Figure 6As shown, the electronic device provided in this embodiment includes: a memory 601, a processor 602 and a memory 603, wherein the memory 601 is coupled to the processor 602.
[0092] The memory 601 is used to store program instructions.
[0093] The processor 602 is used to execute program instructions stored in the memory 601:
[0094] Predict the applications that a user may launch within a preset time period after the current moment;
[0095] If the memory resources required for the application to run are greater than the preset memory resources, then memory defragmentation (603) will be performed.
[0096] In one possible implementation, the processor 602, before performing memory defragmentation 603, is further configured to:
[0097] Obtain the fragmentation status of the memory 603;
[0098] When the processor 602 performs memory defragmentation on the memory 603, it is specifically used to: perform memory defragmentation on the memory 603 according to the fragmentation state of the memory 603.
[0099] In one possible implementation, when the processor 602 obtains the fragmentation state of the memory 603, it specifically performs the following:
[0100] Obtain the number of consecutive available page frames for different page numbers of the memory 603;
[0101] The fragmentation state of the memory 603 is determined based on the number of consecutive available page frames for different page numbers of the memory 603.
[0102] In one possible implementation, when the processor 602 determines the state of the memory 603 based on the number of consecutive available page frames of different page numbers, it specifically performs the following:
[0103] The fragmentation index of memory 603 is determined based on the number of consecutive available page frames for different page numbers of memory 603;
[0104] The larger the fragmentation index of the memory 603, the more severe the fragmentation of the memory 603.
[0105] In one possible implementation, when the processor 602 performs memory defragmentation based on the fragmentation state of the memory 603, it specifically performs the following:
[0106] If the fragmentation index of memory 603 is greater than a preset index threshold, then memory 603 defragmentation is performed.
[0107] In one possible implementation, when the processor 602 performs memory defragmentation 603, it is specifically used for:
[0108] If the memory resources required for the application to run are less than the available memory resources of memory 603, then memory 603 defragmentation is performed.
[0109] In one possible implementation, the processor 602 is further configured to:
[0110] If the memory resources required for the application to run are greater than the available memory resources of 603, then release the memory resources occupied by the application that are not currently in use.
[0111] In one possible implementation, the preset index threshold is related to the size of the memory 603.
[0112] In one possible implementation, when the processor 602 predicts applications that the user may launch within a preset time period after the current moment, it is specifically used for:
[0113] Obtain the user's historical behavior when using the application;
[0114] Based on the user's historical behavior when using applications, predict the applications the user may launch within a preset time period after the current time.
[0115] The electronic device provided in this embodiment can be used to perform... Figures 2 to 4 The technical solutions of the method embodiments shown are similar in principle and in effect, and will not be described again here.
[0116] Figure 7 This is a block diagram of an electronic device 800 provided in one embodiment of this application. For example, the memory defragmentation electronic device 800 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0117] like Figure 7 As shown, the electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.
[0118] Processing component 802 typically controls the overall operation of electronic device 800, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 802 may include one or more modules to facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802.
[0119] Memory 804 is configured to store various types of data to support the operation of electronic device 800. Examples of this data include instructions for any application or method operating on electronic device 800, contact data, phonebook data, messages, pictures, videos, etc. Memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0120] Power component 806 provides power to various components of electronic device 800. Power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 800.
[0121] Multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 808 includes a front-facing camera and / or a rear-facing camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0122] Audio component 810 is configured to output and / or input audio signals. For example, audio component 810 includes a microphone (MIC) configured to receive external audio signals when electronic device 800 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 804 or transmitted via communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
[0123] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0124] Sensor assembly 814 includes one or more sensors for providing state assessments of various aspects of electronic device 800. For example, sensor assembly 814 can detect the on / off state of electronic device 800, the relative positioning of components such as the display and keypad of electronic device 800, changes in position of electronic device 800 or a component of electronic device 800, the presence or absence of user contact with electronic device 800, orientation or acceleration / deceleration of electronic device 800, and temperature changes of electronic device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 814 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0125] Communication component 816 is configured to facilitate wired or wireless communication between electronic device 800 and other devices. Electronic device 800 can access wireless networks based on communication standards, such as WiFi, 2G, or 3G, or combinations thereof. In one exemplary embodiment, communication component 816 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 816 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0126] In some embodiments, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0127] In some embodiments, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, which can be executed by a processor 820 of an electronic device 800 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0128] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0129] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method of memory defragmentation, the method comprising: The method comprises the following steps: acquiring historical behaviors of a user using an application program; predicting an application program that the user is likely to start in a preset time period after a current time according to the historical behaviors of the user using the application program; acquiring a fragmentation state of a memory, comprising: acquiring a number of continuous page frames of different page numbers of the memory respectively; determining a fragmentation index of the memory according to the number of continuous page frames of different page numbers of the memory, wherein the larger the fragmentation index of the memory is, the more serious the fragmentation state of the memory is; and determining a triggering time of memory fragmentation according to a memory resource required by the application program and the fragmentation index of the memory; if the memory resource required by the application program is greater than a preset memory resource and the fragmentation index of the memory is greater than a preset index threshold, performing memory fragmentation, wherein the preset index threshold is related to a size of the memory; the performing of the memory fragmentation comprises: if the memory resource required by the application program is less than an available memory resource of the memory, performing memory fragmentation; if the memory resource required by the application program is greater than the available memory resource of the memory, releasing a memory resource occupied by an application program that is not currently required.
2. An apparatus for memory defragmentation, the apparatus comprising: The method comprises the following steps: a prediction module is configured to acquire historical behaviors of a user using an application program; and predict an application program that the user is likely to start in a preset time period after a current time according to the historical behaviors of the user using the application program; an acquisition module is configured to acquire a fragmentation state of a memory; the acquisition module is specifically configured to acquire a number of continuous page frames of different page numbers of the memory respectively; and determine a fragmentation index of the memory according to the number of continuous page frames of different page numbers of the memory, wherein the larger the fragmentation index of the memory is, the more serious the fragmentation state of the memory is; a determination module is configured to determine a triggering time of memory fragmentation according to a memory resource required by the application program and the fragmentation index of the memory; a processing module is configured to perform memory fragmentation if the memory resource required by the application program is greater than a preset memory resource and the fragmentation index of the memory is greater than a preset index threshold, wherein the preset index threshold is related to a size of the memory; the processing module is specifically configured to perform memory fragmentation if the memory resource required by the application program is less than an available memory resource of the memory; the processing module is further configured to release a memory resource occupied by an application program that is not currently required if the memory resource required by the application program is greater than the available memory resource of the memory.
3. An electronic device, comprising: The method comprises the following steps: a memory and a processor are coupled; the memory is configured to store program instructions; the processor is configured to invoke the program instructions in the memory to execute the method in claim 1.
4. A computer-readable storage medium, characterized in that, The computer program stored on the readable storage medium, when executed, implements the method in claim 1. The computer program stored on the readable storage medium, when executed, implements the method in claim 1.
Citation Information
Patent Citations
Rapid application program start method, mobile terminal and computer readable storage medium
CN107249074A
Memory management device, memory management method, and program
JP2008225669A