CN110377527A - A kind of method and relevant device of memory management - Google Patents
A kind of method and relevant device of memory management Download PDFInfo
- Publication number
- CN110377527A CN110377527A CN201810333058.6A CN201810333058A CN110377527A CN 110377527 A CN110377527 A CN 110377527A CN 201810333058 A CN201810333058 A CN 201810333058A CN 110377527 A CN110377527 A CN 110377527A
- Authority
- CN
- China
- Prior art keywords
- memory
- application scenarios
- terminal device
- contiguous memory
- contiguous
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0238—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
- G06F12/0246—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
- G06F12/0269—Incremental or concurrent garbage collection, e.g. in real-time systems
- G06F12/0276—Generational garbage collection
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Telephone Function (AREA)
- Stored Programmes (AREA)
Abstract
The application provides the method and relevant device of a kind of memory management, based on application scenarios and contiguous memory requirement forecasting, memory fragmentation arrangement is actively carried out, to meet the needs of different application scene is to contiguous memory, the waiting time of Memory Allocation is reduced, improves and applies operational efficiency.This method comprises: terminal device obtains the switching probability for being switched to each second application scenarios in one or more second application scenarios from the first application scenarios currently run;Then the contiguous memory according to needed for switching probability meets the second application scenarios of one or more of preset condition in second application scenarios of one or more determines target contiguous memory;If available contiguous memory is less than the target contiguous memory on the terminal device, then before the terminal device is switched to any second application scenarios from the first application scenarios, the terminal device carries out memory fragmentation arrangement, so that available contiguous memory is greater than the target contiguous memory on the terminal device.
Description
Technical field
This application involves computer field, in particular to the method and relevant device of a kind of memory management.
Background technique
The fragmentation of physical memory, i.e. memory pages are discontinuous, are always one of the major issue that operating system faces, and
It is general that the most of memory used at runtime is applied to require as contiguous memory.To solve asking for physical memory fragmentation
Topic, the prior art is usually using memory management algorithm, for example, the fragment of the Buddy system (buddy system) in Linux is whole
Fragment (fragmentation) in memory is organized into contiguous memory by adjustment method, to meet the memory requirements of application.
Existing memory management algorithm is broadly divided into two classes: isochronous memory defragmentation (memory
Defragmentation) algorithm and asynchronous memory defragmentation algorithms.Wherein, isochronous memory defragmentation algorithms are to answer
During with storage allocation, if the available contiguous memory of system is unable to satisfy application demand, triggering memory fragmentation is arranged.It is different
It is when the available contiguous memory of system is lower than given threshold that step memory fragmentation, which arranges algorithm, and triggering memory fragmentation arranges.
As can be seen that existing memory management algorithm is arranged based on particular event passive triggering memory fragmentation.Such as it is same
It is to trigger defragmentation when system can not distribute contiguous memory for current application that step memory fragmentation, which arranges algorithm, it is therefore desirable to etc.
Memory Allocation could be completed after system releasing memory and after sorting out contiguous memory, can greatly increase the waiting of Memory Allocation in this way
Time influences the operational efficiency of current application.And asynchronous memory defragmentation algorithms can be lower than in advance with contiguous memory in system
If triggering memory fragmentation when threshold value to arrange, and arrange to just stopping on threshold value, it is different when application needs a large amount of contiguous memories
The memory requirements that step defragmentation can not meet application in time also results in memory hence into isochronous memory defragmentation
The problem for distributing time length influences the operational efficiency of application.
Summary of the invention
The application provides the method and relevant device of a kind of memory management, pre- based on application scenarios and contiguous memory demand
It surveys, actively carries out memory fragmentation arrangement, to meet the needs of different application scene is to contiguous memory, reduce the waiting of Memory Allocation
Time improves and applies operational efficiency.
In view of this, the application first aspect provides a kind of method of memory management, may include:
Terminal device is obtained to be switched in one or more second application scenarios often from currently running first application scenarios
The switching probability of a second application scenarios, wherein multiple is two or more;Then the terminal device is full according to this
Switching probability meets each of preset condition in the switching probability of sufficient preset condition and second application scenarios of one or more
Contiguous memory needed for second application scenarios determines target contiguous memory;It is somebody's turn to do if available contiguous memory is less than on the terminal device
Target contiguous memory is then switched to appointing in second application scenarios of one or more from the first application scenarios in the terminal device
Before one second application scenarios, which carries out memory fragmentation arrangement according to the target contiguous memory, so that the terminal is set
Standby available contiguous memory is greater than the target contiguous memory.
It should be noted that the application embodiment is equal to target contiguous memory to contiguous memory available on terminal device
The case where, memory fragmentation arrangement can be carried out, can also be arranged without memory fragmentation, with specific reference to actual design demand tune
It is whole, it is not construed as limiting herein.
In the embodiment of the present application, the application scenarios that will switch to terminal device are predicted, are obtained from the first application
Scene switching and meets the switching probability of preset condition and corresponding according to this to the switching probability of each second application scenarios
Contiguous memory needed for second application scenarios determines target contiguous memory, and terminal device actively carries out memory fragmentation arrangement later, with
The available contiguous memory on the terminal device is set to be greater than the target contiguous memory, to ensure terminal device when switching application scenarios
There are enough contiguous memories to distribute, just carries out memory fragmentation arrangement when switching application scenarios without waiting for terminal device, improve eventually
End equipment switches efficiency when application scenarios.
In conjunction with the application in a first aspect, in the first embodiment of the application first aspect, which is carried out
Memory fragmentation arranges, and may include:
Terminal device obtains system load, and the range according to locating for system load determines that memory fragmentation arranges algorithm;So
Algorithm is arranged according to the memory fragmentation afterwards, memory fragmentation arrangement is carried out to the memory of the terminal device, it can on terminal device to improve
Contiguous memory.
In the embodiment of the present application, can range locating for the system load by terminal device determine that memory fragmentation arranges
Algorithm can also adjust memory fragmentation according to the system load dynamic of terminal device and arrange algorithm, and then can be rationally using eventually
The memory source of end equipment reduces memory fragmentation and arranges the influence for running application scenarios to terminal device, improves terminal device and cuts
Change the efficiency of application scenarios.
In conjunction with the first embodiment of the application first aspect, in second of embodiment of the application first aspect
In, terminal device range according to locating for system load determines that memory fragmentation arranges algorithm, comprising:
If the system load is in the first preset range, it is depth which, which determines that the memory fragmentation arranges algorithm,
Memory fragmentation arranges algorithm;If the system load is in the second preset range, which determines that the memory fragmentation arranges
Algorithm is that moderate memory fragmentation arranges algorithm;If or the system load is in third preset range, which determines should
It is that slight memory fragmentation arranges algorithm that memory fragmentation, which arranges algorithm,.
In the embodiment of the present application, it determines that suitable memory fragmentation arranges algorithm according to the system load of terminal device, moves
State adjusts memory fragmentation and arranges algorithm, including depth memory fragmentation arranges algorithm, moderate memory fragmentation arranges algorithm and slight
Memory fragmentation arranges algorithm, while carrying out memory fragmentation arrangement, reduces to the application scenarios being currently running on terminal device
Influence, clean out the available contiguous memory of terminal device, improve the efficiency of terminal device switching application scenarios.For example, terminal
In the higher situation of apparatus of load, algorithm can be arranged by slight memory fragmentation and carry out memory fragmentation arrangement, to avoid influence
The application scenarios being currently running on terminal device;Or terminal device loads in lower situation, can pass through depth memory fragmentation
Arrange algorithm and carry out memory fragmentation arrangement, rationally to utilize the resource of terminal device, while do not influence on terminal device other into
The operation of journey or application scenarios.
In conjunction with the of the application first aspect, the first embodiment of the application first aspect or the application first aspect
Two kinds of embodiments obtain terminal device and cut from the first application scenarios in the third embodiment of the application first aspect
The switching probability for changing to one or more second application scenarios may include:
Terminal device is obtained to be switched to each second in second application scenarios of one or more from first application scenarios
The history switching times of application scenarios;The terminal device is determined from first application scenarios according to the history switching times and is switched to
The switching probability of each second application scenarios in second application scenarios of one or more.
Specifically, in the application embodiment, terminal device obtain first from the first application scenarios be switched to one or
Then the history switching times of multiple second application scenarios are switched to each second application scenarios according to history number calculating
Switching probability.Contiguous memory needed for the switching probability can be used for predicting switching application scenarios, and according to contiguous memory master
It is dynamic to carry out memory fragmentation arrangement, contiguous memory needed for making the available contiguous memory on terminal device meet switching application scenarios,
Improve the efficiency of terminal device switching application scenarios.
In conjunction with the application first aspect, the first embodiment of the application first aspect to the application first aspect
Any embodiment in three kinds of embodiments, it is general according to the switching in the 4th kind of embodiment of the application first aspect
Meet switching probability in the switching probability and second application scenarios of one or more of preset condition in rate and meets the default item
Contiguous memory needed for the second application scenarios of each of part determines target contiguous memory, may include:
The terminal device determines that the switching probability is greater than the second of threshold value and answers from second application scenarios of one or more
Use scene;Terminal device contiguous memory according to needed for the second application scenarios that the switching probability is greater than threshold value determines the target
Contiguous memory.
In the application embodiment, the second application scenarios that switching probability is not more than threshold value are filtered out, then according to switching
Contiguous memory needed for probability is greater than the second application scenarios of threshold value determines target contiguous memory, and sorts out terminal device greatly
In the available contiguous memory of target contiguous memory, so that available contiguous memory can more ensure will switch on terminal device
Contiguous memory needed for two application scenarios.
In conjunction with the 4th kind of embodiment of the application, in the 5th kind of embodiment of the application, if from the one or more
It is multiple to determine that switching probability has greater than the second application scenarios of the threshold value in two scenes, the terminal device is according to one or more
Contiguous memory needed for the switching probability is greater than the second preset application scenarios determines the target contiguous memory, may include:
The terminal device is greater than each second application scenarios in the second application scenarios of threshold value to multiple switching probability
Switching probability and required contiguous memory are weighted, to obtain the target contiguous memory.Wherein, in ranking operation
The switching probability that weight can be greater than each second application scenarios in the second application scenarios of threshold value with multiple switching probability has
There is corresponding relationship, for example, switching probability is higher, shared weight is bigger.
It, can be by being greater than each second in the second application scenarios of threshold value to switching probability in the application embodiment
The switching probability of application scenarios and required contiguous memory are weighted, and are more nearly so as to obtain target contiguous memory
The contiguous memory needed for the second application scenarios that terminal device will switch, and then ensure that terminal device is switched to the second application
Contiguous memory needed for scene.
In conjunction with the 4th kind of embodiment of the application, in the 6th kind of embodiment of the application, the terminal device according to this one
Contiguous memory needed for a or multiple switching probabilities are greater than the second application scenarios of threshold value determines the target contiguous memory, comprising:
The terminal device is continuous needed for determining in the second application scenarios that the one or more switching probability is greater than threshold value
The maximum target application scene of memory;And using contiguous memory needed for the target application scene as the target contiguous memory.
In the application embodiment, one or more switching probabilities can be greater than institute in the second application scenarios of threshold value
The maximum contiguous memory needed meets the switching probability with this and is greater than in the second application scenarios of threshold value often as target contiguous memory
Contiguous memory needed for a second application scenarios improves the efficiency of terminal device switching application scenarios.
In conjunction with the application first aspect, the first embodiment of the application first aspect to the application first aspect
Any embodiment in six kinds of embodiments, in the 7th kind of embodiment of the application first aspect, this method can be with
Include:
When the terminal device is switched to from first application scenarios wherein one in second application scenarios of one or more
A second application scenarios, and the available contiguous memory on the terminal device is unsatisfactory for needed for one of them second application scenarios
When contiguous memory, which arranges algorithm by slight memory fragmentation and arranges to the memory fragmentation of terminal device.
In the application embodiment, terminal device is likely to occur on unexpected contiguous memory consumption or terminal device
When can be lower than target contiguous memory with contiguous memory, terminal device can also carry out slight when switching to the second application scenarios
Memory fragmentation arranges, and fast finishing goes out available contiguous memory, to ensure that terminal device can normally switch application scenarios.
The embodiment of the present application second aspect provides terminal device, which, which has, realizes above-mentioned first aspect memory
The function of the method for management.The function can also execute corresponding software realization by hardware realization by hardware.This is hard
Part or software include one or more modules corresponding with above-mentioned function.
The embodiment of the present application third aspect provides a kind of terminal device, may include:
Processor, memory, bus and input/output interface, the processor, the memory and the input/output interface
It is connected by the bus;The memory, for storing program code;The processor is held when calling the program code in the memory
The step of terminal device that row the application first aspect or first aspect any embodiment provide executes.
The embodiment of the present application fourth aspect provides a kind of storage medium, it should be noted that the technical solution essence of this hair
On in other words all or part of the part that contributes to existing technology or the technical solution can with software produce mouth shape
Formula embodies, which is stored in a storage medium, for being stored as calculating used in above equipment
Machine software instruction, it includes be journey designed by terminal device for executing above-mentioned first aspect either side into second aspect
Sequence.
The storage medium includes: USB flash disk, mobile hard disk, read-only memory (english abbreviation ROM, full name in English: Read-
Only Memory), random access memory (english abbreviation: RAM, full name in English: Random Access Memory), magnetic disk
Or the various media that can store program code such as CD.
The 5th aspect of the embodiment of the present application provides a kind of computer program product comprising instruction, when it is transported on computers
When row, so that computer executes the method as described in the application first aspect or second aspect any optional embodiment.
In the embodiment of the present application, if terminal device is currently running the first application scenarios, terminal device can be at this time
Obtain the switching probability that each second scene in one or more second application scenarios is switched to from the first application scenarios, and according to
Switching probability meets the switching probability of the second scene of each of preset condition and is somebody's turn to do in second application scenarios of one or more
Contiguous memory needed for the starting of each second application scenarios and operation determines target contiguous memory, then in terminal device from the
One application scenarios are switched to before any one second application scenarios, and terminal device actively carries out memory fragmentation arrangement, make terminal
The length of available contiguous memory in equipment is greater than the length of the target contiguous memory, to ensure the second applied field that will switch
Contiguous memory needed for scape improves the efficiency of the second application scenarios of terminal device switching and operation.
Detailed description of the invention
Fig. 1 is the schematic diagram of a scenario of the embodiment of the present application concrete application;
Fig. 2 is memory pages schematic diagram in the embodiment of the present application;
Fig. 3 is the frame diagram of the method for memory management in the embodiment of the present application;
Fig. 4 is a kind of flow diagram of the method for memory management in the embodiment of the present application;
Fig. 5 is another flow diagram of the method for memory management in the embodiment of the present application;
Fig. 6 is a kind of schematic diagram of buddy algorithm in the embodiment of the present application;
Fig. 7 is another flow diagram of the method for memory management in the embodiment of the present application;
Fig. 8 is that the embodiment of the present application mild or moderate memory fragmentation arranges schematic diagram;
Fig. 9 is that moderate memory fragmentation arranges schematic diagram in the embodiment of the present application;
Figure 10 is that depth memory fragmentation arranges schematic diagram in the embodiment of the present application;
Figure 11 is the concrete scene schematic diagram of the method for memory management in the embodiment of the present application;
Figure 12 is a kind of embodiment schematic diagram of terminal device in the embodiment of the present application;
Figure 13 is another embodiment schematic diagram of terminal device in the embodiment of the present application.
Specific embodiment
The application provides the method and relevant device of a kind of memory management, pre- based on application scenarios and contiguous memory demand
It surveys, carries out memory fragmentation arrangement (memory defragmentation), actively to meet different application scene to contiguous memory
Demand, reduce the waiting time of Memory Allocation, improve apply operational efficiency.
The method of memory management equipment provided by the embodiments of the present application can be applied to terminal device, which can be with
It is mobile phone, tablet computer, vehicle-mounted mobile, PDA (personal digital assistant, personal digital assistant), phase
Machine or wearable device etc..Certainly, in the examples below, the concrete form of the terminal device is not intended to be limited in any.Wherein,
The system that terminal device can carry may includeOr other operations
System etc., the embodiment of the present application is not intended to be limited in any this.
To carryFor the terminal device 100 of operating system, as shown in Figure 1, terminal device 100 is logically
Hardware layer 21, operating system 161 and application layer 31 can be divided into.Hardware layer 21 includes application processor 101, microcontroller
The hardware resources such as unit 103, modem 107, Wi-Fi module 111, sensor 114, locating module 150.Application layer 31
Including one or more application program, such as application program 163, application program 163 can be social category application, e-commerce
Using any type of application programs such as, browsers.Operating system 161 is as in the software between hardware layer 21 and application layer 31
Between part, be the computer program for managing and controlling hardware and software resource.
In one embodiment, operating system 161 includes kernel 23, hardware abstraction layer (hardware abstraction
Layer, HAL) 25, library and (libraries and runtime) 27 and frame (framework) 29 when operation.Wherein,
Kernel 23 is used to provide first floor system component and service, such as: power management, memory management, thread management, hardware driving journey
Sequence etc.;Hardware driver package includes Wi-Fi driving, sensor driving, locating module driving etc..Hardware abstraction layer 25 is to kernel
The encapsulation of driver provides interface to frame 29, shields the realization details of low layer.Hardware abstraction layer 25 operates in user's sky
Between, and Kernel Driver operates in kernel spacing.
Library and operation when 27 also referred to as run-time library, it for executable program provide at runtime required for library file and
Performing environment.27 include 271 and library 273 etc. (Android Runtime, ART) when Android is run when library and operation.ART
271 be the virtual machine or virtual machine instance that the bytecode of application program can be converted to machine code.Library 273 be executable
Program provides the program library of support at runtime, including browser engine (such as webkit), script executing engine (such as
JavaScript engine), graphics processing engine etc..
Frame 27 is used to provide common component and the service on various bases, such as window for the application program in application layer 31
Management, location management etc..Frame 27 may include telephone supervisor 291, resource manager 293, location manager 295 etc..
The function of the various components of operations described above system 161 can execute memory by application processor 101
The program that stores in 105 is realized.
Those skilled in the art is understood that terminal 100 may include than less or more component shown in FIG. 1, figure
The terminal device shown in 1 only includes component more relevant to multiple implementations disclosed in the embodiment of the present application.
By figure 1 above it is found that multiple application programs (referred to as " applying ") can be installed on terminal device, and can be multiple
Switched between, or the multiple scenes applied at one, such as the different function applied or interface etc., between cut
It changes.When terminal device progress application scenarios switching, it is included between multiple applications and switches over, or is in an application multiple
When switching in scene, terminal device memory is related to the operation of multiple modules, including Memory Allocation and the read-write of memory etc..
Each application scenarios starting and operation need contiguous memory.
Wherein, by taking a concrete application scene switches as an example, browser, shopping software, trip are mounted on the terminal device
Software etc. of playing is applied.Terminal device can switch between multiple application scenarios, multiple including what is installed on the terminal device
Each scene between, or in application, for example switched between function or user interface.For example, being cut from browser
Change to shopping software, or from shopping software exchange to software of taking pictures, and or from the scene switching of taking pictures in software of taking pictures to photograph
Piece preview scene etc..When terminal device carries out the switching of application scenarios, the variation of memory is also related to inside terminal device, often
The starting and operation of a application scenarios require memory.Memory also may include a variety of division modes, specifically, with Linux
For system, physical memory divides memory by fixed page, can be divided into multiple memory pages, the size of a memory pages
It can be 4kb.And require contiguous memory when being normally applied scene operation, i.e., continuous memory pages.Memory pages can divide
For removable memory pages, irremovable memory pages and the recyclable page.Removable memory pages can be moved arbitrarily,
This can be moved to the data that memory pages are stored to be moved on other memory pages.The application program in general user space
The occupied page belongs to the removable page, and application program and memory pages can pass through page-map.Therefore it may only be necessary to refresh page
The data stored on former memory pages are copied to the target memory page by list item.One memory pages may also be more
A process is shared, corresponding multiple page table entries.And physical memory is after long-term Memory Allocation and release, foring part can not
The mobile page, i.e., position is fixed in memory, can not be moved to elsewhere.The page that core kernel is distributed largely all belongs to
In the irremovable page, as the operation duration of system is longer, the irremovable page will also increase.The recyclable page cannot be direct
It is mobile, but can recycle, data are rebuild from other memory pages including application program, then the data on former memory pages are just
It can be recovered.The generally recyclable page can be recycled by the Memory recycle process of system intialization.For example, the data of mapped file
Occupied memory may belong to the recyclable page, and the kswapd process in linux system can be according to preset rule, period
Property recycles the recyclable page.
When terminal device is when carrying out application scenarios switching, it will use and arrive contiguous memory.And with the use of system, physics
Memory by with the operation of system it is occupied.For example, as shown in Fig. 2, may include a variety of memory pages in one section of memory, including
Free memory pages, the recyclable memory page, irremovable memory pages and removable memory pages etc..It therefore, is guarantee
The normal operation of application scenarios on terminal device needs internally to deposit into the arrangement of row memory fragmentation, to obtain continuous free memory.
Wherein, memory fragmentation arrangement is the process of a reduction memory fragmentation quantity, and it mainly includes to removable interior that memory fragmentation, which arranges,
It deposits the page to be moved, or the recyclable page is recycled or removed, to obtain the continuous free memory of physical address.
Therefore, to ensure to have available enough contiguous memory on terminal device, it is with aforementioned terminal device described in figure
Example, the embodiment of the present application have made improvement to operating system part.It can specifically be related to being related to memory portion in operating system
Divide and application runs required part, also relates to the application layer part inside terminal device, and in particular to arrive and apply
The handoff procedure of program.In addition, each functional module, only part of module described in Fig. 1, terminal device can in practical application
To include multiple related to memory, and module relevant to application operation and application switching, herein and it is not construed as limiting.This Shen
Please the method for memory management provides in embodiment specific improvement, may include before carrying out application scenarios switching, to will
The application scenarios of switching and required contiguous memory are predicted, memory fragmentation arrangement is actively carried out, enough to sort out
Contiguous memory.And then ensure that terminal device when switching application scenarios, can distribute enough contiguous memories for application scenarios.Tool
Body, the frame of the method for memory management is as shown in Figure 3 in the embodiment of the present application.
Terminal device can be predicted before application starts or carries out application scenarios switching by way of calculating or learning
Target contiguous memory needed for the application scenarios that will switch.Then terminal device is broken according to target contiguous memory progress memory
Piece arranges, and sorts out the contiguous memory that can be used, and the available contiguous memory of terminal device is made to be greater than the target contiguous memory.Its
In, " application scenarios " in each embodiment of the application can be the application on terminal device, be also possible to certain on terminal device
Scene, such as function, the user interface applied etc. in one application.The switching of application scenarios can be terminal and set i.e. in the application
Switching between standby upper application, is also possible to the scene switching on terminal device inside a certain application, this is not limited here.
Before terminal device switches application scenarios, the application scenarios for that will switch distribute contiguous memory, so that terminal device meets
Contiguous memory needed for the application scenarios operates normally the application scenarios.Wherein, memory management provided by the present application
Method is to ensure the contiguous memory demand for the application scenarios that will switch, and terminal device can carry out application scenarios in terminal device
Then target contiguous memory needed for the application scenarios that prediction will switch before switching carries out memory fragmentation arrangement.Therefore, at this
Apply in embodiment, can be sorted out needed for the application scenarios that will switch before terminal device carries out application scenarios switching
Contiguous memory, required contiguous memory, improves the efficiency of application scenarios switching when ensureing the application scenarios that will switch operation.
Further, in the embodiment of the present application the process of the method for memory management as shown in figure 4, the application memory management
The flow diagram of method, comprising:
401, it obtains from the first application scenarios and is switched to each second application scenarios in one or more second application scenarios
Switching probability.
It may include one or more application on terminal device, it is multiple to refer to two or more.In each application
It may include multiple application scenarios.Terminal device at runtime, can switch in multiple application scenarios.If terminal device is worked as
Before be currently running the first application scenarios, terminal device is available to be switched to the one or more second from the first application scenarios and answers
With the switching probability of the second application scenarios each in scene, the mode for obtaining the switching probability be can be according on the terminal device
Carry out the modes such as number or the deep learning of application scenarios switching.For example, terminal device is currently running browser, i.e., first
Application scenarios, then terminal device is available is switched to the one or more second such as camera, game, shopping software from the browser
The switching probability of each second application scenarios in application scenarios is such as 15% from the probability that the browser is switched to camera, switching
Probability to shopping software is 23%, and the probability for being switched to game is 3% etc..In another example when each scene inside application
The probability for being switched to wechat red packet is by the chat conversations scene being currently running in wechat when middle switching, on terminal device
30%, the probability for being switched to circle of friends scene is 50% etc..
In the embodiment of the present application, first application scenarios and the second application scenarios can be different application, can also be with
Be different or identical application in different application scene, can be adjusted according to actual design demand, this is not limited here.
402, contiguous memory needed for each second application scenarios in one or more second application scenarios is obtained.
Terminal device is switched in second application scenarios of one or more often in addition to needing to obtain from the first application scenarios
The switching probability of a application scenarios, it is also necessary to obtain in second application scenarios of one or more needed for each second application scenarios
Contiguous memory.For example, running game needs 60kb contiguous memory, operation camera needs 500kb contiguous memory etc..It can be with
It is to obtain the switching probability greater than contiguous memory needed for each second application scenarios in the second application scenarios of preset value.
Contiguous memory needed for each second application scenarios in one or more second application scenarios is obtained if should be understood that,
Then in the embodiment of the present application, step 401 can be first carried out, step 402 can also be first carried out, this is not limited here.
403, the contiguous memory according to needed for switching probability and each second application scenarios determines target contiguous memory.
After determination is switched to the switching probability of the second application scenarios, determines and determine the default item of satisfaction in the switching probability
Switching probability meets the second applied field of each of preset condition in the switching probability of part, and one or more second application scenarios
Contiguous memory needed for scape.Terminal device can meet each of preset condition second according to the switching probability and switching probability
Target contiguous memory is calculated in contiguous memory needed for application scenarios.Terminal device can be switched to any one in terminal device
Before second application scenarios, memory fragmentation arrangement is carried out, keeps available contiguous memory on terminal device continuously interior greater than the target
It deposits, and then makes terminal device when switching application scenarios, enough contiguous memories can be distributed for application scenarios, ensure that terminal is set
It is standby from the first application scenarios be switched to one of them second application scenarios needed for contiguous memory.
The specific mode for calculating target contiguous memory can be, it is first determined switching probability is greater than the second applied field of threshold value
Scape, at least two switching probabilities are greater than the second application scenarios of threshold value if it exists, are greater than threshold value at least two switching probability
Each of the second application scenarios switching probability of the second application scenarios and required contiguous memory be weighted, obtain
The target contiguous memory;It is also possible to terminal device and determines demand from the second application scenarios that the switching probability is greater than threshold value
Maximum contiguous memory specifically can be according to actual design demand then using the maximum contiguous memory as target contiguous memory etc.
Adjustment, is not construed as limiting herein.
404, judge whether available contiguous memory is greater than target contiguous memory on terminal device.
After terminal device determines target contiguous memory, terminal device judges whether available contiguous memory is greater than target company
Continuous memory, that is, judge whether the size of available contiguous memory on terminal device is greater than the size of target contiguous memory.If available
Contiguous memory be greater than target contiguous memory, then follow the steps 405, if available contiguous memory be not more than target contiguous memory,
Then follow the steps 406.Wherein, which is that can distribute to the continuous of the second application scenarios on terminal device
Memory.
405, other steps are executed.
If available contiguous memory is greater than target contiguous memory on terminal device, on the terminal device it is available it is continuous in
Deposit can ensure one of them second application scenarios will be switched to from the first application scenarios needed for contiguous memory.Terminal at this time
Equipment can carry out memory fragmentation arrangement, can also arrange without memory fragmentation, can specifically be adjusted according to actual design demand,
It is not construed as limiting herein.
406, memory fragmentation arrangement is carried out.
If available contiguous memory is less than or equal to target contiguous memory on terminal device, to ensure from the first application scenarios
Contiguous memory needed for being switched to one of them second application scenarios is switched to second from the first application scenarios in terminal device and answers
Before scene, terminal device needs to carry out memory fragmentation arrangement, and available contiguous memory on terminal device is made to be not less than the mesh
Mark contiguous memory has enough contiguous memories that can distribute to ensure terminal device when being switched to the second application scenarios.Memory
The specific steps of defragmentation can be, and arrange to the memory pages on terminal device, move to the removable page,
Or the recyclable page recycles etc., to sort out idle contiguous memory, the contiguous memory of the free time can be in terminal device
Be allocated when application scenarios switching for the application scenarios of switching.
It should be noted that in the embodiment of the present application, if available contiguous memory is continuous equal to target on terminal device
Memory can also be arranged in addition to that can carry out memory fragmentation arrangement without memory fragmentation, specifically can be according to actual design demand
Adjustment, is not construed as limiting herein.
In the embodiment of the present application, it is first determined terminal device is switched to one or more second from the first application scenarios and answers
With the switching probability of the second application scenarios each in scene, target is then calculated according to the switching probability and demand memory
Contiguous memory.Memory fragmentation arrangement is carried out according to the target contiguous memory later, makes on terminal device available contiguous memory not
Less than target contiguous memory, to ensure that terminal device is switched in second application scenarios of one or more from the first application scenarios
One of them second application scenarios when, have enough available contiguous memories.Improve from the first application scenarios be switched to this one
The efficiency of one of them the second application scenarios in a or multiple second application scenarios.
The aforementioned process to EMS memory management process in the embodiment of the present application is illustrated, below in the embodiment of the present application
The process of EMS memory management process is further illustrated.The specific steps of determining target contiguous memory are carried out first detailed
Illustrate, referring to Fig. 5, in the embodiment of the present application the method for inner tube management another embodiment schematic diagram, comprising:
501, the first application scenarios start.
First application scenarios are the application scenarios that terminal device is currently running, when the starting of the first application scenarios and just
Often after operation, next terminal device can be predicted the application scenarios that will be switched to, and sort out in advance enough
Contiguous memory improves the effect of terminal switch application scene to ensure that enough contiguous memories can be used in the application scenarios of switching
Rate.
502, switching application scenarios data acquisition.
Terminal device can with the data of acquisition applications scene switching, for example, in current pervious 24 hours, terminal device from
Application scenarios A is switched to the number of application scenarios B or application scenarios A is switched to the number etc. of application scenarios C.
It is specific to implement be inserted into switch count variable in the scene run function in terminal device in a manner of, it is right
Switching application scenarios are counted every time, for example, being switched to circle of friends scene etc. from the chat scenario of wechat.
503, application scenarios incidence relation is determined.
After the switching times to application scenarios are acquired, it can be determined by the switching times between application scenarios each
Application scenarios incidence matrix can be generated in the incidence relation of a application scenarios, can be according to the application scenarios incidence matrix determination
By the application scenarios of switching, that is, it is switched to the switching probability of the second application scenarios.The calculation of switching probability is for example, from application
It is 50 times that scenario A, which is switched to application scenarios B, and being switched to application scenarios C from application scenarios A is 30 times, is switched to from application scenarios A
Application scenarios D is 20 times, then, if currently operation application scenarios A, i.e. the first application scenarios are switched to the switching of application scenarios B
Probability is 50%, and the switching probability for being switched to application scenarios C is 30%, and the switching probability for being switched to application scenarios D is 20%.It should
Second application scenarios of one or more of application scenarios B, application scenarios C and application scenarios D, that is, earlier figures 4.
For example, the number for being switched to application scenarios B from application scenarios A is 500 times, from application scenarios A before 24 hours
The number for being switched to application scenarios C is 100 times.In practical applications, if terminal device is currently running application scenarios A, that
, the probability of application scenarios B is switched to greater than the probability for being switched to application scenarios C from application scenarios A from application scenarios A.Using
Scene relating matrix can be as shown in table 1 below:
Application scenarios A | Application scenarios B | Application scenarios C | Application scenarios D | Application scenarios E | Application scenarios F | |
Application scenarios A | 100 | 10 | 20 | 0 | 1 | |
Application scenarios B | 5 | 20 | 30 | 50 | 0 | |
Application scenarios C | 80 | 20 | 0 | 2 | 13 | |
Application scenarios D | 10 | 6 | 2 | 22 | 6 | |
Application scenarios E | 0 | 20 | 0 | 0 | 0 | |
Application scenarios F | 0 | 0 | 30 | 0 | 0 |
Table 1
Wherein, equipment of the application scenarios incidence matrix in indicating is switched to another application from some application scenarios
The number of scene.For example, the number for being switched to application scenarios B from application scenarios A is not 100 times in 1 the first row of table, it is switched to
The number of application scenarios C is 10 times, and the number for being switched to application scenarios D is 20 times, and the number for being switched to application scenarios E is 0
Secondary, the number for being switched to application scenarios F is 1 time, can go out in prediction on such basis from application scenarios A and be switched to other each application scenarios
Probability.Terminal device from application scenarios A be switched to application scenarios B probability be greater than be switched to application scenarios C, application scenarios D,
Application scenarios E and application scenarios F.And when switching over the acquisition of application scenarios data, application scenarios of every switching all may be used
To be updated to the application scenarios incidence matrix, to carry out learning records to the application switching on terminal device in real time.Tool
Body, when being updated to original record, can by taking the original record and the average value of more new data to be updated,
It can be by being updated with more new data by ranking operation to original record, this is not limited here.
In addition, in the incidence relation for determining application scenarios, it is every once to be switched, then the incidence relation can be carried out
It updates, so that terminal device can predict the application scenarios that will switch according to more history switch datas.History switch data
More, the accuracy that terminal device switches over scene prediction is higher, therefore terminal device can be closed by updating application scenarios
Connection relationship improves the accuracy rate of prediction, so that ensureing that the available contiguous memory cleaned up on terminal device meets carries out applied field
Scape contiguous memory required when switching.
504, application scenarios contiguous memory acquires.
Switching times in addition to needing acquisition applications scene, determine outside the switching probability of application scenarios, it is also necessary to each
Contiguous memory needed for application scenarios operation is acquired, i.e., the contiguous memory demand in each application scenarios start-up course and answers
Contiguous memory demand when being run with scene can identify next answer according to the contiguous memory demand of each application scenarios
The contiguous memory demand needed for scene.
It is specific to implement be inserted into switch count variable in the memory allocation function in terminal device in a manner of, it is right
The contiguous memory of each Memory Allocation is counted, and is prepared to enter into respectively in application scenarios every time, into obtaining when completing and exiting
Take primary counting.It is continuous interior when the application scenarios start into the contiguous memory difference acquired when completion and accurate entrance
Deposit demand, exit and into the difference of completion be the application scenarios entirety contiguous memory demand.
In addition, can also acquire in addition to the contiguous memory that can acquire each application scenarios demand from current application scene
Switching probability is greater than the contiguous memory of the application scenarios demand of threshold value when switching over, for example, being cut from current application scene
When changing, application scenarios of the switching probability greater than 10% have 10, then can only acquire the continuous interior of this 10 application scenarios demands
It deposits, the specific situation that acquires can be adjusted according to design requirement, and this is not limited here.
If should be understood that when carrying out the acquisition of application scenarios contiguous memory without using the collected application scenarios of step 502
Switch data, then the application is not construed as limiting the execution sequence of step 502 and step 504, can first carry out step 502, can also
To first carry out step 504, can specifically be adjusted according to actual design demand, this is not limited here.
In the embodiment of the present application, contiguous memory needed for each application scenarios can also be recorded, every sub-distribution
After contiguous memory, contiguous memory needed for each application scenarios is updated.It can be the contiguous memory of current switching distribution
Switch distributed contiguous memory with history to be weighted, is also possible to be gone through with the contiguous memory substitution of current switching distribution
History switches distributed contiguous memory record, can specifically be adjusted according to actual scene, is not construed as limiting herein.
505, application scenarios contiguous memory demand is determined.
After the contiguous memory to application scenarios is acquired, each second application can be determined according to collected data
The contiguous memory demand of scene, for example, according to the contiguous memory demand in each second application scenarios start-up course and can answer
Contiguous memory demand when being run with scene is determined from second application scenarios are switched to company required when application scenarios operation
Continuous memory requirements.
Specifically, in linux system, memory fragmentation is managed by partner (buddy) algorithm, system kernel exists
Each zone removes the available memory pages of manager, is arranged in chained list queue by 2 power level size, is stored in free_area number
In.Be illustrated below with a specific embodiment, please refer to Fig. 6, in the embodiment of the present application buddy algorithm schematic diagram.
Wherein, there are 16 memory pages in Installed System Memory, including memory pages 0 are to memory pages 15, i.e. in pages row in Fig. 6
0-15.16 memory pages are arranged in chained list queue by 2 power level size.Because of only 16 pages, therefore only need 4 grades
Not (order) bitmap for just can determine that 16 memory pages, i.e. order0 to order3 in Fig. 6.The contiguous memory of high-order
It can be come out by low order contiguous memory fast finishing, low order contiguous memory can quickly be divided by high-order contiguous memory
Match.Therefore, in the contiguous memory demand for determining application scenarios, contiguous memory distribution can be carried out by buddy algorithm.Specifically
Format it is as shown in table 2:
Starting | It is maximum | |
Application scenarios A | 100, order:2 | 500, order:2 |
Application scenarios B | 200, order:4 | 500, order:4 |
Application scenarios C | 100, order:8 | 1000, order:8 |
Application scenarios D | 0 | 0 |
Application scenarios E | 10, order:2 | 10, order:2 |
Application scenarios F | 100, order:2 | 500, order:2 |
Table 2
Wherein, when starting application scenarios A, the memory pages of 100 order2 are needed, when application scenarios A is operated normally,
Need the memory pages of 500 order2;When starting application scenarios B, the memory pages of 200 order4 are needed, in applied field
When scape B is operated normally, the page of 500 order4 is needed;When starting application scenarios C, the page of 100 order8 is needed
Face needs the memory pages of 1000 order8 when application scenarios C is operated normally;When starting application scenarios D, 0 is needed
Memory pages need 0 memory pages when application scenarios D is operated normally;When starting application scenarios E, 10 order2 are needed
Memory pages, application scenarios E operate normally when, need the memory pages of 10 order2;When starting application scenarios F, need
The memory pages for wanting 100 order2 need the memory pages of 500 order2 when application scenarios F is operated normally, other
Application scenarios and so on.
506, target contiguous memory is predicted.
After the contiguous memory needed for the switching probability and each second application scenarios of each second application scenarios of determination,
The second application scenarios that will switch can be predicted, while predict required target contiguous memory.Can wherein it pass through
Application scenarios incidence matrix determines the switching probability that other application scenarios are switched to from current application, can be by the way that a threshold is arranged
Value, the application scenarios that will be less than threshold value filter out, it can filter out the lower application scenarios of sending probability.For example, if answering
It is lower than 10% with the switching probability of scenario A, then filters out application scenarios A.
It determines that the specific steps of target contiguous memory can be, filters out switch in one or more second application scenarios first
Probability is not more than the second application scenarios of threshold value.Then to switching probability be greater than threshold value the second application scenarios switching probability with
And required contiguous memory is weighted, and obtains target contiguous memory.Specifically, the weight in the ranking operation can be with
Switching probability corresponding to each second application scenarios has corresponding relationship.For example, shared by the biggish application scenarios of switching probability
Weight can also it is bigger to get to target contiguous memory be more biased towards needed for biggish second application scenarios of switching probability
Contiguous memory;Can also be using the switching probability be greater than threshold value the second application scenarios needed for maximum contiguous memory as
The target contiguous memory, or target contiguous memory is obtained by other algorithms, it can be specifically adjusted according to physical device demand,
It is not construed as limiting herein.
507, starting memory fragmentation arranges.
After determining target contiguous memory, if available contiguous memory is not more than target contiguous memory on terminal device, i.e.,
Memory fragmentation arrangement can be actively carried out, so as to can use on terminal device on terminal device before being switched to the second application scenarios
Contiguous memory be greater than target contiguous memory.Wherein, specific scrap cleaning method in the embodiment of following Fig. 7 specifically
It is bright.
In the embodiment of the present application, target contiguous memory needed for being switched to the second application scenarios by look-ahead, and
Memory fragmentation arrangement is carried out in advance, so that available contiguous memory is greater than target contiguous memory on terminal device, therefore terminal is set
Start and run second for enough contiguous memories when being switched to the second application scenarios from the first application scenarios, can be used
Application scenarios to reduce the waiting time that terminal device is switched to the second application scenarios, and then can be improved terminal device and cut
Change the efficiency of application scenarios.
The aforementioned specific steps progress to target contiguous memory is determined in EMS memory management process in the embodiment of the present application emphatically
Explanation, in EMS memory management process provided by the present application, in addition to the look-ahead target contiguous memory before application scenarios switch,
And carry out outside memory fragmentation arrangement, to further increase the efficiency of memory fragmentation arrangement, and do not influence transporting on terminal device
Capable application or process etc., the embodiment of the present application has also made improvement to the specific algorithm of memory scrubbing, can pass through dynamic regulation
Carry out memory fragmentation arrangement.Below in EMS memory management process in the embodiment of the present application carry out memory fragmentation arrangement the step of carry out
Elaborate, referring to Fig. 7, in the embodiment of the present application the method for memory management another embodiment schematic diagram, may include:
701, starting memory fragmentation arranges.
After terminal device determines target contiguous memory by way of prediction, switch to a certain second application scenarios it
Before, terminal device can star memory fragmentation arrangement, to sort out available contiguous memory.Specifically in following steps 702- step
It is described in detail in 708.
702, it calculates currently available contiguous memory and thens follow the steps 703 if meeting target contiguous memory, if being unsatisfactory for mesh
Contiguous memory is marked, thens follow the steps 704.
After determining target contiguous memory, terminal device can calculate currently available contiguous memory, i.e. terminal device is current
The contiguous memory of the second application scenarios can be distributed to.Specifically, it in linux system, can be obtained from buddy system current
All available contiguous memories on terminal device, and judge target contiguous memory whether can be met with contiguous memory.
If the available contiguous memory on terminal device is discontented with foot-eye contiguous memory, 704 are thened follow the steps, that is, is carried out quick
Memory is arranged, so that the available contiguous memory on terminal device is less than target contiguous memory.If available continuous on terminal device
Memory is not less than target contiguous memory, then terminal device can carry out irremovable page compact district calculating, i.e. execution step
703。
703, irremovable page compact district is calculated.
It is continuously interior that available contiguous memory when terminal device starting memory fragmentation arranges or on terminal device meets target
When depositing, irremovable page compact district can be calculated.Wherein, in preset unit range, the irremovable page is super
Cross intensive threshold value, then it is assumed that be irremovable compact district in the unit range.For example, if in 1024 pages, it is irremovable
The page is more than 100, it may be considered that 1024 pages belong to irremovable page compact district.It is close when the page cannot be moved
When Ji Qu is greater than intensive threshold value, then step 704 can be executed.And when irremovable page compact district is not more than intensive threshold value,
It can stop carrying out memory fragmentation arrangement.
It, can also be with it should be noted that in the embodiment of the present application, can calculate irremovable page compact district
Irremovable page compact district is not calculated, i.e., step 703 can be optional step.In practical applications, when terminal is set
For when not calculating target contiguous memory, irremovable page compact district can also be directly calculated.If the irremovable page
Compact district is greater than preset value, can also carry out fast finishing contiguous memory, i.e., is arranged in algorithm progress by slight memory fragmentation
Defragmentation is deposited, slight memory fragmentation arranges algorithm and is described in detail in step 704.If irremovable page compact district is not
Greater than preset value, can continue quickly to carry out memory fragmentation arrangement by slight memory fragmentation arrangement algorithm, it can also not
Memory fragmentation arrangement is carried out, can specifically be adjusted according to actual design demand, be not construed as limiting herein.
Specifically, it when terminal device carries out memory fragmentation arrangement, is directly skipped if encountering the irremovable page, when being
Unite after long-play, it is not possible to the mobile page increases, and RAM fragmentation degree greatly promotes, cause to sort out bulk continuously in
The success rate deposited lowers, and causes the speed of memory scrubbing and Memory Allocation to decline, will reduce the operational efficiency of terminal device.Cause
This in the embodiment of the present application calculates irremovable page compact district, and in subsequent progress memory fragmentation arrangement, packet
It includes and the region for including the irremovable page is arranged, be specifically described in detail in subsequent step 707 and step 708.
It therefore, can be to including that irremovable page area arranges, after avoiding system long-play, because the irremovable page increases
Add and reduce memory fragmentation arrangement efficiency and success rate, can be improved terminal device carry out memory fragmentation arrangement efficiency with
And success rate.
704, fast finishing contiguous memory.
Available contiguous memory on the terminal device is discontented with irremovable intensive on foot-eye contiguous memory or terminal device
When area is greater than preset value, terminal device fast finishing contiguous memory.Memory is carried out including arranging algorithm by slight memory fragmentation
Defragmentation, it can memory fragmentation arrangement is carried out to removable page pool.Specifically, algorithm is arranged by slight memory fragmentation
The memory pages after memory pages and arrangement before arrangement are as shown in Figure 8, wherein removable page pool is in preset unit model
Memory pages in enclosing do not include the irremovable page.For example, if not including the irremovable page, then in 1024 pages
It is considered that 1024 pages belong to removable page pool.Memory fragmentation arrangement is carried out by slight memory algorithm, i.e., to can
Mobile page pool is arranged, and the removable page in removable page pool is all moved on one section of contiguous memory, so that empty
The not busy page forms contiguous memory.For example, including discontinuous in the memory pages that removable page regional address is 0001-0100
20 removable pages, it is possible to 20 removable pages are uniformly moved on 0001-0020, because this address is
Memory pages after 0020 are all free page, and idle contiguous memory is sorted out with this.Therefore, pass through slight memory fragmentation
Idle contiguous memory can be gone out by fast finishing on the terminal device by arranging algorithm, be cut with ensureing that terminal device carries out application scenarios
Required contiguous memory when changing.
In practical applications, algorithm fast finishing can be arranged by slight memory fragmentation and goes out available contiguous memory, with
Ensureing to have when terminal device switches and applies more can be used contiguous memory that can distribute.For example, if terminal device is currently run
Application scenarios A, then, if available contiguous memory current on terminal device is unsatisfactory on application scenarios A or terminal device
Irremovable page compact district is greater than preset value, then terminal device can carry out fast finishing contiguous memory, to the removable page
Area carries out fast finishing, and fast finishing goes out available contiguous memory.Terminal device is avoided to switch application scenarios suddenly and company with this
Continuous low memory, and then improve the efficiency and reliability of switching application scenarios.If page compact district cannot be moved to be greater than in advance
If value, then the irremovable page on terminal device increases, can make to have on terminal device more by fast finishing contiguous memory
Contiguous memory can for application scenarios distribute.
705, system load is obtained.
After carrying out fast finishing contiguous memory, available contiguous memory on terminal device can be increased, can be prevented end
End equipment switches the inadequate situation of application scenarios Shi Keyong contiguous memory suddenly.If the available contiguous memory on terminal device is still
Discontented foot-eye contiguous memory, or further to improve the available contiguous memory on terminal device, it can further internally
Fragment is deposited to be arranged.It specifically can be by the system load of acquisition terminal device, according to locating for the system load of terminal device
Range to memory defragmentation algorithms carry out dynamic adjustment, with rationally utilize terminal device resource, and reduce terminal is set
The influence of the standby application scenarios being above currently running.The system load can be used to indicate that the system busy extent in terminal device,
It can be and be currently running or wait coefficient shared by the process of operation in end equipment in the unit time.For example, system load can be with
Be in the unit time, the operation of terminal device line up in number of processes average value.It specifically, can be in linux system
It is instructed by using preset inquiry instruction, such as uptime, top, to inquire the system load of terminal device.
The system load of terminal device can usually pass through the middle central processing unit (central of terminal device
Processing unit, cpu) occupancy or input and output (input/output, io) throughput indicate.Determine terminal
The mode of the system load of equipment specifically can be, the node of cpu or io in reading system, the system for obtaining terminal device with this
Load.Then terminal device can carry out dynamic regulation, i.e. the arrangement algorithm of dynamic regulation memory fragmentation according to system load, point
Grade realizes that memory fragmentation arranges, and improves the efficiency that terminal device carries out memory fragmentation arrangement, and reduce and carry out memory fragmentation arrangement
Influence to the application scenarios run on terminal device.Specifically, if system load is in the first preset range, terminal device
Determining that memory fragmentation arranges algorithm is that depth memory fragmentation arranges algorithm, i.e. execution step 708;If it is pre- that system load is in second
If range, then it is that moderate memory fragmentation arranges algorithm that terminal device, which determines that memory fragmentation arranges algorithm, i.e. execution step 707;Or
If system load is in third preset range, it is that slight memory fragmentation arranges calculation that terminal device, which determines that memory fragmentation arranges algorithm,
Method, i.e. execution step 706.
It is as shown in table 3 that specific gradation memory arranges algorithm:
Table 3
According to table 3, specifically, when system load < 20%, system load is not high at this time, carries out in depth at this time
Depositing defragmentation algorithms not influences the operation of currently running application scenarios or other application scenarios on terminal device, and depth arranges
Algorithm includes whole to irremovable page compact district, irremovable page general area and removable page pool progress memory fragmentation
Reason;When system load is in 20%~40%, terminal device carries out moderate memory fragmentation and arranges algorithm, broken compared to depth memory
Piece, which arranges algorithm, reduces the arrangement of irremovable page compact district, and the load of system when memory fragmentation arrangement is carried out to reduce,
It can be to avoid currently running application scenarios on influence terminal device or the efficiency of other application scenarios operation;At system load
When 40%~60%, system is more busy at this time, can carry out slight memory fragmentation arrangement, only arranges removable page pool,
To reduce influence of the memory fragmentation arrangement to application scenarios currently running on terminal device or other application scenarios;When system is negative
When load is > 60%, the system of terminal device is busy at this time, can arrange without memory fragmentation, to avoid terminal device is influenced
On the application scenarios that are currently running.
It should be noted that second preset range is 20%~40% in addition to the first preset range can be < 20%, the
Three preset ranges are 40%~60%, and the first preset range, the second preset range and third preset range can also be other values,
It can specifically be adjusted according to actual design demand, be not construed as limiting herein.
In the embodiment of the present application, it can determine that different memory fragmentations arranges algorithm according to system load, reduce to end
The influence of currently running application scenarios or other application scenarios in end equipment, transports the application scenarios on terminal device normally
Row, while available contiguous memory can be sorted out, improve efficiency when terminal device carries out memory switching.
706, it executes slight memory fragmentation and arranges algorithm.
When the system load on terminal device is in third preset range, terminal device executes slight memory fragmentation and arranges
Algorithm arranges removable page pool.Wherein, carry out the step of memory fragmentation arrangement with it is quick whole in abovementioned steps 704
The slight memory fragmentation arrangement algorithm managed in contiguous memory is similar, and specific details are not described herein again.
In the embodiment of the present application, it when system load is in third preset range, executes slight memory fragmentation and arranges calculation
Method, the third preset range can be in the higher situation of system load, can to avoid to be currently running on terminal device its
The influence of his application scenarios.
707, it executes moderate memory fragmentation and arranges algorithm;
When the system load on terminal device is in the second preset range, executes moderate memory fragmentation and arrange algorithm, it is right
Irremovable page general area and removable page pool carry out memory fragmentation arrangement.Wherein, for moving the whole of page pool
Reason mode is similar with the slight memory fragmentation arrangement algorithm in fast finishing contiguous memory in abovementioned steps 704, specifically herein not
It repeats again.In preset unit range, the irremovable page is greater than 0 and is no more than intensive threshold value, then it is assumed that the unit range
Interior is irremovable general area.For example, if the irremovable page is no more than 100, and is greater than 0, then in 1024 pages
It is considered that 1024 pages belong to irremovable page general area.It is specific to the memory scrubbing of irremovable page general area
It can be connected with being in as shown in figure 9, the removable page in irremovable page general area is arranged, the removable page
In continuous memory pages, continuous page is sorted out with this.Wherein it is possible to which the removable page can be moved to the continuous interior of free time
It in depositing, can also be moved in the contiguous memory adjacent with the irremovable page, can specifically be adjusted according to actual design demand, this
Place is not construed as limiting.
Therefore, in the embodiment of the present application, when the system load of terminal device is in the second preset range, terminal at this time
Equipment is in the moderate situation of system load, can carry out moderate memory fragmentation and arrange algorithm, only common to the irremovable page
Area and removable page pool are arranged, and to adapt to the system load of moderate equipment, improve the operational efficiency of terminal device, and
Available contiguous memory can be sorted out in advance.
In the embodiment of the present application, the irremovable page is arranged, after avoiding system long-play, because not removable
The dynamic page increases and reduces the efficiency and success rate of memory fragmentation arrangement, and terminal device can be improved and carry out memory fragmentation arrangement
Efficiency and success rate.
708, it executes depth memory fragmentation and arranges algorithm.
When the system load on terminal device is in the first preset range, terminal device can execute depth memory fragmentation
Algorithm is arranged, including memory is carried out to irremovable page compact district, irremovable page general area and removable page pool
Defragmentation.Wherein removable page pool is carried out in memory fragmentation arrangement and abovementioned steps 704 in fast finishing contiguous memory
Slight memory fragmentation to arrange algorithm similar, wherein carrying out memory fragmentation arrangement and abovementioned steps to irremovable page general area
Moderate memory fragmentation arrangement algorithm in 707 is similar, and specific details are not described herein again.It is broken to the memory of irremovable page compact district
What piece arranged specifically can be as shown in Figure 10, can be by the removable page movement of irremovable page compact district to irremovable
On the free memory of page compact district, contiguous memory can be used on terminal device to increase.It specifically, can be by the irremovable page
On the removable page movement to the free memory pages being spaced between the irremovable page of compact district.When simultaneously to removable page
When face area, irremovable page general area and irremovable page compact district are arranged, removable page movement can be arrived
On the free memory pages being spaced between the irremovable page, to sort out more free memory pages.And irremovable page
Face general area and irremovable page compact district are arranged, after avoiding system long-play, because the irremovable page increases
Add and reduce the efficiency and success rate of memory fragmentation arrangement.Memory of the terminal device after system long-play can be reduced
Efficiency and success rate that terminal device carries out memory fragmentation arrangement can be improved in the intensification degree of fragment.
In addition, in the embodiment of the present application, when terminal device is switched to the second application scenarios from the first application scenarios, if
Available contiguous memory on terminal device is not enough to start or run second application scenarios, then terminal device can carry out quickly
Memory scrubbing.Such as execute slight memory fragmentation and arrange algorithm so that the available contiguous memory on terminal device meet this second
Contiguous memory needed for application scenarios.For example, terminal device currently runs the first application scenarios, answered to will switch second
It is predicted with scene, and after obtaining target contiguous memory, because of contiguous memory deficiency on terminal device, needs to carry out memory fragmentation
It arranges.When carrying out memory fragmentation arrangement or before carrying out memory fragmentation arrangement, if terminal device is switched to the second application at this time
Scene, then terminal device can also enable slight memory fragmentation and arrange algorithm at this time, free memory be quickly cleaned out, to ensure end
End equipment can normally start the second application scenarios of operation.
In the embodiment of the present application, after target contiguous memory is determined by way of prediction, then memory fragmentation is actively carried out
It arranges, to clean out the available contiguous memory for being not less than target contiguous memory, to ensure that terminal device can normally switch application
Scene.When carrying out memory fragmentation arrangement, progress fast memory defragmentation is protected first with quickly obtaining available contiguous memory
Hinder contiguous memory demand when terminal device switching.Further, after carrying out fast memory defragmentation, if at this time also not
The second application scenarios are switched to, then terminal device can carry out memory fragmentation arrangement according further to system load, according to end
The system load of end equipment carries out dynamic adjustment to memory scrubbing algorithm, available continuous interior on terminal device to further increase
It deposits.Avoid terminal device after system long-play, it is not possible to which move page increases, and RAM fragmentation severity is promoted, whole
The success rate for managing out contiguous memory is low, caused Memory Allocation speed decline.And the resource of terminal device can be carried out rationally
It utilizes, reduces the influence to the application scenarios being currently running on terminal device, improve the efficiency of terminal device switching application scenarios
And reliability.
The aforementioned method to memory management provided by the present application is described in detail, specifically, in the embodiment of the present application
Terminal device can be smart phone, tablet computer, vehicle-mounted mobile, PDA (Personal Digital
Assistant, personal digital assistant), camera or various wearable devices etc., this is not limited here.Below with terminal device
In concrete application scene for be further illustrated.
Figure 11 is please referred to, the specific handoff scenario schematic diagram of one of the method for memory management in the embodiment of the present application.Its
In, by taking the terminal device is smart phone as an example, multiple applications are mounted in the smart phone, including wechat and phase
Machine can be switched to camera from wechat and take pictures when user is when using the smart phone.When terminal device switches from wechat
When to camera, starting camera is carried out first, subsequently into camera preview, is just carried out camera later and is taken pictures.Wherein, in camera preview
Scene and camera scene of taking pictures can all be used to a large amount of contiguous memories, if it is clear lower than certain threshold value just to execute memory in memory
Reason, then to camera preview scene and camera take pictures scene distribution contiguous memory when, if contiguous memory is insufficient, just carry out at this time
Memory fragmentation arrangement, which will lead to, waits long period storage allocation, therefore leads to terminal device Caton, influences user experience.
It therefore, is the operational efficiency for improving smart phone, the specific steps of the method for memory management provided by the present application can
To include:
When smart phone is currently running wechat, at this point, terminal device is switched to other application scenarios to from wechat
Number is acquired, and obtains the switching times that camera is switched to from wechat.Specific acquisition mode can be, to every time from wechat
Other application scenarios are switched to be recorded.For example, being 100 times from the number that wechat is switched to camera, it is switched to and answers from wechat
It is 2 inferior with the number in market.Then respectively acquire smart phone on it is each application or application scenarios in starting and operation
Required contiguous memory, camera preview scene and camera including camera take pictures scene operation needed for contiguous memory size.
Specific acquisition mode can be, and switch count variable is inserted into the memory allocation function in smart phone, right
The contiguous memory of each Memory Allocation is counted, and is prepared to enter into respectively in camera every time, into obtaining one when completing and exiting
Secondary counting is the contiguous memory demand when camera starts into the contiguous memory difference acquired when completing and accurately entering,
Exit and into the difference of completion be the camera entirety contiguous memory demand.
When being acquired to the number for being switched to other application and application scenarios from wechat, can update simultaneously from micro-
Letter is switched to the number of other application or application scenarios, is acquired so as to subsequent to camera handover information.Collecting camera
Contiguous memory after, the contiguous memory needed for camera can also be updated, so that smart phone is according to historical record data
The contiguous memory demand of the camera is determined with collected data.
After the related information of the handover information and camera that determine camera, it can answer currently other are switched to from wechat
With or application scenarios probability, wherein can determine that the probability for being switched to camera from wechat is 90%, smart phone can be at this time
Prediction will be switched to camera scene.For the probability of prediction camera starting, the sample that smart phone starts camera is more, prediction
Probability it is more accurate, the efficiency of prediction is also higher.For example, sample, which is more than 100,000, can be predicted when entering wechat
Start the probability of camera out, if sample only 1, it can only be predicted when entering camera.And it is continuously interior for camera
Deposit demand, it is only necessary to which a sample can be predicted.
After smart phone prediction will be switched to camera scene, identify in continuous needed for camera starting and operation
It deposits, required contiguous memory of taking pictures including camera preview and camera.Subsequent start-up memory fragmentation arranges.Computational intelligence hand first
Current available contiguous memory on machine, if available contiguous memory current on smart phone starts no more than camera and run institute
The contiguous memory needed, then smart phone can be with fast memory defragmentation, if available contiguous memory current on smart phone is big
In camera start and run needed for contiguous memory or smart phone do not compare can with contiguous memory and camera starting and
When contiguous memory needed for operation, smart phone can calculate current irremovable page compact district, if the current irremovable page
Compact district is greater than preset value, and the current RAM fragmentation degree of smart phone is serious, then smart phone can also carry out subsequent
Memory fragmentation arranges step, first progress fast memory defragmentation.Fast memory defragmentation, which can be, executes slight memory
Defragmentation algorithms arrange the memory fragmentation on smart phone, first fast finishing go out camera preview scene needed for company
Continuous memory, then sorts out contiguous memory required when camera is taken pictures.After the completion of fast memory defragmentation, Ke Yiji
Then the continuous system load for obtaining smart phone adjusts memory fragmentation according to the system load of smart phone dynamic and arranges algorithm,
For example, when system load is less than 20%, executes depth memory fragmentation and arrange algorithm, to irremovable page compact district, can not
Mobile page general area and removable page pool are arranged, wherein the specific step arranged in algorithm and earlier figures 7
706- step 708 is similar, and specific details are not described herein again;If system load is in 20%-40%, moderate memory can be executed at this time
Defragmentation algorithms carry out memory fragmentation arrangement to irremovable page general area and removable page pool;If system load
In 40%-60%, moderate memory fragmentation being executed at this time and arranges algorithm, it is whole to carry out memory fragmentation to removable page pool
Reason;If system load is greater than 60%, memory fragmentation arrangement can not be executed, to avoid being currently running on smart phone is influenced
Application.
The aforementioned method to the memory management provided in the embodiment of the present application is described in detail, in addition, the application is real
It applies example and additionally provides the terminal device for implementing the method for dry memory management, please refer to Figure 12, terminal device in the embodiment of the present application
One embodiment schematic diagram, may include:
Data acquisition module 1201 is switched in one or more second application scenarios for obtaining from the first application scenarios
The switching probability of each second application scenarios, the application scenarios which is currently run for the terminal device, tool
Body can be used to implement the specific steps of step 401 in 4 embodiment of earlier figures;
Contiguous memory demand identification module 1202, for according to meet in the switching probability switching probability of preset condition with
And in second application scenarios of one or more switching probability meet it is continuous needed for the second application scenarios of each of preset condition
Memory determines target contiguous memory, specifically can be used to implement the specific steps of step 403 in 4 embodiment of earlier figures;
Active memory defragmentation module 1203, if available contiguous memory is continuous no more than the target on the terminal device
Memory then any second is answered what the terminal device was switched in second application scenarios of one or more from the first application scenarios
Before scene, for carrying out memory fragmentation arrangement according to the target contiguous memory, so that available continuous on the terminal device
Memory is greater than the target contiguous memory, specifically can be used to implement the specific steps of step 406 in 4 embodiment of earlier figures.
In some possible embodiments, the active memory defragmentation module 1203, is specifically used for:
Determine that memory fragmentation arranges algorithm according to system load;
Algorithm is arranged according to the memory fragmentation and the target contiguous memory carries out memory fragmentation arrangement;
It specifically can be used to implement step 705 in 7 embodiment of earlier figures and the specific steps in correlation step.
In some possible embodiments, the active memory defragmentation module 1203, is specifically also used to:
If the system load is in the first preset range, it is determined that it is that depth memory fragmentation is whole that the memory fragmentation, which arranges algorithm,
Adjustment method;
If the system load is in the second preset range, it is determined that it is that moderate memory fragmentation is whole that the memory fragmentation, which arranges algorithm,
Adjustment method;Or
If the system load is in third preset range, it is determined that it is that slight memory fragmentation is whole that the memory fragmentation, which arranges algorithm,
Adjustment method;
It specifically can be used to implement the specific steps in 7 embodiment of earlier figures in step 705- step 708.
In some possible embodiments, the data acquisition module 1201, is specifically used for:
It obtains from first application scenarios and is switched to each second application scenarios in second application scenarios of one or more
History switching times;
It is determined according to the history switching times from first application scenarios and is switched to second application scenarios of one or more
In each second application scenarios switching probability;
It specifically can be used to implement the specific steps in 5 embodiment of earlier figures in step 502.
In some possible embodiments, the contiguous memory demand identification module 1202, is specifically used for:
Determine that the switching probability is greater than the second application scenarios of threshold value from second application scenarios of one or more;
Contiguous memory needed for the second application scenarios for being greater than threshold value according to the switching probability determines the target contiguous memory,
It specifically can be used to implement the specific steps in 5 embodiment of earlier figures in step 506.
In some possible embodiments, the contiguous memory demand identification module 1202, is specifically also used to:
Multiple switching probabilities are greater than the second application scenarios of threshold value if it exists, are greater than the of threshold value to multiple switching probability
The switching probability of each second application scenarios and required contiguous memory are weighted in two application scenarios, to be somebody's turn to do
Target contiguous memory specifically can be used to implement the specific steps in 5 embodiment of earlier figures in step 506.
In some possible embodiments, the contiguous memory demand identification module 1202, is specifically used for:
The terminal device is greater than the second application scenarios of threshold value from the terminal device from the one or more switching probability
The maximum target application scene of contiguous memory needed for middle determination;
The terminal device can specifically be used using contiguous memory needed for the target application scene as the target contiguous memory
Specific steps in realization 5 embodiment of earlier figures in step 506.
In some possible embodiments, the active memory defragmentation module 1203, is also used to:
When the terminal device is switched to from first application scenarios wherein one in second application scenarios of one or more
A second application scenarios, and the available contiguous memory on the terminal device is unsatisfactory for needed for one of them second application scenarios
When contiguous memory, which arranges memory fragmentation by fast memory defragmentation algorithms, specifically can be used for
Realize the specific steps in 7 embodiment of earlier figures in step 704.
The embodiment of the present application also provides a kind of terminal devices, as shown in figure 13, for ease of description, illustrate only and this
The relevant part of inventive embodiments, it is disclosed by specific technical details, please refer to present invention method part.The terminal is set
It include mobile phone, tablet computer, PDA (Personal Digital Assistant, personal digital assistant), POS for that can be
Any terminal device such as (Point of Sales, point-of-sale terminal), vehicle-mounted computer, by taking terminal device is mobile phone as an example:
Figure 13 shows the block diagram of the part-structure of mobile phone relevant to terminal provided in an embodiment of the present invention.With reference to figure
13, mobile phone includes: radio frequency (Radio Frequency, RF) circuit 1310, memory 1320, input unit 1330, display unit
1340, sensor 1350, voicefrequency circuit 1360, Wireless Fidelity (wireless fidelity, WiFi) module 1370, processor
The components such as 1380 and power supply 1390.It will be understood by those skilled in the art that handset structure shown in Figure 13 is not constituted pair
The restriction of mobile phone may include perhaps combining certain components or different component cloth than illustrating more or fewer components
It sets.
It is specifically introduced below with reference to each component parts of the Figure 13 to mobile phone:
RF circuit 1310 can be used for receiving and sending messages or communication process in, signal sends and receivees, particularly, by base station
After downlink information receives, handled to processor 1380;In addition, the data for designing uplink are sent to base station.In general, RF circuit
1310 include but is not limited to antenna, at least one amplifier, transceiver, coupler, low-noise amplifier (Low Noise
Amplifier, LNA), duplexer etc..In addition, RF circuit 1310 can also be logical with network and other equipment by wireless communication
Letter.Any communication standard or agreement, including but not limited to global system for mobile communications (Global can be used in above-mentioned wireless communication
System of Mobile communication, GSM), general packet radio service (General Packet Radio
Service, GPRS), CDMA (Code Division Multiple Access, CDMA), wideband code division multiple access
(Wideband Code Division Multiple Access, WCDMA), long term evolution (Long Term Evolution,
LTE), Email, short message service (Short Messaging Service, SMS) etc..
Memory 1320 can be used for storing software program and module, and processor 1380 is stored in memory by operation
1320 software program and module, thereby executing the various function application and data processing of mobile phone.Memory 1320 can be led
It to include storing program area and storage data area, wherein storing program area can be needed for storage program area, at least one function
Application program (such as sound-playing function, image player function etc.) etc.;Storage data area, which can be stored, uses institute according to mobile phone
Data (such as audio data, phone directory etc.) of creation etc..In addition, memory 1320 may include high random access storage
Device, can also include nonvolatile memory, and a for example, at least disk memory, flush memory device or other volatibility are solid
State memory device.
Input unit 1330 can be used for receiving the number or character information of input, and generate with the user setting of mobile phone with
And the related key signals input of function control.Specifically, input unit 1330 may include touch panel 1331 and other inputs
Equipment 1332.Touch panel 1331, also referred to as touch screen collect touch operation (such as the user of user on it or nearby
Use the behaviour of any suitable object or attachment such as finger, stylus on touch panel 1331 or near touch panel 1331
Make), and corresponding attachment device is driven according to preset formula.Optionally, touch panel 1331 may include touch detection
Two parts of device and touch controller.Wherein, the touch orientation of touch detecting apparatus detection user, and detect touch operation band
The signal come, transmits a signal to touch controller;Touch controller receives touch information from touch detecting apparatus, and by it
It is converted into contact coordinate, then gives processor 1380, and order that processor 1380 is sent can be received and executed.In addition,
Touch panel 1331 can be realized using multiple types such as resistance-type, condenser type, infrared ray and surface acoustic waves.In addition to touch surface
Plate 1331, input unit 1330 can also include other input equipments 1313.Specifically, other input equipments 1313 can wrap
It includes but is not limited in physical keyboard, function key (such as volume control button, switch key etc.), trace ball, mouse, operating stick etc.
It is one or more.
Display unit 1340 can be used for showing information input by user or be supplied to user information and mobile phone it is each
Kind menu.Display unit 1340 may include display panel 1341, optionally, can use liquid crystal display (Liquid
Crystal Display, LCD), the forms such as Organic Light Emitting Diode (Organic Light-Emitting Diode, OLED)
To configure display panel 1341.Further, touch panel 1331 can cover display panel 1341, when touch panel 1331 is examined
After measuring touch operation on it or nearby, processor 1380 is sent to determine the type of touch event, is followed by subsequent processing device
1380 provide corresponding visual output according to the type of touch event on display panel 1341.Although in Figure 13, touch surface
Plate 1331 and display panel 1341 are the input and input function for realizing mobile phone as two independent components, but certain
In embodiment, can be integrated by touch panel 1331 and display panel 1341 and that realizes mobile phone output and input function.
Mobile phone may also include at least one sensor 1350, such as optical sensor, motion sensor and other sensors.
Specifically, optical sensor may include ambient light sensor and proximity sensor, wherein ambient light sensor can be according to ambient light
Light and shade adjust the brightness of display panel 1341, proximity sensor can close display panel when mobile phone is moved in one's ear
1341 and/or backlight.As a kind of motion sensor, accelerometer sensor can detect in all directions (generally three axis)
The size of acceleration can detect that size and the direction of gravity when static, the application that can be used to identify mobile phone posture is (such as vertical and horizontal
Shield switching, dependent game, magnetometer pose calibrating), Vibration identification correlation function (such as pedometer, percussion) etc.;As for mobile phone
The other sensors such as gyroscope, barometer, hygrometer, thermometer, the infrared sensor that can also configure, details are not described herein.
Voicefrequency circuit 1360, loudspeaker 1361, microphone 1362 can provide the audio interface between user and mobile phone.Audio
Electric signal after the audio data received conversion can be transferred to loudspeaker 1361, be converted by loudspeaker 1361 by circuit 1360
For voice signal output;On the other hand, the voice signal of collection is converted to electric signal by microphone 1362, by voicefrequency circuit 1360
Audio data is converted to after reception, then by after the processing of audio data output processor 1380, through RF circuit 1310 to be sent to ratio
Such as another mobile phone, or audio data is exported to memory 1320 to be further processed.
WiFi belongs to short range wireless transmission technology, and mobile phone can help user's transceiver electronics postal by WiFi module 1370
Part, browsing webpage and access streaming video etc., it provides wireless broadband internet access for user.Although Figure 13 is shown
WiFi module 1370, but it is understood that, and it is not belonging to must be configured into for mobile phone, it is can according to need completely not
Change in the range of the essence of invention and omits.
Processor 1380 is the control centre of mobile phone, using the various pieces of various interfaces and connection whole mobile phone,
By running or execute the software program and/or module that are stored in memory 1320, and calls and be stored in memory 1320
Interior data execute the various functions and processing data of mobile phone, to carry out integral monitoring to mobile phone.Optionally, processor
1380 may include one or more processing units;Preferably, processor 1380 can integrate application processor and modulation /demodulation processing
Device, wherein the main processing operation system of application processor, user interface and application program etc., modem processor is mainly located
Reason wireless communication.It is understood that above-mentioned modem processor can not also be integrated into processor 1380.The processor
1380 can execute the specific steps that earlier figures 3 are executed into Figure 13 by terminal device.
Mobile phone further includes the power supply 1390 (such as battery) powered to all parts, it is preferred that power supply can pass through power supply
Management system and processor 1380 are logically contiguous, to realize management charging, electric discharge and power consumption pipe by power-supply management system
The functions such as reason.
Although being not shown, mobile phone can also include camera, bluetooth module etc., and details are not described herein.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed system, device and method can be with
It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the unit
It divides, only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or components
It can be combined or can be integrated into another system, or some features can be ignored or not executed.Another point, it is shown or
The mutual coupling, direct-coupling or communication connection discussed can be through some interfaces, the indirect coupling of device or unit
It closes or communicates to connect, can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, each functional unit in each embodiment of the application can integrate in one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and sells or use as independent product
When, it can store in a computer readable storage medium.Based on this understanding, the technical solution of the application is substantially
The all or part of the part that contributes to existing technology or the technical solution can be in the form of software products in other words
It embodies, which is stored in a storage medium, including some instructions are used so that a computer
Equipment (can be personal computer, server or the network equipment etc.) executes the application Fig. 3 each embodiment institute into Figure 11
State all or part of the steps of method.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (ROM, Read-
Only Memory), random access memory (RAM, Random Access Memory), magnetic or disk etc. are various can be with
Store the medium of program code.
The above, above embodiments are only to illustrate the technical solution of the application, rather than its limitations;Although referring to before
Embodiment is stated the application is described in detail, those skilled in the art should understand that: it still can be to preceding
Technical solution documented by each embodiment is stated to modify or equivalent replacement of some of the technical features;And these
It modifies or replaces, the range of each embodiment technical solution of the application that it does not separate the essence of the corresponding technical solution.
Claims (18)
1. a kind of method of memory management characterized by comprising
It obtains terminal device and is switched to each second application scenarios in one or more second application scenarios from the first application scenarios
Switching probability, the application scenarios that first application scenarios are currently run by the terminal device;
It is applied according to the one or more second that switching probability in one or more of second application scenarios meets preset condition
Contiguous memory needed for scene determines target contiguous memory;
If available contiguous memory is less than the target contiguous memory on the terminal device, in the terminal device from first
Application scenarios are switched to before any second application scenarios in one or more of second application scenarios, carry out memory fragmentation
It arranges, so that available contiguous memory is greater than the target contiguous memory on the terminal device.
2. the method according to claim 1, wherein the progress memory fragmentation arrangement, comprising:
Determine that memory fragmentation arranges algorithm according to range locating for the system load of the terminal device;
Algorithm is arranged using the determining memory fragmentation, and memory fragmentation arrangement is carried out to the memory of the terminal device.
3. according to the method described in claim 2, it is characterized in that, the range according to locating for system load determines that memory is broken
Piece arranges algorithm, comprising:
If the system load is in the first preset range, it is determined that it is that depth memory fragmentation is whole that the memory fragmentation, which arranges algorithm,
Adjustment method;
If the system load is in the second preset range, it is determined that it is that moderate memory fragmentation is whole that the memory fragmentation, which arranges algorithm,
Adjustment method;Or
If the system load is in third preset range, it is determined that it is that slight memory fragmentation is whole that the memory fragmentation, which arranges algorithm,
Adjustment method.
4. method according to any one of claim 1-3, which is characterized in that the acquisition terminal device is applied from first
Switching probability of the scene switching to one or more second application scenarios, comprising:
Terminal device is obtained to be switched to each second in one or more of second application scenarios from first application scenarios
The history switching times of application scenarios;
It is determined according to the history switching times from first application scenarios and is switched to one or more of second applied fields
The switching probability of each second application scenarios in scape.
5. method described in -4 according to claim 1, which is characterized in that described according to one or more of second applied fields
Contiguous memory needed for switching probability meets the second application scenarios of one or more of the preset condition in scape determines that target connects
Continuous memory, comprising:
Determine that one or more switching probability is greater than the second applied field of threshold value from one or more of second application scenarios
Scape;
Contiguous memory needed for the second application scenarios for being greater than threshold value according to one or more of switching probabilities determines the mesh
Mark contiguous memory.
6. according to the method described in claim 5, it is characterized in that, if determining switching from one or more of second scenes
Probability be greater than the threshold value the second application scenarios have it is multiple, it is described according to one or more of switching probabilities be greater than the threshold
Contiguous memory needed for second application scenarios of value determines the target contiguous memory, comprising:
Contiguous memory needed for each second application scenarios in second application scenarios of threshold value is greater than to the multiple switching probability
It is weighted, to obtain the target contiguous memory.
7. method according to claim 5, which is characterized in that described to be greater than according to one or more of switching probabilities
Contiguous memory needed for second application scenarios of the threshold value determines the target contiguous memory, comprising:
The contiguous memory needed for determining in the second application scenarios that one or more of switching probabilities are greater than the threshold value is maximum
Target application scene;
It is the target contiguous memory by contiguous memory needed for the target application scene.
8. method according to claim 1 to 6, which is characterized in that the method also includes:
When the terminal device is switched in one or more of second application scenarios wherein from first application scenarios
One the second application scenarios, and the available contiguous memory on the terminal device is unsatisfactory for one of them described second application scenarios
When required contiguous memory, the terminal device arranges algorithm by slight memory fragmentation and carries out to the memory of the terminal device
It arranges.
9. a kind of terminal device characterized by comprising
Data acquisition module is switched in one or more second application scenarios for obtaining terminal device from the first application scenarios
The switching probability of each second application scenarios, the applied field that first application scenarios are currently run by the terminal device
Scape;
Contiguous memory demand identification module, it is default for being met according to switching probability in one or more of second application scenarios
Contiguous memory needed for the second application scenarios of one or more of condition determines target contiguous memory;
Active memory defragmentation module, if available contiguous memory is less than the target contiguous memory on the terminal device,
Then any second answered what the terminal device was switched in one or more of second application scenarios from the first application scenarios
Before scene, for carrying out memory fragmentation arrangement according to the target contiguous memory, so that available on the terminal device
Contiguous memory is greater than the target contiguous memory.
10. terminal device according to claim 9, which is characterized in that the active memory defragmentation module, it is specific to use
In:
Determine that memory fragmentation arranges algorithm according to range locating for the system load of the terminal device;
Algorithm is arranged using the determining memory fragmentation, and memory fragmentation arrangement is carried out to the memory of the terminal device.
11. terminal device according to claim 10, which is characterized in that the active memory defragmentation module, specifically
For:
If the system load is in the first preset range, it is determined that it is that depth memory fragmentation is whole that the memory fragmentation, which arranges algorithm,
Adjustment method;
If the system load is in the second preset range, it is determined that it is that moderate memory fragmentation is whole that the memory fragmentation, which arranges algorithm,
Adjustment method;Or
If the system load is in third preset range, it is determined that it is that slight memory fragmentation is whole that the memory fragmentation, which arranges algorithm,
Adjustment method.
12. the terminal device according to any one of claim 9-11, which is characterized in that the data acquisition module, tool
Body is used for:
Terminal device is obtained to be switched to each second in one or more of second application scenarios from first application scenarios
The history switching times of application scenarios;
It is determined according to the history switching times from first application scenarios and is switched to one or more of second applied fields
The switching probability of each second application scenarios in scape.
13. according to terminal device described in claim 9-12, which is characterized in that the contiguous memory demand identification module,
It is specifically used for:
Determine that one or more switching probability is greater than the second applied field of threshold value from one or more of second application scenarios
Scape;
Contiguous memory needed for the second application scenarios for being greater than threshold value according to one or more of switching probabilities determines the mesh
Mark contiguous memory.
14. terminal device according to claim 13, which is characterized in that the contiguous memory demand identification module, specifically
For:
To the multiple switching probability be greater than threshold value the second application scenarios in each second application scenarios switching probability and
Required contiguous memory is weighted, to obtain the target contiguous memory.
15. terminal device according to claim 13, which is characterized in that the contiguous memory demand identification module, tool
Body is used for:
The terminal device is continuous needed for determining in the second application scenarios that one or more of switching probabilities are greater than threshold value
The maximum target application scene of memory;
Using contiguous memory needed for the target application scene as the target contiguous memory.
16. the terminal device according to any one of claim 9-15, which is characterized in that the active memory defragmentation
Module is also used to:
When the terminal device is switched in one or more of second application scenarios wherein from first application scenarios
One the second application scenarios, and the available contiguous memory on the terminal device is unsatisfactory for one of them described second application scenarios
When required contiguous memory, the terminal device arranges algorithm by slight memory fragmentation and arranges to memory fragmentation.
17. a kind of terminal device characterized by comprising
Processor and memory;
Computer program is stored in the memory;
The processor realizes the step of any one of claim 1-8 the method when executing described program.
18. a kind of computer readable storage medium is stored thereon with instruction, which is characterized in that described instruction is executed by processor
The step of any one of Shi Shixian claim 1-8 the method.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810333058.6A CN110377527B (en) | 2018-04-13 | 2018-04-13 | Memory management method and related equipment |
PCT/CN2019/082098 WO2019196878A1 (en) | 2018-04-13 | 2019-04-10 | Method for memory management and related device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810333058.6A CN110377527B (en) | 2018-04-13 | 2018-04-13 | Memory management method and related equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110377527A true CN110377527A (en) | 2019-10-25 |
CN110377527B CN110377527B (en) | 2023-09-22 |
Family
ID=68163011
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810333058.6A Active CN110377527B (en) | 2018-04-13 | 2018-04-13 | Memory management method and related equipment |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110377527B (en) |
WO (1) | WO2019196878A1 (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111078405A (en) * | 2019-12-10 | 2020-04-28 | Oppo(重庆)智能科技有限公司 | Memory allocation method and device, storage medium and electronic equipment |
CN111444116A (en) * | 2020-03-23 | 2020-07-24 | 海信电子科技(深圳)有限公司 | Storage space fragment processing method and device |
CN112925478A (en) * | 2021-01-29 | 2021-06-08 | 惠州Tcl移动通信有限公司 | Camera storage space control method, intelligent terminal and computer readable storage medium |
CN113082705A (en) * | 2021-05-08 | 2021-07-09 | 腾讯科技(上海)有限公司 | Game scene switching method and device, computer equipment and storage medium |
US20220283934A1 (en) * | 2021-03-02 | 2022-09-08 | Western Digital Technologies, Inc. | Storage System and Method for Automatic Defragmentation of Memory |
CN116400871A (en) * | 2023-06-09 | 2023-07-07 | Tcl通讯科技(成都)有限公司 | Defragmentation method, defragmentation device, storage medium and electronic device |
CN116661988A (en) * | 2022-12-29 | 2023-08-29 | 荣耀终端有限公司 | Memory normalization method, electronic device and readable storage medium |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115982060B (en) * | 2021-10-14 | 2024-07-05 | 华为技术有限公司 | Memory recycling method and related device |
CN118708502A (en) * | 2024-08-28 | 2024-09-27 | 深圳市云希谷科技有限公司 | Method for improving generation of large amount of memory fragments in use of map heap under freeRTOS |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110047470A1 (en) * | 2006-10-18 | 2011-02-24 | Streamezzo | Method for managing memory in a client terminal, corresponding signal, computer program and terminal |
CN105701025A (en) * | 2015-12-31 | 2016-06-22 | 华为技术有限公司 | Memory recovery method and device |
CN107133094A (en) * | 2017-06-05 | 2017-09-05 | 努比亚技术有限公司 | Application management method, mobile terminal and computer-readable recording medium |
CN107273011A (en) * | 2017-06-26 | 2017-10-20 | 努比亚技术有限公司 | Application program fast switch over method and mobile terminal |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6571326B2 (en) * | 2001-03-08 | 2003-05-27 | Intel Corporation | Space allocation for data in a nonvolatile memory |
CN1889737A (en) * | 2006-07-21 | 2007-01-03 | 华为技术有限公司 | Resource management method and system |
CN100462940C (en) * | 2007-01-30 | 2009-02-18 | 金蝶软件(中国)有限公司 | Method and apparatus for cache data in memory |
CN103150257A (en) * | 2013-02-28 | 2013-06-12 | 天脉聚源(北京)传媒科技有限公司 | Memory management method and memory management device |
CN105718027B (en) * | 2016-01-20 | 2019-05-31 | 努比亚技术有限公司 | The management method and mobile terminal of background application |
CN105939416A (en) * | 2016-05-30 | 2016-09-14 | 努比亚技术有限公司 | Mobile terminal and application prestart method thereof |
-
2018
- 2018-04-13 CN CN201810333058.6A patent/CN110377527B/en active Active
-
2019
- 2019-04-10 WO PCT/CN2019/082098 patent/WO2019196878A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110047470A1 (en) * | 2006-10-18 | 2011-02-24 | Streamezzo | Method for managing memory in a client terminal, corresponding signal, computer program and terminal |
CN105701025A (en) * | 2015-12-31 | 2016-06-22 | 华为技术有限公司 | Memory recovery method and device |
CN107133094A (en) * | 2017-06-05 | 2017-09-05 | 努比亚技术有限公司 | Application management method, mobile terminal and computer-readable recording medium |
CN107273011A (en) * | 2017-06-26 | 2017-10-20 | 努比亚技术有限公司 | Application program fast switch over method and mobile terminal |
Non-Patent Citations (1)
Title |
---|
黄文茜等: "基于用户行为分析的智能终端应用管理优化", 《计算机系统应用》 * |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111078405A (en) * | 2019-12-10 | 2020-04-28 | Oppo(重庆)智能科技有限公司 | Memory allocation method and device, storage medium and electronic equipment |
CN111078405B (en) * | 2019-12-10 | 2022-07-15 | Oppo(重庆)智能科技有限公司 | Memory allocation method and device, storage medium and electronic equipment |
CN111444116A (en) * | 2020-03-23 | 2020-07-24 | 海信电子科技(深圳)有限公司 | Storage space fragment processing method and device |
CN111444116B (en) * | 2020-03-23 | 2022-11-25 | 海信电子科技(深圳)有限公司 | Storage space fragment processing method and device |
CN112925478A (en) * | 2021-01-29 | 2021-06-08 | 惠州Tcl移动通信有限公司 | Camera storage space control method, intelligent terminal and computer readable storage medium |
US20220283934A1 (en) * | 2021-03-02 | 2022-09-08 | Western Digital Technologies, Inc. | Storage System and Method for Automatic Defragmentation of Memory |
US11520695B2 (en) * | 2021-03-02 | 2022-12-06 | Western Digital Technologies, Inc. | Storage system and method for automatic defragmentation of memory |
CN113082705A (en) * | 2021-05-08 | 2021-07-09 | 腾讯科技(上海)有限公司 | Game scene switching method and device, computer equipment and storage medium |
CN113082705B (en) * | 2021-05-08 | 2023-09-15 | 腾讯科技(上海)有限公司 | Game scene switching method, game scene switching device, computer equipment and storage medium |
CN116661988A (en) * | 2022-12-29 | 2023-08-29 | 荣耀终端有限公司 | Memory normalization method, electronic device and readable storage medium |
CN116661988B (en) * | 2022-12-29 | 2024-08-23 | 荣耀终端有限公司 | Memory normalization method, electronic device and readable storage medium |
CN116400871A (en) * | 2023-06-09 | 2023-07-07 | Tcl通讯科技(成都)有限公司 | Defragmentation method, defragmentation device, storage medium and electronic device |
Also Published As
Publication number | Publication date |
---|---|
WO2019196878A1 (en) | 2019-10-17 |
CN110377527B (en) | 2023-09-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110377527A (en) | A kind of method and relevant device of memory management | |
CN107220076B (en) | A kind of method for recovering internal storage and device | |
CN107357656B (en) | Memory allocation method, mobile terminal and computer readable storage medium | |
CN107368400B (en) | CPU monitoring method and device, computer readable storage medium and mobile terminal | |
CN107179950B (en) | Application process processing method, mobile terminal and computer readable storage medium | |
CN109992400A (en) | Resource allocation methods, device, mobile terminal and computer readable storage medium | |
US20170109756A1 (en) | User Unsubscription Prediction Method and Apparatus | |
CN106776036A (en) | A kind of resource allocation methods and device | |
CN103530115B (en) | Application program display method and device and terminal equipment | |
CN107766139B (en) | Application management method and device | |
CN104363988B (en) | A kind of management method and device of multi-core processor | |
CN108984064A (en) | Multi-screen display method, device, storage medium and electronic equipment | |
CN107391198B (en) | Method for scheduling task and device, computer readable storage medium, mobile terminal | |
CN109992367A (en) | Application processing method and device, electronic equipment, computer readable storage medium | |
CN104460934A (en) | Scheduling method and device for multi central processing units (CPU) | |
CN109062468A (en) | Multi-screen display method, device, storage medium and electronic equipment | |
CN104519262A (en) | Method, device for acquiring video data, and terminal | |
CN104424211A (en) | Microblog-based service data release method, device and system | |
CN109992399A (en) | Method for managing resource, device, mobile terminal and computer readable storage medium | |
EP3582450B1 (en) | Message notification method and terminal | |
CN106502833A (en) | Data back up method and device | |
CN110032439A (en) | Method for managing resource, device, mobile terminal and computer readable storage medium | |
CN109284110B (en) | Terminal application replacement method, terminal and computer readable storage medium | |
CN110555155A (en) | article information recommendation method, device and storage medium | |
CN109101328A (en) | The method, apparatus of mobile terminal and application program running background |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |