Embodiment
Here exemplary embodiment will be illustrated in detail, its example is illustrated in the accompanying drawings.Following description is related to
During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous key element.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended
The example of the consistent apparatus and method of some aspects be described in detail in claims, the application.
It is only merely for the purpose of description specific embodiment in term used in this application, and is not intended to be limiting the application.
" one kind " of singulative used in the application and appended claims, " described " and "the" are also intended to including majority
Form, unless context clearly shows that other implications.It is also understood that term "and/or" used herein refers to and wrapped
Containing the associated list items purpose of one or more, any or all may be combined.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the application
A little information should not necessarily be limited by these terms.These terms are only used for same type of information being distinguished from each other out.For example, do not departing from
In the case of the application scope, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as
One information.Depending on linguistic context, word as used in this " if " can be construed to " ... when " or " when ...
When " or " in response to determining ".
Present applicant proposes the scheme that the systematic function to equipment is improved.In certain embodiments, equipment can be
Desktop computer, in certain embodiments, equipment can be portable (such as notebook, tablet PC or hands
Holding equipment).In certain embodiments, equipment can be wearable (such as intelligent watch, intelligent glasses etc.), in some implementations
In example, equipment can be mounted to (such as car-mounted terminal, navigator etc.) in other equipment.
In some examples, the logical architecture of device interior may be referred to Fig. 1, and equipment has operating system 100, operating system
The type of (Operating System, OS) is not construed as limiting in this application, for example, can be Windows OS, iOS, MacOS,
Android OS, Linux OS, YunOS (cloud OS) etc..Certain operations system possibly relies on virtual machine, for example, Android
In OS, YunOS, therefore the upper strata of operating system 100 can be virtual machine 110, and virtual machine (Virtual Machine) is usually
Refer to the complete computers system that there is complete hardware system function, operating in a completely isolated environment simulated by software
System.It is readily appreciated that, in some examples, the logical framework of device interior may not also include virtual machine 110.System framework
(Framework) 120 be a language development software, there is provided the framework of software development, exploitation is had more engineering, simplicity
And stability.Equipment can be mounted with a variety of applications, and various applications are installed on application layer 130.Inside application or operating system
When the service of offer is run, operating system 100 starts corresponding process, and is the memory headroom of the course allocation independence.
Conventional art is generally internal using conventional GC (Garbage Collection, garbage collection) strategies
Deposit and be compressed, and conventional GC strategies can cause the fragment rate more and more higher in heap (heap area) region, therefore would generally enter
(such as using when being switched to backstage when not in use from the foreground used) is to the process institute in heap areas when journey is in the non-sensitive phase
Caused data do first compression processing.Due to the process (the application be referred to as the process of Activity attribute) related to interface compared with
Easily determine the state for entering the non-sensitive phase from sensitive periods, therefore conventional GC strategies are generally directed to there is entering for Activity attributes
The data in internal memory shared by journey are compressed and defragmentation, and in some OS, progress can be automatically controlled by virtual machine
The time point of compression.But can not it has been found that being compressed for the data in the internal memory shared by Activity processes
Solves the problems, such as memory source deficiency, its reason is substantial amounts of background process when equipment is run be present, for example, Services belongs to
The process of property and the ratio of the process committed memory of Persistent attributes are very high, due to Services attributes process or
Persistent attribute processes are typically the Resident Process on backstage, have no chance to be switched to the non-sensitive phase, so can not pass through GC
Strategy does the arrangement optimization in heap regions to these processes, causes system operation time to lengthen and consume more internal memories.Therefore,
Applicant proposes the scheme being compressed to the data in the internal memory shared by background process.Part flow in some examples can
Referring to Fig. 2 a.
S201a, operating system send the triggering command of memory compression to virtual machine;
S202a, the triggering command of virtual machine response memory compression, to specifying the data in the internal memory shared by background process
It is compressed.Background process is specified to include the process of Service attributes and/or the Persistent processes of attribute, it is worthwhile to note that
It is not precluded from the possibility being compressed when design needs to the background process of other attributes.
It is found by the applicant that when forced-triggered during some background process memory compression to that can sort out many fragments, in order to both
Data in internal memory shared by background process are compressed, and do not influence the normal use of user, in the example shown in Fig. 2 a
In son, by selecting suitable opportunity, the compression process of background process is actively triggered by the triggering command of memory compression, to rear
Platform process is compressed.
The example of Fig. 2 a descriptions, can be performed the operation of memory compression by virtual machine, certainly, in other examples,
According to the difference of operating system, the operation of memory compression can be performed by operating system or other executive agents.Some examples
In son, part steps as shown in Figure 2 b can be performed by performing the entity of memory compression:
S201b, receive the triggering command of memory compression;
S202b, to specifying the data in the internal memory shared by background process to be compressed;Specified background process can include
The process of Service attributes and/or the Persistent processes of attribute, but be not precluded from when design needs to other attributes
The possibility that background process is compressed.
Using executive agent as virtual machine instance, triggering command can come from outside virtual machine;Can also be default certain
Trigger condition, when meeting condition, virtual machine internal is sent automatically.In some examples, triggering command is sent from virtual machine outside
Opportunity can be operating system call virtual machine provided interface when, or by operating system to virtual machine send specify
Signal when actively trigger the triggering command of memory compression.As an example, the interface that virtual machine is provided can be virtual machine layer
The newly-increased interface extended, for example, it may be AMS (Activity Manager Service, application management service) module
Expansion interface, AMS modules can be managed to application program, such as download, be mobile, deleting, upgrading and buying authority.
The opportunity of memory compression for user can the function of normal use equipment have large effect, applicant is through excessive
The experimental study of amount, work out the sensitive periods of resident background process, it is determined that it is several actively trigger background process compression at the time of,
For example, active trigger event can be following one or more of modes:
1st, as the event for actively triggering background process compression when equipment is started;
2nd, a control specified can be increased newly, for example, button that a key accelerates etc., the master when the control that user's triggering is specified
The event of dynamic triggering background process compression;
The event that background process compresses, example are triggered when the 3rd, can trigger functional by some already present controls in the lump
Such as, this moment can be when background process clearing function is triggered.
It is readily appreciated that, cited several moment are merely exemplary to be illustrated, it is not excluded that other situations.
As an example, the process of compression is referred to carry out the process of Activity attributes the mode of GC compressions, such as
The compression algorithm of use can be mark-copy or mark-compact etc..In background process memory compression flow
After being triggered, the process of all Services attributes and Persistent attributes can be traveled through, internal memory pressure is sent to virtual machine
The triggering command of contracting.In order to reduce EMS memory occupation, the request can be Asynchronous Request.Virtual machine receives the triggering of memory compression
After instruction, the data in the internal memory shared by background process that can attempt to compress needs are compressed.
In some examples, virtual machine can record this memory compression after the triggering command of memory compression is received
The timestamp of triggering command, and record after each memory compression the time of this memory compression.If this receives internal memory pressure
The time interval of the time gap last time memory compression of the triggering command of contracting conforms to a predetermined condition, then performs to specifying background process
The step of data in shared internal memory are compressed, if not meeting predetermined condition, ignore touching for the memory compression
Send instructions, predetermined condition can determine according to the design requirement of designer, for example, 5 minutes can be set as time interval etc..
If this is applicant when fully taking into account that memory compression time interval is too short twice, newly-generated heap fragments are less, again
System resource can more be consumed by doing heap compressions, therefore this time cut-off of virtual machine ensure that and frequently be received even in virtual machine
To memory compression triggering command when, can also ensure the high yield of memory compression.
In order to guarantee safety, in some examples, can also have to enter the process for sending the internal memory triggering command
The step of row Authority Verification, a system process can be set to the security procedure of acquiescence, if sending internal memory triggering command
Process is this system process, then Authority Verification passes through;Otherwise, the result of authority authentication failed is returned.
In some examples, the process of Activity attributes can also be compressed in the lump, press at the time of background process compresses
Contracting mode may be referred to virtual machine in traditional scheme and send memory compression request pair by receiving the interface of the AMS modules
The process that the data in internal memory shared by the process of Activity attributes are compressed.
Can be to the internal memory shared by the process of Activity attributes in some examples, during except platform process upon compression
In data be compressed, can also be called with reference to virtual machine in traditional scheme according to preset rules in the interface of AMS modules
When, virtual machine is compressed to the process of Activity attributes automatically.
Fig. 3 a are examples under an application scenarios, have multiple applications on mobile terminal, the AMS modules of virtual machine 320 carry
For first interface, Activity processes are compressed automatically for virtual machine;The second interface of extension is provided, received for virtual machine outside main
The compression instruction of dynamic triggering carries out background process (such as the process of Services attributes and process of Persistent attributes)
Compression." key acceleration " button is triggered as the triggering thing for actively triggering background process compression using device power-up and user in this example
Part.Fig. 3 b show the part flow being compressed during device power-up to the internal storage data shared by background process.
In the stage 1, trigger memory compression flow:When mobile terminal starts, start specific system process to call AMS modules
Second interface, by second interface to virtual machine send memory compression triggering command;
Stage 2 is proof of identity process:Whether second interface verification called side is the system process set, if it is,
The background process of all Services attributes and Persistent attributes is traveled through in AMS modules, notice is each currently in
The background process of active state, discharged by the first process resource of the process oneself, then sent out by the background process to virtual machine interface
The Asynchronous Request of memory compression is sent, notice virtual machine carries out memory compression, if check results are not the system process of setting,
The triggering command for receiving memory compression is abandoned;
Stage 3 is memory compression processing procedure:After virtual machine receives request, it can attempt to carry out internal memory pressure to the process
Contracting, and record the timestamp of second compression request.
Stage 4 to triggering the handling process of memory compression process again:When user is using during mobile device, lead to
The triggering command that " key acceleration " button triggers memory compression again is crossed, then is again started up specific system process to call second
Interface performs above-mentioned steps.If virtual machine, which this time receives request, is less than the time specified apart from the time that last compression occurs,
Then ignore this second compression (not shown), if not less than the time specified, be compressed again.
It may be noted that when calling second interface progress memory compression, entering for all Activity attributes can also be traveled through
Journey is compressed.In addition, when virtual machine internal calls first interface automatically, the process to Activity attributes can also be triggered
It is compressed.
For this example, contrasted by following test data with the test data compressed without background process, with
The advantage that display background process compression is brought to systematic function.Exemplified by saving as 1G in tested mobile terminal.
Step 1,5 seconds start recording internal storage datas after mobile device 300 is unlocked.This data is as " start internal storage data
1”;
Step 2, on the basis of step 1, internal storage data is recorded after standing 3 minutes.This data is as " start internal storage data
2”;
Step 3,10 minutes start recording internal storage datas after unblock.This data is as " start internal storage data 3 ";Meanwhile this
Data will be used as " internal storage data before a key accelerates ";
Step 4, on the basis of step 2, one key of triggering accelerates button, and internal storage data is recorded after standing 10 seconds.This data is made
For " key accelerate after internal storage data 1 ";
Step 5,10 minutes are stood after unblock, then triggers a key and accelerate button, internal storage data is recorded after standing 10 seconds.This
Data as " key accelerate after internal storage data 2 ";
One key accelerates the effect of optimization to internal memory, mainly may be referred to " internal storage data 2 " and " key acceleration after a key accelerates
Preceding internal storage data ".
By above testing procedure, following test result is obtained:
1st, " display of start internal storage data 1 " in the version start of memory compression by saving as:The internal memory used reduces
8.9M, the internal memory increase 8.4M of idle condition;
2nd, " display of start internal storage data 2 " in the version start of memory compression by saving as:The internal memory used reduces
9.5M, the internal memory increase 8.6M of idle condition;
3rd, " display of start internal storage data 3 " in the version start of memory compression by saving as:The internal memory used deposits reduction
3.9M, the internal memory increase 5.3M of idle condition;
4th, " key accelerate before internal storage data ", " after a key accelerates the display of internal storage data 1 " by memory compression version phase
Than the version without memory compression, a key accelerates to cause:The internal memory used reduces 16.3M, the internal memory increase of idle condition
15.3M;
5th, " key accelerate before internal storage data ", " after a key accelerates internal storage data 2 " show the version used compare without
The version of memory compression is crossed, a key accelerates to cause:Used internal memories reduce 19.6M, Free internal memories increase 18.5M.
It thereby it is assumed that during the normal use of terminal device 300, once the flow of triggering memory compression, Ke Yiduo
Save 2% or so internal memory.
Corresponding with the embodiment of the method for foregoing memory compression, present invention also provides the implementation of the device of memory compression
Example.
The embodiment of the device of the application memory compression can be applied on an electronic device.Device embodiment can be by soft
Part is realized, can also be realized by way of hardware or software and hardware combining.Exemplified by implemented in software, as a logical meaning
On device, be to be read corresponding computer program instructions in nonvolatile memory by the processor of electronic equipment where it
Get what operation in internal memory was formed.For hardware view, as shown in figure 4, being electronics where the device of the application memory compression
A kind of hardware structure diagram of equipment, except the processor shown in Fig. 4, internal memory, network interface and nonvolatile memory it
Outside, memory storage processor-executable instruction, the electronic equipment in embodiment where device is generally according to the electronic equipment
Actual functional capability, other hardware can also be included, this is repeated no more.Processor, which is configured as performing correlation described above, to be moved
Make, for example, in some examples, processor is configured as receiving the triggering command of memory compression, by virtual machine to specifying backstage
The data in internal memory shared by process are compressed;The process of the specified background process including Service attributes and/or
The process of Persistent attributes.
Fig. 5 is refer to, the device 500 of memory compression, can be included:
Interface module 501, for receiving the triggering command of memory compression;
Memory compression module 502, to specifying the data in the internal memory shared by background process to be compressed;Specified backstage is entered
Journey can include the process of Service attributes and/or the process of Persistent attributes.
As an example, the triggering command of memory compression can be sent when meeting active trigger event;Actively trigger
Event can include following at least one:
Control, the background process clearing function that equipment starts, user's triggering is specified are triggered, it is not excluded that have other actively
Trigger condition.
In some examples, device 500 can also include correction verification module 502, for sending the internal memory triggering command
Process carries out Authority Verification, can specifically include:
If sending the system process of the process of the internal memory triggering command for setting, Authority Verification is by and leading to
Know the memory compression module 504;Otherwise, the result of authority authentication failed is returned.
In some examples, judge module 503 can also be included, for touching for this memory compression received according to record
Whether the time to send instructions, the time interval of judging distance last time memory compression are conformed to a predetermined condition, and institute is notified if meeting
The step of memory compression module is performed to specifying the data in the internal memory shared by background process to be compressed is stated, if do not met
Predetermined condition, then ignore the triggering command of the memory compression.
As an example, described device 500 can be located at virtual machine, and interface module 501 can connect outside the virtual machine
Receive the triggering command of memory compression.
Interface module 501 can be the expansion interface of application management service AMS modules.
In addition, memory compression module 504 can be also used for the number in the internal memory shared by the process of Activity attributes
According to being compressed.
Fig. 6 is a kind of part logic diagram of operating system 600, including:
Process manager module 601, for managing multiple processes, the process includes background process;
The interface 602 of Virtual machine, for sending the triggering command of memory compression to virtual machine, the memory compression
Triggering command is used to trigger virtual machine to specifying the data in the internal memory shared by background process to be compressed;The specified backstage
Process includes the process of service Service attributes and/or the process of permanent Persistent attributes.
Operating system 600 can also include the system process of setting, for calling the interface of the Virtual machine to void
Plan machine sends the triggering command of memory compression, is called so as to the interface of Virtual machine when responding active trigger event.
As an example, active trigger event can include following at least one:
Control, the background process clearing function that equipment starts, user's triggering is specified are triggered.
The triggering command of memory compression can be the instruction for the interface for calling the virtual machine to provide or to described
Specified signal that virtual machine is sent etc..
As an example, the interface that virtual machine provides can be the expansion interface of AMS modules.
The function of unit and the implementation process of effect specifically refer to and step are corresponded in the above method in said apparatus
Implementation process, it will not be repeated here.
For device embodiment, because it corresponds essentially to embodiment of the method, so related part is real referring to method
Apply the part explanation of example.Device embodiment described above is only schematical, wherein described be used as separating component
The unit of explanation can be or may not be physically separate, can be as the part that unit is shown or can also
It is not physical location, you can with positioned at a place, or can also be distributed on multiple NEs.Can be according to reality
Need to select some or all of module therein to realize the purpose of application scheme.Those of ordinary skill in the art are not paying
In the case of going out creative work, you can to understand and implement.
The preferred embodiment of the application is the foregoing is only, not limiting the application, all essences in the application
God any modification, equivalent substitution and improvements done etc., should be included within the scope of the application protection with principle.