CN105573842B - The method and device of process recovery processing is carried out in the application - Google Patents

The method and device of process recovery processing is carried out in the application Download PDF

Info

Publication number
CN105573842B
CN105573842B CN201510967725.2A CN201510967725A CN105573842B CN 105573842 B CN105573842 B CN 105573842B CN 201510967725 A CN201510967725 A CN 201510967725A CN 105573842 B CN105573842 B CN 105573842B
Authority
CN
China
Prior art keywords
component
current process
event
recycling
run
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.)
Active
Application number
CN201510967725.2A
Other languages
Chinese (zh)
Other versions
CN105573842A (en
Inventor
宋照春
张炅轩
姚彤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201510967725.2A priority Critical patent/CN105573842B/en
Publication of CN105573842A publication Critical patent/CN105573842A/en
Application granted granted Critical
Publication of CN105573842B publication Critical patent/CN105573842B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Stored Programmes (AREA)

Abstract

The present invention provides a kind of method and devices for carrying out process recovery processing in the application.This method comprises: the process of preset monitored recycles event;When listening to the preset process recycling event, a process reclaimer operation is triggered every a predetermined amount of time;Wherein, the process reclaimer operation includes: the attribute information for obtaining each component run in current process;The attribute information of the attribute information of each component run in the current process component corresponding with process recycling rule is compared, it is determined whether the current process is recycled.Technical solution provided by the invention can be realized the purpose being recycled in time to process, solve the timely recycling that can not achieve process in the prior art, cause before recycling process still can long-term committed memory resource the problem of.

Description

The method and device of process recovery processing is carried out in the application
Technical field
The present invention relates to field of computer technology, carry out process recovery processing in the application more particularly to a kind of Method and device.
Background technique
In terminal device, due to cost considerations, Installed System Memory is very limited, when system is run under biggish load When, the case where being easy to appear low memory.
Currently, in Android (Android) operating system, system can memory be reduced to default threshold value when It waits, according to the liveness collection process of process.Although this alleviates the case where low memory to a certain extent, existing According to the method for the liveness collection process of process, the process that sometimes will cause operating system application is recovered, and leads to end The defect that end equipment can not normally be run.In addition, system is when memory is reduced to the threshold value of default, it just can basis The liveness collection process of process can not achieve the timely recycling of process, and process still can long-term committed memory before recycling Resource.
Summary of the invention
The invention proposes a kind of method and devices of process recovery processing that carries out in the application to overcome above-mentioned ask Inscribe or at least be partially solved the above problem.
According to an aspect of the invention, there is provided a kind of method for carrying out process recovery processing in the application, packet It includes:
The process of preset monitored recycles event;
When listening to the preset process recycling event, a process recycling behaviour is triggered every a predetermined amount of time Make;
Wherein, the process reclaimer operation includes:
Obtain the attribute information of each component run in current process;
By the attribute of the attribute information of each component run in the current process component corresponding with process recycling rule Information is compared, it is determined whether is recycled to the current process;
Wherein, the method also includes:
Count area is arranged to each process in application program, for the group for being resumed and/or being suspended in the process Part is counted;
When receiving component recovery event, count value is increased to the count area of process where the component being resumed;
When receiving component suspending event, count value is reduced to the count area of process where the component being suspended.
Optionally, the preset process recycling event includes at least one following:
Application program launching event;
System component starts event;
System component exits event;
Component destruction event;
Anti- registration procedure recycles interface management class event.
Optionally, the method also includes: the component that cannot be recovered is registered in specified class;
By the attribute of the attribute information of each component run in the current process component corresponding with process recycling rule Information is compared, it is determined whether is recycled to the current process, comprising:
Judge whether each component run in the current process is registered in the specified class;
If in each component run in the current process, there are at least one component registers into the specified class, really Determine to the current process without recovery processing;
If there is no component registers into the specified class in each component run in the current process, it is determined that institute Current process is stated to be recycled.
Optionally, judge whether each component run in the current process is registered in the specified class, comprising:
The judgment method for calling the specified class searches each component run in the current process by the judgment method Whether it is registered in the specified class;
Receive the lookup result that the judgment method returns;
Determined whether to recycle the current process according to the lookup result.
Optionally, by the attribute information of each component run in the current process component corresponding with process recycling rule Attribute information be compared, it is determined whether the current process is recycled, comprising:
Judge in each component run in the current process with the presence or absence of the component being resumed;
If so, determining to the current process without recovery processing;
If not, it is determined that the current process is recycled.
Optionally, judge in each component run in the current process with the presence or absence of the component being resumed, comprising:
Read the count area of the current process;
Judge whether the count value of the count area is greater than specified threshold;
If so, determining the component for existing in each component run in the current process and being resumed;
If not, it is determined that there is no the components being resumed in each component run in the current process.
Optionally, by the attribute information of each component run in the current process component corresponding with process recycling rule Attribute information be compared, it is determined whether the current process is recycled, comprising:
Judge whether the current process is null process or background process;
If so, determination is recycled the current process.
According to another aspect of the present invention, a kind of dress for carrying out process recovery processing in the application is additionally provided It sets, comprising:
Module is monitored, preset process recycling event is adapted for listening for;
Recycling module, suitable for triggering one every a predetermined amount of time when listening to the preset process recycling event Secondary process reclaimer operation;
Wherein, the process reclaimer operation includes:
Obtain the attribute information of each component run in current process;
By the attribute of the attribute information of each component run in the current process component corresponding with process recycling rule Information is compared, it is determined whether is recycled to the current process;
Wherein, described device further include:
Counting module, suitable for in application program each process be arranged count area, for be resumed in the process and/ Or the component being suspended is counted;When receiving component recovery event, to the counting word of process where the component being resumed Duan Zengjia count value;When receiving component suspending event, the count area of process where the component being suspended is reduced and is counted Value.
Optionally, the preset process recycling event includes at least one following:
Application program launching event;
System component starts event;
System component exits event;
Component destruction event;
Anti- registration procedure recycles interface management class event.
Optionally, above-mentioned apparatus further include:
Registration module, suitable for registering the component that cannot be recovered in specified class;
The recycling module is further adapted for: judging whether each component run in the current process is registered to the specified class In;If in each component run in the current process, there are at least one component registers into the specified class, it is determined that right The current process is without recovery processing;If there is no component registers described in each component run in the current process In specified class, it is determined that the current carry out process recovery processing.
Optionally, the recycling module is further adapted for:
The judgment method for calling the specified class searches each component run in the current process by the judgment method Whether it is registered in the specified class;
Receive the lookup result that the judgment method returns;
Determined whether to recycle the current process according to the lookup result.
Optionally, the recycling module is further adapted for:
Judge in each component run in the current process with the presence or absence of the component being resumed;
If so, determining to the current process without recovery processing;
If not, it is determined that the current process is recycled.
Optionally, the recycling module is further adapted for:
Read the count area of the current process;
Judge whether the count value of the count area is greater than specified threshold;
If so, determining the component for existing in each component run in the current process and being resumed;
If not, it is determined that there is no the components being resumed in each component run in the current process.
Optionally, the recycling module is further adapted for:
Judge whether the current process is null process or background process;
If so, determination is recycled the current process.
Technical solution provided by the invention realizes the recovery processing to the process of application program, is provided with first preset Process recycles event, and carries out active sniffing to preset process recycling event, when listening to preset process recycling event, A process reclaimer operation is triggered every a predetermined amount of time, i.e., triggers process reclaimer operation in a manner of poll, is obtained current The attribute information of each component run in process, and then the attribute information of each component run in current process and process are recycled The attribute information of the corresponding component of rule is compared, it is determined whether is recycled to current process.It is provided by the invention Technical solution realizes the purpose being recycled in time to process, solves and can not achieve the timely of process in the prior art Recycling, cause before recycling process still can long-term committed memory resource the problem of.Also, the embodiment of the present invention is will be current The attribute information of the attribute information of each component run in process component corresponding with process recycling rule is compared, and determination is It is no that current process is recycled, rather than only according to the liveness collection process of process, so that operating system The process of application will not be recovered, and can guarantee the normal operation of terminal device.
The above description is only an overview of the technical scheme of the present invention, in order to better understand the technical means of the present invention, And it can be implemented in accordance with the contents of the specification, and in order to allow above and other objects of the present invention, feature and advantage can It is clearer and more comprehensible, the followings are specific embodiments of the present invention.
According to the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will be brighter The above and other objects, advantages and features of the present invention.
Detailed description of the invention
By reading the following detailed description of the preferred embodiment, various other advantages and benefits are common for this field Technical staff will become clear.The drawings are only for the purpose of illustrating a preferred embodiment, and is not considered as to the present invention Limitation.And throughout the drawings, the same reference numbers will be used to refer to the same parts.In the accompanying drawings:
Fig. 1 shows the stream of the method according to an embodiment of the invention for carrying out process recovery processing in the application Cheng Tu;
Fig. 2 show the state transition diagram of Activity;
Fig. 3 shows the method according to an embodiment of the invention for determining whether to be recycled current process Flow chart;
Fig. 4 shows the method in accordance with another embodiment of the present invention for determining whether to be recycled current process Flow chart;
Fig. 5 shows the method for determining whether to be recycled current process of another embodiment according to the present invention Flow chart;
Fig. 6 shows the method in accordance with another embodiment of the present invention for carrying out process recovery processing in the application Flow chart;
Fig. 7 shows the knot of the device according to an embodiment of the invention for carrying out process recovery processing in the application Structure schematic diagram;And
Fig. 8 shows the device in accordance with another embodiment of the present invention for carrying out process recovery processing in the application Structural schematic diagram.
Specific embodiment
Exemplary embodiments of the present disclosure are described in more detail below with reference to accompanying drawings.Although showing the disclosure in attached drawing Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here It is limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosure It is fully disclosed to those skilled in the art.It should be noted that under the premise of not conflicting, the embodiment of the present invention and implementation Technical characteristic in example can be combined with each other.
Fig. 1 shows the stream of the method according to an embodiment of the invention for carrying out process recovery processing in the application Cheng Tu.As shown in Figure 1, this method comprises:
The process of step S102, preset monitored recycle event;
Step S104 triggers a process every a predetermined amount of time and returns when listening to preset process recycling event It brings drill to an end work;
Wherein, process reclaimer operation includes:
Obtain the attribute information of each component run in current process;
By the attribute information of the attribute information of each component run in current process component corresponding with process recycling rule It is compared, it is determined whether current process is recycled.
Method provided in this embodiment realizes the recovery processing to the process of application program, first be provided with it is preset into Cheng Huishou event, and active sniffing is carried out to preset process recycling event, when listening to preset process recycling event, often A process reclaimer operation is triggered every a predetermined amount of time, i.e., triggers process reclaimer operation in a manner of poll, is obtained when advance The attribute information of each component run in journey, and then the attribute information of each component run in current process and process recycling are advised Then the attribute information of corresponding component is compared, it is determined whether is recycled to current process.The present embodiment realizes It to the purpose that process is recycled in time, solves in the prior art the timely recycling for the process that can not achieve, causes returning Before receipts process still can long-term committed memory resource the problem of.Also, the present embodiment is each group that will be run in current process The attribute information of the attribute information of part component corresponding with process recycling rule is compared, it is determined whether carries out to current process Recovery processing, rather than only according to the liveness collection process of process, so that the process of operating system application will not be by It recycles, can guarantee the normal operation of terminal device.
Method provided in this embodiment is primarily adapted for use in Android (Android) system.Android system is a kind of in not The open source system of disconnected evolution state, there are multiple and different versions, and different version android systems is in and deposits State.Method provided in this embodiment is suitable for the version of 2.2 or more Android, and applicable range is big.
In order to be compatible with the version of 2.2 or more Android, can all be had using the version of 2.2 or more Android OnUpdate method trigger above-mentioned process reclaimer operation, and start to be polled, determine whether to recycle some process.
In general, the four big basic modules that android system all has are Activity (activity), Service respectively (service), ContentProvider (content provider), BroadcastReceiver (radio receiver), separately below to this Four components are introduced.
Firstly, Activity is the concept of a user interface, Activity usually indicates a screen in application program Curtain.It generally comprise one or more View (View is user interface element, be constitute user interface basic building block, View can be a button, label, the text field or various other user interface elements), however, you can also not include View. The meaning of this word of Activity and it itself is much like: helping user to complete a certain operation, this operation may be to look at number According to, creation data or editor data.Multiple Activity are owned by most of Android application program.
Service in Android is similar to the service in Windows (window) or other platforms, they are all possible The background process of long-play.Android defines two kinds of Service: local Service and long-range Service. Local Service is the component that can only be accessed by the application program for carrying the Service.And long-range Service is in equipment The Service of the other applications remote access of upper operation.Email application is used for the component of poll new mail, just It is a Service example.If the other applications that this Service cannot be run in equipment use, it It is exactly local Service.If there is multiple application programs use the Service, then it is exactly long-range Service.
Android is that application program defines a kind of standard mechanism and comes shared data (such as contacts list), without public affairs Open bottom storage, structure and realization.By ContentProvider application program can be allowed to use and come from it with public data The data of his application program.
Android application program can be used BroadcastReceiver and be filtered to external event, only to interested External event (e.g., when phone incoming call or when data network is available) received and responded. BroadcastReceiver does not have user interface, however, they can star an Activity or Serice to respond them The information received, or user is notified with NotificationManager (notice management class).Notice can use many kinds side Formula attracts the attention of user, such as flashes back light, vibration, plays sound, in general can put one on status bar Lasting icon, user can open it and obtain message.
Four big basic modules, which require registration, to be used, each Activity, Service, ContentProvider It needs to be configured in AndroidManifest file.It is not stated in AndroidManifest file Activity, Service and ContentProvider will not be system finding, thus it is also just unavailable, and The registration point static registration (being configured in AndroidManifest file) of BroadcastReceiver and pass through code Dynamic creation is simultaneously registered to system in a manner of calling Context.registerReceiver ().It should be noted that The BroadcastReceiver configured in AndroidManifest file can be constantly in active with the starting of system State, even if program not running, as long as receiving interested broadcast will trigger.
Operation Android application program and its process of component can undergo various life cycle events (Android application journey The life cycle of sequence is to be managed by Android frame, rather than directly controlled by application program), Android is provided back It adjusts, by realizing that they can handle state change.
By taking the various life cycle callbacks of an Activity as an example, the life cycle callback method of Activity is as follows: onCreate()、onStart()、onRestart()、onResume()、onPause()、onStop()、onDestroy ().It is illustrated in figure 2 the state transition diagram of Activity.
System can start and stop Activity according to other events of generation.Just when creation Activity, Android calls onCreate () method, then can always call onStart (), but calls not total before onStart () It is to call onCreate (), because can stop in application program and (call calling onStart () after onStop ()).Work as tune When with onStart (), Activity is invisible to user, but later will be visible.After calling onStart (), Activity is in foreground and calls onResume () when can access for user, and at this moment, user will interact with Activity.
When user determines to go to another Activity, system will call onPause () method of current Activity, Then onResume () or onStop () can be capable of calling.For example, will be called if current Activity is recalled to foreground by user onResume().If Activity becomes invisible to user, onStop () will be called.Before if Activity has been recalled to Platform, then after calling onStop () onRestart () will be called.If Activity is located in Activity stack, but It is invisible to user, and system decision terminates the Activity, then onDestroy () will be called.
It triggers process reclaimer operation by onUpdate method and is polled and need suitable opportunity, that is, need that conjunction is arranged Suitable preset process recycles event, and the present embodiment provides several preferred preset processes recycling events, including it is following at least One of: application program launching event, system component starting event, system component exit event, component destruction event, it is counter register into Cheng Huishou interface management class event.
Application program launching event, system component starting event, system component exit event, component destruction event actually All reflected that the operating status of current system is changed, then at this time with regard to need judge certain processes whether be can With recycling, to save system resource.In order to trigger the process reclaimer operation of poll as far as possible, counter will be registered in the present embodiment Process recycles interface management class event and also recycles event as a kind of optional preset process.
The attribute information for each component mentioned in the above method is primarily referred to as the current state information of each component, below into Row detailed description.
Fig. 3 shows the method according to an embodiment of the invention for determining whether to be recycled current process Flow chart.As shown in figure 3, this approach includes the following steps S302 to step S306.
Step S302 judges with the presence or absence of the component being resumed in each component run in current process, if so, continuing Execute step S304;Otherwise, step S306 is continued to execute.
In this step, the component being resumed is the component for being in front stage operation, can also judge current process indirectly With the presence or absence of the component for being in front stage operation in each component of interior operation.
Step S304 is determined to current process without recovery processing.
In this step, the component being resumed is in the state of front stage operation, then not to the process where the component into Row recycling.
Step S306, determination are recycled current process.
It in this step, can be to when advance if there is no the components being resumed in each component run in current process Cheng Jinhang recovery processing can also further be judged using the subsequent method referred to.
In an embodiment of the present invention, count area each process in application program can be arranged (as worked as application program In process initiation when, the count area of the process is set), for the group for being resumed component in the process and/or being suspended Part is counted.For example, when receiving component recovery event (i.e. calling onResume () callback method), to what is be resumed The count area of process increases count value where component;(onPause () readjustment side is called when receiving component suspending event Method) when, count value is reduced to the count area of process where the component being suspended.
Counting by taking Activity component as an example, when receiving Activity component recovery event, to process where it Field mResumedActivityCount increases count value, such as 1 or 2;When receiving Activity component suspending event, Count value, such as 1 or 2 are reduced to the count area mResumedActivityCount of process where it, the present invention does not do this Limitation.
Based on to the count area of each process setting in application program, the embodiment of the invention provides a kind of implementations above The optinal plan of above step S302 can read the count area of current process in this scenario, and then judge count area Count value whether be greater than specified threshold, there is the component that is resumed in each component run in current process if so, determining; If not, it is determined that there is no the components being resumed in each component run in current process.
The embodiment of the invention also provides the another kind scheme that selectively determines whether to be recycled current process, Fig. 4 shows the process of the method in accordance with another embodiment of the present invention for determining whether to be recycled current process Figure.As shown in figure 3, this method at least includes the following steps S302 to step S306.
Step S402 judges whether current process is null process or background process, if so, continuing to execute step S404; Otherwise, step S406 is continued to execute.
In this step, the identifier of current process can be first obtained, searches the identifier of current process in systems RunningAppProcessInfo (information for the process that the interface encapsulation is currently running), calls its importance field. If the field value is IMPORTANCE_EMPTY, then it represents that current process is null process;If the field value is IMPORTANCE_BACKGROUND, then it represents that current process is background process.
Step S404, determination are recycled current process.
Step S406 is determined to current process without recovery processing.
In this step, if current process is not null process or background process, can to current process without recycling at Reason, can also be using method shown in Fig. 3 or the subsequent method referred to further judge above.
In an embodiment of the present invention, the component that cannot be recovered can be registered in specified class.In an application program It is interior, usually possess one or more Activity, Service, ContentProvider, BroadcastReceiver, is answering During being run with program, for the component that cannot be recovered, it can be registered in specified class.For example, self defined class IKillable, it is impossible to which for the component register being recovered into the self defined class, it has a method isKillable (), is sentencing When whether disconnected component needs to be recovered, this method isKillable () can be called, by this method isKillable () lookup group Whether part is registered in the self defined class, if this method returns to false, then it represents that component register is into the self defined class, the group Part cannot be recovered.If this method return true, then it represents that component is not registered in the self defined class, can recycle the component or Person continues through other methods and judges whether to recycle the component.
Based on specified class above, the embodiment of the invention also provides another kind selectively determine whether to current process into The scheme of row recycling, Fig. 5 show another embodiment according to the present invention and determine whether to be recycled current process Method flow chart.As shown in figure 5, this method at least includes the following steps S502 to step S506.
Step S502, judges whether each component run in current process is registered in specified class, if fortune in current process There are at least one component registers into specified class in capable each component, then continues to execute step S504;If fortune in current process There is no component registers into specified class in capable each component, then continues to execute step S506.
In this step, the judgment method that specified class can be called, it is each by being run in judgment method lookup current process Whether component is registered in specified class, and then receives the lookup result that judgment method returns, and is determined whether back according to lookup result Receive current process.
Step S504 is determined to current process without recovery processing.
Step S506, determination are recycled current process.
It in this step, can be right if there is no component registers into specified class in each component run in current process Current process is recycled, and can not also be recycled using conservative scheme, can be using Fig. 3's or Fig. 4 above Method further judges.
In practical applications, can be determined whether using Fig. 3, Fig. 4 or Fig. 5 method shown in any one to current process into Row recovery processing can also determine whether to be recycled current process, example in conjunction with Fig. 3, Fig. 4 and method shown in fig. 5 Such as, there is no the components being resumed in each component run in current process, and in each component run in current process not When there are component registers into specified class, determination is recycled current process.
When current process is multiple processes, can be judged respectively for each process, with determine whether to its into Row recovery processing, details are not described herein again.
The method for carrying out process recovery processing in the application of the invention is discussed in detail with a specific embodiment below Realization process.
In this embodiment, the customized class being related to is as follows:
1)IKillable
One interface.It has a method, isKillable ()
isKillable
Search whether the components such as Activity or Service are registered in IKillable, if this method returns to false, Component register is indicated into IKillable, which cannot be recovered.If this method returns to true, then it represents that component is unregistered Into IKillable, the component can be recycled or continue through other methods judge whether to recycle the component.
2)KillableMonitor
For managing the class of all IKillable interfaces, i.e., above-mentioned recovery processing interface management class, including it is typical List<IKillable>。
registerKillable(IKillable)
It is added IKillable interface object (mKillableSet) into List.
unregisterKillable(IKillable)
It deletes IKillable interface object (mKillableSet) into List.It is anti-every time in order to trigger poll as far as possible A MESSAGE_TRY_KILL_PROCESS (a kind of process reclaimer operation) can be all initiated when registration immediately, can be moved back in time in this way UI process out.
isAllKillable()
It judges whether there is IKillable.isKillable and returns to false.As long as there is any one, this cannot be recycled by meaning that Process.
3)KillerHandler
It is inherited from Handler, for handling event: MESSAGE_TRY_KILL_PROCESS
MESSAGE_TRY_KILL_PROCESS
This method is used to call tryKillProcess.Since Handler uses the mode of poll, every between setting time It walks every (such as 1 minute) once, until the event is terminated.
4)ProcessKiller
Core classes, for dispatching the life and death of entire process.Including method:
onUpdate
MESSAGE_TRY_KILL_PROCESS event is only initiated, automatically into poll once initiating.
However, in triggering scene this method need to be called in following scenario:
Activity.onDestroy (each)
When application program launching
Other possible situations
init()
Registration onUpdate method is simultaneously ready.
addKillableService(ComponentName)
The Service class of IKillable interface is had been realized in addition current application to mKillableService (oneself Definition) list.All Service for being not carried out IKillable interface are saved if be provided with, as long as sending out when exiting The Service of the existing IKillable being not carried out is run in current process, then current process would not be exited.
For the Service class for having been realized in IKillable interface added here, it can be found in current process Also at runtime, it can judge whether it can exit by force by isKillable ().It, should when it returns to true Service will not prevent exiting for process again running in current process.
tryKillProcess
Core methed is called in KillerHandler, called primary according to setting time interval, this method Judge that process sees above Fig. 2, Fig. 3 and Fig. 4, details are not described herein again.
Fig. 6 shows the method in accordance with another embodiment of the present invention for carrying out process recovery processing in the application Flow chart.As shown in fig. 6, this method at least includes the following steps S602 to step S614.
The process of step S602, preset monitored recycle event.
In this step, preset process recycling event can be application program launching event, system component starts event, System component exits event, component destruction event, anti-registration procedure recycling interface management class event etc..
In the present embodiment, to each process setting count area in application program (as when the process initiation in application program When, the count area of the process is set), for being counted to the component for being resumed component in the process and/or being suspended.Example Such as, when receiving component recovery event, count value is increased to the count area of process where the component being resumed;When receiving When component suspending event, count value is reduced to the count area of process where the component being suspended.
Step S604 is obtained once every a predetermined amount of time when advance when listening to preset process recycling event The attribute information of each component run in journey.
Step S606 judges with the presence or absence of the component being resumed in each component run in current process, if so, continuing Execute step S608;Otherwise, step S610 is continued to execute.
Step S608 is determined to current process without recovery processing.
In this step, the component being resumed is in the state of front stage operation, then not to the process where the component into Row recycling.
Step S610, judges whether each component run in current process is registered in specified class, if fortune in current process There are at least one component registers into specified class in capable each component, then continues to execute step S608;If fortune in current process There is no component registers into specified class in capable each component, then continues to execute step S612.
Step S612 judges whether current process is null process or background process, if so, continuing to execute step S614; Otherwise, step S608 is continued to execute.
Step S614, determination are recycled current process.
The embodiment of the present invention is that the attribute information for each component that will be run in current process is corresponding with process recycling rule The attribute information of component is compared, it is determined whether current process is recycled, rather than only according to the work of process Jerk collection process can guarantee the normal fortune of terminal device so that the process of operating system application will not be recovered Row.
Based on the method for carrying out process recovery processing in the application that each embodiment above provides, it is based on same hair Bright design, the embodiment of the invention also provides a kind of devices for carrying out process recovery processing in the application.
Fig. 7 shows the knot of the device according to an embodiment of the invention for carrying out process recovery processing in the application Structure schematic diagram.As shown in fig. 7, the device 700 at least may include monitoring module 710 and recycling module 720, wherein
Module 710 is monitored, preset process recycling event is adapted for listening for;
Recycling module 720 is coupled with module 710 is monitored, suitable for when listening to preset process recycling event, every One predetermined amount of time triggers a process reclaimer operation;
Wherein, process reclaimer operation includes:
Obtain the attribute information of each component run in current process;
By the attribute information of the attribute information of each component run in current process component corresponding with process recycling rule It is compared, it is determined whether current process is recycled.
In an embodiment of the present invention, preset process recycling event includes at least one following:
Application program launching event;
System component starts event;
System component exits event;
Component destruction event;
Anti- registration procedure recycles interface management class event.
In an embodiment of the present invention, as shown in figure 8, the device that Fig. 7 is shown can also include:
Registration module 730 is coupled with recycling module 720, suitable for registering the component that cannot be recovered in specified class;
Recycling module 720 is further adapted for: judging whether each component run in current process is registered in specified class;If current There are at least one component registers into specified class in each component run in process, it is determined that current process without recycling Processing;If there is no component registers into specified class in each component run in current process, it is determined that carried out to current process Recovery processing.
In an embodiment of the present invention, recycling module 720 is further adapted for:
The judgment method for calling specified class searches whether each component run in current process is registered to finger by judgment method Determine in class;
Receive the lookup result that judgment method returns;
Determined whether to recycle current process according to lookup result.
In an embodiment of the present invention, recycling module 720 is further adapted for:
Judge in each component run in current process with the presence or absence of the component being resumed;
If so, determining to current process without recovery processing;
If not, it is determined that current process is recycled.
In an embodiment of the present invention, as shown in figure 8, the device that Fig. 7 is shown can also include:
Counting module 740 is coupled with recycling module 720, suitable for count area is arranged to each process in application program, For being counted to the component for being resumed and/or being suspended in the process;When receiving component recovery event, to being resumed Component where process count area increase count value;When receiving component suspending event, to where the component being suspended The count area of process reduces count value.
In an embodiment of the present invention, recycling module 720 is further adapted for:
Read the count area of current process;
Judge whether the count value of count area is greater than specified threshold;
If so, determining the component for existing in each component run in current process and being resumed;
If not, it is determined that there is no the components being resumed in each component run in current process.
In an embodiment of the present invention, recycling module 720 is further adapted for:
Judge whether current process is null process or background process;
If so, determination is recycled current process.
Technical solution provided by the invention realizes the recovery processing to the process of application program, is provided with first preset Process recycles event, and carries out active sniffing to preset process recycling event, when listening to preset process recycling event, A process reclaimer operation is triggered every a predetermined amount of time, i.e., triggers process reclaimer operation in a manner of poll, is obtained current The attribute information of each component run in process, and then the attribute information of each component run in current process and process are recycled The attribute information of the corresponding component of rule is compared, it is determined whether is recycled to current process.It is provided by the invention Technical solution realizes the purpose being recycled in time to process, solves and can not achieve the timely of process in the prior art Recycling, cause before recycling process still can long-term committed memory resource the problem of.Also, the embodiment of the present invention is will be current The attribute information of the attribute information of each component run in process component corresponding with process recycling rule is compared, and determination is It is no that current process is recycled, rather than only according to the liveness collection process of process, so that operating system The process of application will not be recovered, and can guarantee the normal operation of terminal device.
In the instructions provided here, numerous specific details are set forth.It is to be appreciated, however, that implementation of the invention Example can be practiced without these specific details.In some instances, well known method, structure is not been shown in detail And technology, so as not to obscure the understanding of this specification.
Similarly, it should be understood that in order to simplify the disclosure and help to understand one or more of the various inventive aspects, Above in the description of exemplary embodiment of the present invention, each feature of the invention is grouped together into single implementation sometimes In example, figure or descriptions thereof.However, the disclosed method should not be interpreted as reflecting the following intention: i.e. required to protect Shield the present invention claims features more more than feature expressly recited in each claim.More precisely, as following Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore, Thus the claims for following specific embodiment are expressly incorporated in the specific embodiment, wherein each claim itself All as a separate embodiment of the present invention.
Those skilled in the art will understand that can be carried out adaptively to the module in the equipment in embodiment Change and they are arranged in one or more devices different from this embodiment.It can be the module or list in embodiment Member or component are combined into a module or unit or component, and furthermore they can be divided into multiple submodule or subelement or Sub-component.Other than such feature and/or at least some of process or unit exclude each other, it can use any Combination is to all features disclosed in this specification (including adjoint claim, abstract and attached drawing) and so disclosed All process or units of what method or apparatus are combined.Unless expressly stated otherwise, this specification is (including adjoint power Benefit require, abstract and attached drawing) disclosed in each feature can carry out generation with an alternative feature that provides the same, equivalent, or similar purpose It replaces.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodiments In included certain features rather than other feature, but the combination of the feature of different embodiments mean it is of the invention Within the scope of and form different embodiments.For example, in detail in the claims, embodiment claimed it is one of any Can in any combination mode come using.
Various component embodiments of the invention can be implemented in hardware, or to run on one or more processors Software module realize, or be implemented in a combination thereof.It will be understood by those of skill in the art that can be used in practice Microprocessor or digital signal processor (DSP) realize that the process according to an embodiment of the present invention that carries out in the application is returned Receive some or all functions of some or all components in the device of processing.The present invention is also implemented as executing Some or all device or device programs of method as described herein are (for example, computer program and computer journey Sequence product).It is such to realize that program of the invention can store on a computer-readable medium, either can have one or The form of multiple signals.Such signal can be downloaded from an internet website to obtain, be perhaps provided on the carrier signal or It is provided in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and ability Field technique personnel can be designed alternative embodiment without departing from the scope of the appended claims.In the claims, Any reference symbol between parentheses should not be configured to limitations on claims.Word "comprising" does not exclude the presence of not Element or step listed in the claims.Word "a" or "an" located in front of the element does not exclude the presence of multiple such Element.The present invention can be by means of including the hardware of several different elements and being come by means of properly programmed computer real It is existing.In the unit claims listing several devices, several in these devices can be through the same hardware branch To embody.The use of word first, second, and third does not indicate any sequence.These words can be explained and be run after fame Claim.
So far, although those skilled in the art will appreciate that present invention has been shown and described in detail herein multiple shows Example property embodiment still without departing from the spirit and scope of the present invention, still can according to the present disclosure directly Determine or deduce out many other variations or modifications consistent with the principles of the invention.Therefore, the scope of the present invention is understood that and recognizes It is set to and covers all such other variations or modifications.

Claims (14)

1. a kind of method for carrying out process recovery processing in the application, comprising:
The process of preset monitored recycles event;
When listening to the preset process recycling event, a process reclaimer operation is triggered every a predetermined amount of time;
Wherein, the process reclaimer operation includes:
Obtain the attribute information of each component run in current process;
By the attribute information of the attribute information of each component run in the current process component corresponding with process recycling rule It is compared, it is determined whether the current process is recycled;
Wherein, the method also includes:
To in application program each process be arranged count area, for the component for being resumed and/or being suspended in the process into Row counts;
When receiving component recovery event, count value is increased to the count area of process where the component being resumed;
When receiving component suspending event, count value is reduced to the count area of process where the component being suspended.
2. according to the method described in claim 1, wherein, the preset process recycling event includes at least one following:
Application program launching event;
System component starts event;
System component exits event;
Component destruction event;
Anti- registration procedure recycles interface management class event.
3. method according to claim 1 or 2, wherein
The method also includes: the component that registration cannot be recovered in specified class;
By the attribute information of the attribute information of each component run in the current process component corresponding with process recycling rule It is compared, it is determined whether the current process is recycled, comprising:
Judge whether each component run in the current process is registered in the specified class;
If in each component run in the current process, there are at least one component registers into the specified class, it is determined that right The current process is without recovery processing;
If there is no component registers into the specified class in each component run in the current process, it is determined that work as to described Preceding process is recycled.
4. according to the method described in claim 3, wherein, judging whether each component run in the current process is registered to institute It states in specified class, comprising:
Whether the judgment method for calling the specified class searches each component run in the current process by the judgment method It is registered in the specified class;
Receive the lookup result that the judgment method returns;
Determined whether to recycle the current process according to the lookup result.
5. method according to claim 1 or 2, wherein by the attribute information of each component run in the current process The attribute information of component corresponding with process recycling rule is compared, it is determined whether carries out at recycling to the current process Reason, comprising:
Judge in each component run in the current process with the presence or absence of the component being resumed;
If so, determining to the current process without recovery processing;
If not, it is determined that the current process is recycled.
6. according to the method described in claim 5, wherein, judging in each component run in the current process with the presence or absence of quilt The component of recovery, comprising:
Read the count area of the current process;
Judge whether the count value of the count area is greater than specified threshold;
If so, determining the component for existing in each component run in the current process and being resumed;
If not, it is determined that there is no the components being resumed in each component run in the current process.
7. method according to claim 1 or 2, wherein by the attribute information of each component run in the current process The attribute information of component corresponding with process recycling rule is compared, it is determined whether carries out at recycling to the current process Reason, comprising:
Judge whether the current process is null process or background process;
If so, determination is recycled the current process.
8. a kind of device for carrying out process recovery processing in the application, comprising:
Module is monitored, preset process recycling event is adapted for listening for;
Recycling module, suitable for when listening to the preset process recycling event, every predetermined amount of time triggering once into Journey reclaimer operation;
Wherein, the process reclaimer operation includes:
Obtain the attribute information of each component run in current process;
By the attribute information of the attribute information of each component run in the current process component corresponding with process recycling rule It is compared, it is determined whether the current process is recycled;
Wherein, described device further include:
Counting module, suitable for in application program each process be arranged count area, for be resumed in the process and/or by The component of pause is counted;When receiving component recovery event, the count area of process where the component being resumed is increased Add count value;When receiving component suspending event, count value is reduced to the count area of process where the component being suspended.
9. device according to claim 8, wherein the preset process recycling event includes at least one following:
Application program launching event;
System component starts event;
System component exits event;
Component destruction event;
Anti- registration procedure recycles interface management class event.
10. device according to claim 8 or claim 9, wherein further include:
Registration module, suitable for registering the component that cannot be recovered in specified class;
The recycling module is further adapted for: judging whether each component run in the current process is registered in the specified class; If in each component run in the current process, there are at least one component registers into the specified class, it is determined that described Current process is without recovery processing;It is specified if there is no component registers in each component run in the current process to described In class, it is determined that be recycled to the current process.
11. device according to claim 10, wherein the recycling module is further adapted for:
Whether the judgment method for calling the specified class searches each component run in the current process by the judgment method It is registered in the specified class;
Receive the lookup result that the judgment method returns;
Determined whether to recycle the current process according to the lookup result.
12. device according to claim 8 or claim 9, wherein the recycling module is further adapted for:
Judge in each component run in the current process with the presence or absence of the component being resumed;
If so, determining to the current process without recovery processing;
If not, it is determined that the current process is recycled.
13. device according to claim 12, wherein the recycling module is further adapted for:
Read the count area of the current process;
Judge whether the count value of the count area is greater than specified threshold;
If so, determining the component for existing in each component run in the current process and being resumed;
If not, it is determined that there is no the components being resumed in each component run in the current process.
14. according to the described in any item devices of claim 8 or 9, wherein the recycling module is further adapted for: judging described current Whether process is null process or background process;
If so, determination is recycled the current process.
CN201510967725.2A 2015-12-21 2015-12-21 The method and device of process recovery processing is carried out in the application Active CN105573842B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510967725.2A CN105573842B (en) 2015-12-21 2015-12-21 The method and device of process recovery processing is carried out in the application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510967725.2A CN105573842B (en) 2015-12-21 2015-12-21 The method and device of process recovery processing is carried out in the application

Publications (2)

Publication Number Publication Date
CN105573842A CN105573842A (en) 2016-05-11
CN105573842B true CN105573842B (en) 2018-12-14

Family

ID=55884012

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510967725.2A Active CN105573842B (en) 2015-12-21 2015-12-21 The method and device of process recovery processing is carried out in the application

Country Status (1)

Country Link
CN (1) CN105573842B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106325851B (en) * 2016-08-10 2020-05-26 复旦大学 Interactive remote collaboration method for Android application
CN108134766B (en) * 2016-12-01 2020-12-18 阿里巴巴集团控股有限公司 Service publishing method, device, system, server and client
CN109254850A (en) * 2018-09-30 2019-01-22 深圳市万普拉斯科技有限公司 memory resource management method and system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103544063A (en) * 2013-09-30 2014-01-29 三星电子(中国)研发中心 Method and device for removing processes applied to Android platform
CN103677978A (en) * 2013-12-30 2014-03-26 Tcl集团股份有限公司 Method and electronic device for protecting processes

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8161544B2 (en) * 2006-07-19 2012-04-17 Microsoft Corporation Trusted communications with child processes

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103544063A (en) * 2013-09-30 2014-01-29 三星电子(中国)研发中心 Method and device for removing processes applied to Android platform
CN103677978A (en) * 2013-12-30 2014-03-26 Tcl集团股份有限公司 Method and electronic device for protecting processes

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Android进程线程管理机制与组件生命周期解析;heyetina;《https://blog.csdn.net/heyetina/article/details/8477434》;20130107;第1-2页 *
深入Android【五】——任务和进程;潜龙勿用;《http://blog.sina.com.cn/s/blog_495c8c720100uxiw.html》;20111012;第1-3页 *

Also Published As

Publication number Publication date
CN105573842A (en) 2016-05-11

Similar Documents

Publication Publication Date Title
CN106569585B (en) A kind of method and terminal managing program process
WO2015176448A1 (en) Method and apparatus for intelligent screen splitting of terminal
CN105094630B (en) The prompt information processing method and device of application program PUSH message
CN109152061B (en) Channel allocation method, device, server and storage medium
CN105573842B (en) The method and device of process recovery processing is carried out in the application
WO2014101584A1 (en) Method and system for notification between mobile terminals during communication
US10691390B2 (en) Method and device for video rendering
CN106296135A (en) Event-prompting method, device and terminal
CN105095749B (en) The adapting method and device of status bar notice
US11132766B2 (en) Image processing method and device using multiple layers of an operating system
CN105468438B (en) The method and device of process recovery processing is carried out in the application
CN110990142A (en) Concurrent task processing method and device, computer equipment and storage medium
CN103491175B (en) Method and terminal for application program management
CN105607953B (en) The method and device of process recovery processing is carried out in the application
CN106775620B (en) Timing method and device
CN104281488A (en) Implementation method and system of server engine
CN108984321A (en) A kind of mobile terminal and its method for limiting, the storage medium of interprocess communication
CN106708501A (en) Activity monitoring method and device
CN106933681B (en) It is a kind of multipair as blocking method and its system
WO2021244548A1 (en) Instant message processing method and device
CN114585035A (en) Voice call method, device and computer readable storage medium
CN114610202A (en) Silence help seeking method and terminal equipment
CN109857720B (en) Database table monitoring method, device, computer device and readable storage medium
CN101820360A (en) Alarm platform and method for implementing alarm thereof
CN112771499A (en) Message loading method, message loading device and mobile terminal

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20220729

Address after: Room 801, 8th floor, No. 104, floors 1-19, building 2, yard 6, Jiuxianqiao Road, Chaoyang District, Beijing 100015

Patentee after: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Patentee before: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Patentee before: Qizhi software (Beijing) Co.,Ltd.

TR01 Transfer of patent right