CN107741891A - Destructed method, medium, device and the computing device of object - Google Patents

Destructed method, medium, device and the computing device of object Download PDF

Info

Publication number
CN107741891A
CN107741891A CN201710966413.9A CN201710966413A CN107741891A CN 107741891 A CN107741891 A CN 107741891A CN 201710966413 A CN201710966413 A CN 201710966413A CN 107741891 A CN107741891 A CN 107741891A
Authority
CN
China
Prior art keywords
destructed
destination object
class
pointer
program
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
Application number
CN201710966413.9A
Other languages
Chinese (zh)
Other versions
CN107741891B (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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201710966413.9A priority Critical patent/CN107741891B/en
Publication of CN107741891A publication Critical patent/CN107741891A/en
Application granted granted Critical
Publication of CN107741891B publication Critical patent/CN107741891B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1479Generic software techniques for error detection or fault masking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3452Performance evaluation by statistical analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Biology (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computer Hardware Design (AREA)
  • Stored Programmes (AREA)

Abstract

Embodiments of the present invention provide destructed method, medium, device and the computing device of a kind of object.The destructed method of the object includes:At the end of the life cycle of destination object, it is destructed that line delay is entered to the destination object;The destination object was entered in the line delay destructed period, the method for being sent to the destination object originally is forwarded to a do-nothing function pointer.Even if the technical scheme of embodiment of the present invention makes occur the problem of being conducted interviews to the object that life cycle is in calling program, also can be by the way that the method for being sent to the object be forwarded into a do-nothing function pointer to ensure the normal operation of program, solve the problems, such as program the collapse of BAD ACCESS types occur and influence user's use, improve the stability of program operation.

Description

Destructed method, medium, device and the computing device of object
Technical field
Embodiments of the present invention are related to communication and field of computer technology, more specifically, embodiments of the present invention relate to And destructed method, medium, device and the computing device of object.
Background technology
This part is it is intended that the embodiments of the present invention stated in claims provide background or context.Herein Description recognizes it is prior art not because not being included in this part.
In software development industry, it is difficult to the problem of APP (Application, application program) collapses can be run into avoiding, its The collapse accounting of middle BAD ACCESS types is very high and investigation is difficult, and the collapses of BAD ACCESS types has been routine access open country refers to Collapsed caused by pin.
The collapse in industry for BAD ACCESS types mainly has two kinds of processing schemes at present:Scheme one is directly to allow APP collapses are fallen, and analyze crash reason by capturing crash log, are solved pair by issuing new APP versions again after repairing The crash issue answered;Scheme two is by way of heat updates, i.e., issues the code after repairing by script file, operationally The replacement of carry out method and calling scripted code, so as to reach the purpose that problem is repaired before new APP versions are issued.
The content of the invention
Because scheme one needs solve corresponding crash issue by issuing new APP versions, thus it is new not issuing APP versions before without effective method avoid the collapse of BAD ACCESS types, cause this period interior to this species The collapse of type can not timely processing, reduce Consumer's Experience.Simultaneously BAD ACCESS types collapse due to its collapse scene compared with Hardly possible reproduction, cause investigation repair it is very difficult, once and errors repair, not only former problem do not obtain adequate solution, also Having causes risk caused by other problemses, therefore for the collapse of this type, collapses the acquisition of real time information of scene particularly It is important, but it is existing generally not accurate enough by way of crash log captures real time information.
And scheme two use hot update mode certain security risks be present, although and hot update method can reach To before new APP versions are issued by the purpose of problem reparation, but itself still need a problem capture, analysis, The process for solving and applying, can not reach real-time and solve the problems, such as, the effect for preventing APP from collapsing in time.
Therefore, being highly desirable to a kind of destructed scheme of improved object, there are BAD ACCESS types with least settlement procedure Collapse and influence user use the problem of, improve program operation stability.
In the present context, embodiments of the present invention it is expected to provide a kind of destructed method, medium, device and the meter of object Calculate equipment.
In the first aspect of embodiment of the present invention, there is provided a kind of destructed method of object, including:In destination object Life cycle at the end of, it is destructed that line delay is entered to the destination object;The destination object is entered line delay it is destructed when Between in section, the method for being sent to the destination object originally is forwarded to a do-nothing function pointer.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:Whether each object in determining program Need to carry out wild pointer protection;If it is determined that any object in described program needs to carry out wild pointer protection, then to described any Object addition mark, and the object of the mark will be with the addition of as the destination object.
In certain embodiments of the present invention, based on aforementioned schemes, according to the type of each object, described in judgement Whether each object needs to carry out wild pointer protection.
In certain embodiments of the present invention, based on aforementioned schemes, each object in determining program whether need into The step of row wild pointer protects, including:The method for creating each object is replaced by the new method of definition;Institute State and judge whether each object needs to carry out wild pointer protection in new method.
In certain embodiments of the present invention, based on aforementioned schemes, the step of identifying, bag are added to any object Include:Any object described in function pair based on dynamic addition affiliated partner adds the mark.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:It is determined that being carried out to the destination object When being delayed destructed, the association attributes that the destination object is quoted is discharged.
In certain embodiments of the present invention, based on aforementioned schemes, the method for the destination object will be sent to originally The step of being forwarded to a do-nothing function pointer, including:Class pointed by the function pointer of the destination object is revised as to specify class, Wherein, the function pointer points to the primitive class of the destination object originally;Intercepted based on the specified class and be sent to institute originally The method of destination object is stated, and is forwarded to the do-nothing function pointer.
In certain embodiments of the present invention, based on aforementioned schemes, intercepted based on the specified class and be sent to institute originally The step of stating the method for destination object, and being forwarded to the do-nothing function pointer, including:Forwarded by the message in the specified class The method that intercepting api callses are sent to the destination object originally, and return to an object class;To object class dynamic addition class side Method, and the pointer of the class method is pointed into do-nothing function.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:By the class name of the primitive class preserve to In the destination object.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:Acquisition is stored in the destination object Primitive class class name;According to the class name got, wrong data that statistics program occurs in the process of running.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:Whether determining program, which switches to backstage, is transported OK, and/or judge whether the quantity of the destructed destination object of delay reaches predetermined quantity;Backstage is switched in judgement described program During operation, and/or when the quantity for judging the destructed destination object of delay reaches the predetermined quantity, call the destructed mesh that is delayed It is destructed to mark destination object progress described in the function pair of the original releasing memory of object.
In the second aspect of embodiment of the present invention, there is provided a kind of medium, be stored thereon with program, the program is located Manage the method realized when device performs as described in first aspect in above-mentioned embodiment.
In the third aspect of embodiment of the present invention, there is provided a kind of destructed device of object, including:Destructed unit, For at the end of the life cycle of destination object, it is destructed to enter line delay to the destination object;Processing unit, for institute State destination object to enter in the line delay destructed period, the method for being sent to the destination object originally is forwarded to a do-nothing function Pointer.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:First judging unit, for judging journey Whether each object in sequence needs to carry out wild pointer protection;Adding device, described in judging in first judging unit When any object in program needs to carry out wild pointer protection, any object is added and identified, and the mark will be with the addition of The object of knowledge is as the destination object.
In certain embodiments of the present invention, it is configured to based on aforementioned schemes, first judging unit:According to described The type of each object, judges whether each object needs to carry out wild pointer protection.
In certain embodiments of the present invention, it is configured to based on aforementioned schemes, first judging unit:Pass through definition New method replace method for creating each object;Whether judge each object in the new method Need to carry out wild pointer protection.
In certain embodiments of the present invention, it is configured to based on aforementioned schemes, the adding device:Added based on dynamic Any object described in the function pair of affiliated partner adds the mark.
In certain embodiments of the present invention, it is additionally operable to based on aforementioned schemes, the destructed unit:It is determined that to described Destination object enter line delay it is destructed when, discharge the association attributes that the destination object is quoted.
In certain embodiments of the present invention, included based on aforementioned schemes, the processing unit:Unit is changed, is used for Class pointed by the function pointer of the destination object is revised as to specify class, wherein, the function pointer is originally described in sensing The primitive class of destination object;Interception unit, for intercepting the method for being sent to the destination object originally based on the specified class, And it is forwarded to the do-nothing function pointer.
In certain embodiments of the present invention, it is configured to based on aforementioned schemes, the interception unit:Specified by described The method that message forwarding intercepting api callses in class are sent to the destination object originally, and return to an object class;To the object Class dynamic addition class method, and the pointer of the class method is pointed into do-nothing function.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:Storage unit, for will be described original The class name of class is preserved into the destination object.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:Acquiring unit, it is stored in for obtaining The class name of primitive class in the destination object;Statistic unit, for according to the class name got, statistics program to be in running The wrong data of middle appearance.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:Second judging unit, for judging journey Whether sequence switches to running background, and/or judges whether the quantity of the destructed destination object of delay reaches predetermined quantity;The analysis Structure unit is additionally operable to, and when second judging unit judges that described program switches to running background, and/or is judging delay analysis When the quantity of the destination object of structure reaches the predetermined quantity, the letter for the destructed original releasing memory of destination object that is delayed is called It is several destructed to destination object progress.
In the fourth aspect of embodiment of the present invention, there is provided a kind of computing device, including:Processor and memory, The memory storage has executable instruction, and the processor is used to call the executable instruction of the memory storage to perform such as Method in above-mentioned embodiment described in first aspect.
According to destructed method, medium, device and the computing device of the object of embodiment of the present invention, due to BAD ACCESS Collapsed caused by the collapse of the type wild pointer that has been routine access, therefore by the end of the life cycle of destination object, it is right The destination object enters that line delay is destructed, and the destination object was entered in the line delay destructed period, will be sent to mesh originally The method of mark object is forwarded to a do-nothing function pointer so that even if occurring entering the object that life cycle is in program The problem of row accesses, also can be by being forwarded to a do-nothing function pointer to ensure the normal of program by the method for being sent to the object Operation, solve the problems, such as that program the collapse of BAD ACCESS types occurs and influences user's use, improve program operation Stability.
According to destructed method, medium, device and the computing device of the object of embodiment of the present invention, by by destination object The class name of primitive class preserve into destination object, and according to the class name of the primitive class being stored in destination object come statistics program The wrong data occurred in the process of running, enabling be effectively retained the scene letter that the collapse of BAD ACCESS types occurs for program Breath, and then technical staff can be facilitated to carry out investigation reparation.
Brief description of the drawings
Detailed description below, above-mentioned and other mesh of exemplary embodiment of the invention are read by reference to accompanying drawing , feature and advantage will become prone to understand.In the accompanying drawings, if showing the present invention's by way of example, and not by way of limitation Dry embodiment, wherein:
Fig. 1 diagrammatically illustrates the flow chart of the destructed method of object according to an embodiment of the invention;
Fig. 2, which diagrammatically illustrates determination according to an embodiment of the invention, to be needed to carry out the flow of the object of wild pointer protection Figure;
Fig. 3 shows the idiographic flow schematic diagram of the step S12 shown in Fig. 1;
Fig. 4 diagrammatically illustrates according to an embodiment of the invention to needing the object instance for carrying out wild pointer protection to carry out The flow chart of processing;
Fig. 5 diagrammatically illustrates the flow chart according to an embodiment of the invention handled the destructed object that is delayed;
Fig. 6 diagrammatically illustrates the processing procedure schematic diagram of delay destructed period according to an embodiment of the invention;
Fig. 7 diagrammatically illustrates the block diagram of the destructed device of object according to the embodiment of the present invention.
In the accompanying drawings, identical or corresponding label represents identical or corresponding part.
Embodiment
The principle and spirit of the present invention is described below with reference to some illustrative embodiments.It should be appreciated that provide this A little embodiments are not with any just for the sake of better understood when those skilled in the art and then realize the present invention Mode limits the scope of the present invention.On the contrary, these embodiments are provided so that the disclosure is more thorough and complete, and energy It is enough that the scope of the present disclosure is intactly communicated to those skilled in the art.
One skilled in the art will appreciate that embodiments of the present invention can be implemented as a kind of system, device, equipment, method Or computer program product.Therefore, the disclosure can be implemented as following form, i.e.,:Complete hardware, complete software (including firmware, resident software, microcode etc.), or the form that hardware and software combines.
According to the embodiment of the present invention, it is proposed that destructed method, medium, device and the computing device of a kind of object.
Herein, it is to be understood that involved term " program ", " application program " and " application " refers to be arranged on Program on the smart machines such as mobile phone, referred to as APP, generally require and worked in coordination operation with service end.Common application is main It is divided to two classes:One kind is the system application of prepackage, such as short message, photo, memorandum etc.;Another kind of is third-party application, for example is provided Interrogate wechat of Netease's news of class, the Taobao for class of doing shopping, social class etc..
Term " program crashing " refers to the APP operationally improper phenomenons exited suddenly, and program crashing can cause to use The ongoing operation in family is all interrupted.
Term " BAD ACCESS " refer to collapse caused by routine access wild pointer, such as to pair that one has discharged As performing release (release), access the member variable of releasing object or send out message etc. to it.
Term " wild pointer " represents to point to a deleted object or does not apply for accessing the pointer of limited region of memory.
Term " destructed " refers to some clean-up tasks carried out when cancelling object, and the internal memory that object is distributed to such as release is empty Between etc..
In addition, any number of elements in accompanying drawing is used to example and unrestricted, and any name is only used for distinguishing, Without any restrictions implication.
Below with reference to the principle and spirit of some representative embodiments of the present invention, in detail the explaination present invention.
Summary of the invention
Do not sent out the inventors discovered that issuing new APP versions at present to solve the scheme of BAD ACCESS types collapse The collapse of BAD ACCESS types is not avoided that before the new APP versions of cloth, is caused in this period to such collapse Can not timely processing, reduce Consumer's Experience.And certain security risks be present by the way of heat updates, although and heat Update method can reach the purpose of problem reparation before new APP versions are issued, but itself still needs one Problem capture, analysis, the process for solving and applying, can not reach real-time and solve the problems, such as, the effect for preventing APP from collapsing in time.
Therefore, embodiments of the present invention provide a kind of improved object destructed method, medium, device and calculating and set It is standby so that, also can be by that will send out even if occurring the problem of being conducted interviews to the object that life cycle is in program The method for giving the object is forwarded to a do-nothing function pointer to ensure the normal operation of program, solves program and BAD occurs The collapse of ACCESS types and influence user use the problem of, improve program operation stability.
After the general principle of the present invention is described, lower mask body introduces the various non-limiting embodiment party of the present invention Formula.
Application scenarios overview
Understand spirit and principles of the present invention it should be noted that following application scenarios are for only for ease of and show, this The embodiment of invention is unrestricted in this regard.On the contrary, embodiments of the present invention can apply to it is applicable any Scene.
Scene one:At the end of the life cycle of a certain object in program, it is destructed to enter line delay to the object, and It is delayed in the destructed period, if there is the method for being sent to the object, this method is forwarded to a do-nothing function pointer, Jin Erneng Enough avoid accessing wild pointer in program and the problem of BAD ACCESS types collapse occur.
Scene two:For the destructed destination object that is delayed, the class name of the primitive class of the destination object can be preserved to this In destination object, and occurred in the process of running come statistics program according to the class name for the primitive class being stored in the destination object Wrong data, it can so be effectively retained program and the field data of BAD ACCESS types collapse occurs, and then skill can be facilitated Art personnel carry out investigation reparation.
Illustrative methods
With reference to above-mentioned application scenarios, pair according to exemplary embodiment of the invention is described referring to figs. 1 to Fig. 6 The destructed method of elephant.
Fig. 1 diagrammatically illustrates the flow chart of the destructed method of object according to an embodiment of the invention.
Shown in reference picture 1, the destructed method of object according to an embodiment of the invention, including:
Step S10, at the end of the life cycle of destination object, it is destructed that line delay is entered to the destination object.
It should be noted that in embodiments of the present invention, the life cycle of object terminates where being object Function is modulated with finishing.
In addition, in embodiments of the present invention, when it is determined that destination object is entered line delay it is destructed when, the mesh can be discharged Mark the association attributes of object reference.
In embodiments of the present invention, due to many system classes in program being present, such as in ISO systems NSString, UIView etc. are created, release is very frequent, and the probability that wild pointer occurs for these examples is very low, in order to improve effect Rate, without all carrying out wild pointer protection to all objects.Therefore, embodiments of the present invention provide determination as shown in Figure 2 The scheme of the destination object of progress wild pointer protection is needed, is specifically included:
Whether step S20, each object in determining program need to carry out wild pointer protection.
In embodiments of the present invention, it can judge whether each object needs according to the type of each object in program Carry out wild pointer protection.Such as some objects for system class, without carrying out wild pointer protection, and for self defined class Some objects, then it can carry out wild pointer protection.
In an exemplary embodiment of the present invention embodiment, step S20 can include:Replaced and be used for by the new method of definition The method for creating each object, judges whether each object needs progress wild pointer to prevent in the new method Shield.
For example for IOS systems, method swizzling can be utilized to replace NSObject's (class in IOS systems) AllocWithZone (method that class example is created in IOS systems) method, then judges whether object needs in new method Carry out wild pointer protection.
Step S22, if it is determined that any object in program needs to carry out wild pointer protection, then any object is added Mark, and the object of the mark will be with the addition of as the destination object.
In an exemplary embodiment of the present invention embodiment, adding the step of identifying to any object in step S22 can include: Any object described in function pair based on dynamic addition affiliated partner adds the mark.
For example for IOS systems, (it can dynamically add and close in IOS systems by objc_setAssociatedObject Joining the function of object) affiliated partner is that the needs carry out the object of wild pointer protection and set mark, extended meeting after identified object Into follow-up protection flow.
With continued reference to Fig. 1, the destructed method of described object also includes:
Step S12, the destination object was entered in the line delay destructed period, the target pair will be sent to originally The method of elephant is forwarded to a do-nothing function pointer.
In embodiments of the present invention, shown in reference picture 3, step S12 comprises the following steps:
Step S121, the class pointed by the function pointer of destination object is revised as to specify class, wherein, the function pointer Originally the primitive class of the destination object is pointed to.
For example for IOS systems, the function pointer (i.e. isa pointers) that destination object can be pointed to its primitive class originally is repaiied Customized class is changed to point to, the customized class is the good class for being used to handle the destructed object of delay of predefined.
Step S122, intercepted based on the specified class and be sent to the method for the destination object originally, and be forwarded to described Do-nothing function pointer.
In an exemplary embodiment of the present invention embodiment, step S122 includes:By specifying the message in class to forward function to block The method for being sent to the destination object originally is cut, and returns to an object class;To object class dynamic addition class method, and will The pointer of the class method points to do-nothing function.
For example for IOS systems, it can be intercepted by customized class and be sent to the method for destination object originally, and returned One object class (such as stubProxy), then to object class dynamic addition selector (i.e. class method), make selector's Imp pointers point to a do-nothing function, and the do-nothing function returns to 0.
It should be noted that the object being over for life cycle, embodiments of the present invention are that it is prolonged When it is destructed, but it is final still need to carry out these objects destructed, based on this, the present invention proposes following end delay analysis The scheme of structure:
In certain embodiments of the present invention, whether determining program switches to running background, and/or judges that delay is destructed The quantity of destination object whether reach predetermined quantity;When judging that described program switches to running background, and/or judging to prolong When destructed destination object quantity when reaching the predetermined quantity, call the destructed original releasing memory of destination object that is delayed Function pair described in destination object carry out it is destructed.
Based on foregoing scheme, embodiments of the present invention additionally provide following scheme:The class name of the primitive class is protected Deposit into the destination object.Obtain the class name for the primitive class being stored in the destination object;According to the class name got, system The wrong data that sequence of having the records of distance by the log occurs in the process of running.
In embodiments of the present invention, by the way that the class name of the primitive class of destination object is preserved into destination object, and The wrong data occurred in the process of running come statistics program according to the class name for the primitive class being stored in destination object so that energy Enough it is effectively retained program and the field data of BAD ACCESS types collapse occurs, and then technical staff can be facilitated to carry out investigation and repaiied It is multiple.
Below by taking IOS systems as an example, the destructed method of the object of embodiment of the present invention is described in detail, main bag Containing following 4 processes:
1st, shown in reference picture 4, comprise the following steps:
Step S401, original allocWithZone methods in NSObject are replaced using method swizzling.
Step S402, judges whether the type object needs to carry out wild pointer protection in new method, if so, then performing Step S403;Otherwise, step S404 is performed.
Step S403, it is that the object instance sets flag to mark by objc_setAssociatedObject, is labeled Object after extended meeting enter protection flow.
Step S404, original allocWithZone methods are called to be handled.
Flow shown in Fig. 4 is particular by the original allocWithZone methods of hook come to needing to carry out wild pointer The object instance addition mark of protection, so that follow-up process is identified.
2nd, shown in reference picture 5, comprise the following steps:
Step S501, the object being over for life cycle, NSObject is replaced using method swizzling In original dealloc methods.
Step S502, judges whether object instance has flag marks, if so, then performing step S504;Otherwise, step is performed S503。
Step S503, original dealloc methods are called to discharge the object instance.I.e. for wild pointer protection need not be carried out Object instance, then the object instance is directly discharged by original dealloc methods.
Step S504, objc_destructInstance methods are called to discharge the reality object instance for having flag to mark The association attributes that example is quoted.
Step S505, the isa of the object instance is revised as HTZombieObject classes.HTZombieObject classes are things One first defined is specifically used to the class of the destructed object of processing delay, can be by so being sent to the method for the class object and disappearing Breath is all forwarded on a do-nothing function pointer.
Step S506, original class name is stored in the example by objc_setAssociatedObject, for rear Continuous error statistics use.
Whether step S507, the destructed object that judges to be delayed reach the upper limit, if so, then performing step S508;Otherwise, directly Perform step S509.
Step S508, ht_freeSomeMemory release cachings are called, in order to which the object instance is added in caching.
Step S509, the object instance is added in caching.
3rd, shown in reference picture 6, comprise the following steps:
Step S601, the forwardingTargetForSelector methods in HTZombieObject are rewritten, to pass through Message forwarding mechanism forwardingTargetForSelector intercepts all message for being transmitted to HTZombieObject.
Step S602, create stake class stubProxy.
Step S603, is selector corresponding to the dynamic addition of stake class, and selector imp points to do-nothing function, the sky letter Number returns to 0.The purpose that program is not collapsed is reached by a function for being returned as sky.
Step S604, the primitive class of the object instance preserved before is obtained by objc_getAssociatedObject Name, mistake of statistics data.
Step S605, return stubProxy is by message transfers to this class object.And then work as After forwardingTargetForSelector intercepts the message for passing to HTZombieObject, the message can be turned Move on on this class object, because the class method selector of this class object imp points to do-nothing function, therefore can finally return 0, the object instance that life cycle is over is have accessed even if realizing, can also ensure that the purpose that program is not collapsed.
4th, when program falls back on backstage or the destructed object instance that is delayed reaches the upper limit, then call destructed object original The destructed object instance of all delays of dealloc methods release.
It should be noted that:Fig. 4 to Fig. 6 has been carried out in detail by taking IOS systems as an example to the destructed method of the embodiment of the present invention Illustrate, those skilled in the art may be equally applicable for the embodiment of the present invention it is to be appreciated that for other operating systems Destructed method.
Exemplary media
After the method for exemplary embodiment of the invention is described, next, to exemplary embodiment of the invention Medium illustrate.
In some possible embodiments, various aspects of the invention are also implemented as a kind of medium, store thereon There is program code, be used to realize that this specification is above-mentioned " illustrative methods " when computing device of the described program code by equipment Step in the destructed method of the object according to the various illustrative embodiments of the present invention described in part.
Specifically, it is used to realize following steps during the computing device described program code of the equipment:In destination object Life cycle at the end of, it is destructed that line delay is entered to the destination object;The destination object is entered line delay it is destructed when Between in section, the method for being sent to the destination object originally is forwarded to a do-nothing function pointer.
In certain embodiments of the present invention, it is additionally operable to realize during the computing device described program code of the equipment Following steps:Whether each object in determining program needs to carry out wild pointer protection;It is if it is determined that any right in described program As needing to carry out wild pointer protection, then any object is added and identified, and the object of the mark will be with the addition of as institute State destination object.
In certain embodiments of the present invention, it is additionally operable to realize during the computing device described program code of the equipment Following steps:According to the type of each object, judge whether each object needs to carry out wild pointer protection.
In certain embodiments of the present invention, it is used to realize such as during the computing device described program code of the equipment Lower step:The method for creating each object is replaced by the new method of definition;Judge in the new method Whether each object needs to carry out wild pointer protection.
In certain embodiments of the present invention, it is used to realize such as during the computing device described program code of the equipment Lower step:Any object described in function pair based on dynamic addition affiliated partner adds the mark.
In certain embodiments of the present invention, it is additionally operable to realize during the computing device described program code of the equipment Following steps:It is determined that the destination object is entered line delay it is destructed when, discharge the association attributes that the destination object is quoted.
In certain embodiments of the present invention, it is used to realize such as during the computing device described program code of the equipment Lower step:Class pointed by the function pointer of the destination object is revised as to specify class, wherein, the function pointer refers to originally To the primitive class of the destination object;Intercepted based on the specified class and be sent to the method for the destination object originally, and forwarded To the do-nothing function pointer.
In certain embodiments of the present invention, it is used to realize such as during the computing device described program code of the equipment Lower step:Forward intercepting api callses to be sent to the method for the destination object originally by the message in the specified class, and return One object class;To object class dynamic addition class method, and the pointer of the class method is pointed into do-nothing function.
In certain embodiments of the present invention, it is used to realize such as during the computing device described program code of the equipment Lower step:The class name of the primitive class is preserved into the destination object.
In certain embodiments of the present invention, it is additionally operable to realize during the computing device described program code of the equipment Following steps:Obtain the class name for the primitive class being stored in the destination object;According to the class name got, statistics program is being transported The wrong data occurred during row.
In certain embodiments of the present invention, it is additionally operable to realize during the computing device described program code of the equipment Following steps:Whether determining program switches to running background, and/or judges whether the quantity of the destructed destination object of delay reaches Predetermined quantity;Reached when judging that described program switches to running background, and/or in the quantity for judging the destructed destination object of delay During to the predetermined quantity, the destination object described in the function pair of the destructed original releasing memory of destination object that is delayed is called to carry out It is destructed.
It should be noted that:Above-mentioned medium can be readable signal medium or readable storage medium storing program for executing.Readable storage medium Matter can be for example but not limited to:Electricity, magnetic, optical, electromagnetic, system, device or the device of infrared ray or semiconductor, or arbitrarily Combination above.The more specifically example (non exhaustive list) of readable storage medium storing program for executing includes:With one or more wires Electrical connection, portable disc, hard disk, random access memory (RAM), read-only storage (ROM), erasable type may be programmed read-only storage Device (EPROM or flash memory), optical fiber, portable compact disc read only memory (CD-ROM), light storage device, magnetic memory device or The above-mentioned any appropriate combination of person.
Readable signal medium can be included in a base band or as a part of data-signal propagated of carrier wave, wherein carrying Readable program code.The data-signal of this propagation can take various forms, and include but is not limited to:Electromagnetic signal, light letter Number or above-mentioned any appropriate combination.Readable signal medium can also be any computer-readable recording medium beyond readable storage medium storing program for executing, The computer-readable recording medium can send, propagate and either transmit for being used by instruction execution system, device or device or being tied with it Close the program used.
The program code included on computer-readable recording medium can be transmitted with any appropriate medium, be included but is not limited to:Wirelessly, have Line, optical cable, RF etc., or above-mentioned any appropriate combination.
Can being combined to write the program operated for performing the present invention with one or more programming languages Code, described program design language include object oriented program language-Java, C++ etc., include routine Procedural programming language-such as " C " language or similar programming language.Program code can be fully in user Performed on computing device, part performs or remotely counted completely on a remote computing on the user computing device for part Calculate and performed on equipment or server.In the situation of remote computing device is related to, remote computing device can pass through any kind Network --- including LAN (LAN) or wide area network (WAN)-be connected to user calculating equipment, or, it may be connected to it is outer Portion's computing device (such as passing through Internet connection using ISP).
Exemplary means
After the medium of exemplary embodiment of the invention is described, next, with reference to figure 7 to the exemplary reality of the present invention The destructed device for applying the object of mode illustrates.
Fig. 7 diagrammatically illustrates the block diagram of the destructed device of object according to the embodiment of the present invention.
Shown in reference picture 7, the destructed device 700 of object according to the embodiment of the present invention, including:Destructed unit 702 With processing unit 704.
Specifically, destructed unit 702 is used at the end of the life cycle of destination object, and the destination object is prolonged When it is destructed;Processing unit 704 is used to enter in the line delay destructed period destination object, will be sent to originally described The method of destination object is forwarded to a do-nothing function pointer.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:First judging unit 706, for judging Whether each object in program needs to carry out wild pointer protection;Adding device 708, in first judging unit 706 When judging that any object in described program needs to carry out wild pointer protection, any object is added and identified, and will be added The object of the mark is as the destination object.
In certain embodiments of the present invention, it is configured to based on aforementioned schemes, first judging unit 706:According to The type of each object, judges whether each object needs to carry out wild pointer protection.
In certain embodiments of the present invention, it is configured to based on aforementioned schemes, first judging unit 706:Pass through The new method of definition replaces the method for creating each object;Judge each object in the new method Whether need to carry out wild pointer protection.
In certain embodiments of the present invention, it is configured to based on aforementioned schemes, the adding device 708:Based on dynamic Add any object described in the function pair of affiliated partner and add the mark.
In certain embodiments of the present invention, it is additionally operable to based on aforementioned schemes, the destructed unit 702:It is determined that pair The destination object enter line delay it is destructed when, discharge the association attributes that the destination object is quoted.
In certain embodiments of the present invention, included based on aforementioned schemes, the processing unit 704:Change unit 7042, for the class pointed by the function pointer of the destination object to be revised as to specify class, wherein, the function pointer is originally Point to the primitive class of the destination object;Interception unit 7044, the mesh is sent to originally for being intercepted based on the specified class The method of object is marked, and is forwarded to the do-nothing function pointer.
In certain embodiments of the present invention, it is configured to based on aforementioned schemes, the interception unit 7044:By described The method for specifying the forwarding intercepting api callses of the message in class to be sent to the destination object originally, and return to an object class;To described Object class dynamic addition class method, and the pointer of the class method is pointed into do-nothing function.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:Storage unit 710, for by the original The class name of beginning class is preserved into the destination object.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:Acquiring unit 712, preserved for obtaining The class name of primitive class in the destination object;Statistic unit, for being run according to the class name got, statistics program The wrong data occurred in journey.
In certain embodiments of the present invention, based on aforementioned schemes, in addition to:Second judging unit 714, for judging Whether program switches to running background, and/or judges whether the quantity of the destructed destination object of delay reaches predetermined quantity;It is described Destructed unit 702 is additionally operable to, and when second judging unit judges that described program switches to running background, and/or is being judged When the quantity of destructed destination object of being delayed reaches the predetermined quantity, call and be delayed in the destructed original release of destination object Destination object described in the function pair deposited carries out destructed.
Exemplary computer device
After method, medium and the device of exemplary embodiment of the invention is described, next, introducing according to this hair The computing device of bright another exemplary embodiment.
Person of ordinary skill in the field it is understood that various aspects of the invention can be implemented as system, method or Program product.Therefore, various aspects of the invention can be implemented as following form, i.e.,:It is complete hardware embodiment, complete The embodiment combined in terms of full Software Implementation (including firmware, microcode etc.), or hardware and software, can unite here Referred to as " circuit ", " module " or " system ".
In some possible embodiments, at least one can be comprised at least according to the computing device of embodiment of the present invention Individual processor and at least one memory.Wherein, the memory storage has program code, when described program code is by institute When stating computing device so that described in above-mentioned " illustrative methods " part of computing device this specification according to this hair Step in the destructed method of the object of bright various illustrative embodiments.For example, the processor can be performed such as institute in Fig. 1 The step S10 shown, at the end of the life cycle of destination object, it is destructed that line delay is entered to the destination object;Step S12, The destination object is entered in the line delay destructed period, the method for being sent to the destination object originally is forwarded to Function pointer.And for example, the step of processor can also be performed as shown in Fig. 2 to Fig. 6.
It should be noted that although being referred to some units or subelement of the destructed device of object in above-detailed, But what this division was merely exemplary, it is not enforceable.In fact, according to the embodiment of the present invention, retouch above Two or more modules or the feature and function of unit stated can embody in a module or unit.Conversely, retouch above The module or the feature and function of unit stated can be further divided into being embodied by multiple modules or unit.
In addition, although the operation of the inventive method is described with particular order in the accompanying drawings, still, this do not require that or Hint must perform these operations according to the particular order, or the operation having to carry out shown in whole could realize it is desired As a result.Additionally or alternatively, it is convenient to omit some steps, multiple steps are merged into a step and performed, and/or by one Step is decomposed into execution of multiple steps.
Although describe spirit and principles of the present invention by reference to some embodiments, it should be appreciated that, this Invention is not limited to disclosed embodiment, and the division to each side does not mean that the feature in these aspects can not yet Combination is to be benefited, and this division is merely to the convenience of statement.It is contemplated that cover appended claims spirit and In the range of included various modifications and equivalent arrangements.

Claims (10)

1. a kind of destructed method of object, including:
At the end of the life cycle of destination object, it is destructed that line delay is entered to the destination object;
The destination object was entered in the line delay destructed period, the method for being sent to the destination object originally is being forwarded To a do-nothing function pointer.
2. the method according to claim 11, in addition to:
Whether each object in determining program needs to carry out wild pointer protection;
If it is determined that any object in described program needs to carry out wild pointer protection, then add identifying to any object, and The object of the mark will be with the addition of as the destination object.
3. according to the method for claim 2, wherein, according to the type of each object, judge that each object is It is no to need to carry out wild pointer protection.
4. according to the method for claim 2, wherein, whether each object in determining program needs to carry out wild pointer protection The step of, including:
The method for creating each object is replaced by the new method of definition;
Judge whether each object needs to carry out wild pointer protection in the new method.
5. according to the method for claim 2, wherein, the step of identifying is added to any object, including:
Any object described in function pair based on dynamic addition affiliated partner adds the mark.
6. the method according to claim 11, in addition to:
It is determined that the destination object is entered line delay it is destructed when, discharge the association attributes that the destination object is quoted.
7. according to the method for claim 1, wherein, the method for being sent to the destination object originally letter is forwarded to The step of number pointer, including:
Class pointed by the function pointer of the destination object is revised as to specify class, wherein, the function pointer points to originally The primitive class of the destination object;
Intercepted based on the specified class and be sent to the method for the destination object originally, and be forwarded to the do-nothing function pointer.
8. a kind of medium, is stored thereon with program, realized when the program is executed by processor such as any one of claim 1 to 7 Described method.
9. a kind of destructed device of object, including:
Destructed unit, at the end of the life cycle of destination object, it is destructed to enter line delay to the destination object;
Processing unit, for entering to the destination object in the line delay destructed period, the target will be sent to originally The method of object is forwarded to a do-nothing function pointer.
10. a kind of computing device, including:Processor and memory, the memory storage have executable instruction, the processor Executable instruction for calling the memory storage performs the method as any one of claim 1 to 7.
CN201710966413.9A 2017-10-17 2017-10-17 Object reconstruction method, medium, device and computing equipment Active CN107741891B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710966413.9A CN107741891B (en) 2017-10-17 2017-10-17 Object reconstruction method, medium, device and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710966413.9A CN107741891B (en) 2017-10-17 2017-10-17 Object reconstruction method, medium, device and computing equipment

Publications (2)

Publication Number Publication Date
CN107741891A true CN107741891A (en) 2018-02-27
CN107741891B CN107741891B (en) 2020-12-08

Family

ID=61237667

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710966413.9A Active CN107741891B (en) 2017-10-17 2017-10-17 Object reconstruction method, medium, device and computing equipment

Country Status (1)

Country Link
CN (1) CN107741891B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108469993A (en) * 2018-04-04 2018-08-31 武汉斗鱼网络科技有限公司 Message forwarding method, computer readable storage medium and electronic equipment
CN109992482A (en) * 2019-04-11 2019-07-09 广州华多网络科技有限公司 Observe the destructed method, apparatus of middleware, computer equipment and storage medium
CN110851187A (en) * 2019-11-19 2020-02-28 北京百度网讯科技有限公司 Video memory processing method, device, equipment and medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5918235A (en) * 1997-04-04 1999-06-29 Hewlett-Packard Company Object surrogate with active computation and probablistic counter
CN101046755A (en) * 2006-03-28 2007-10-03 郭明南 System and method of computer automatic memory management
CN106708737A (en) * 2016-12-21 2017-05-24 腾讯科技(深圳)有限公司 Test method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5918235A (en) * 1997-04-04 1999-06-29 Hewlett-Packard Company Object surrogate with active computation and probablistic counter
CN101046755A (en) * 2006-03-28 2007-10-03 郭明南 System and method of computer automatic memory management
CN106708737A (en) * 2016-12-21 2017-05-24 腾讯科技(深圳)有限公司 Test method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
JINGXIANLI0922: ""好想法---抓取crash,我们要在crash产生的时候直接自动修复它!"", 《HTTPS://BLOG.CSDN.NET/JASONJWL/ARTICLE/DETAILS/54016750》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108469993A (en) * 2018-04-04 2018-08-31 武汉斗鱼网络科技有限公司 Message forwarding method, computer readable storage medium and electronic equipment
CN109992482A (en) * 2019-04-11 2019-07-09 广州华多网络科技有限公司 Observe the destructed method, apparatus of middleware, computer equipment and storage medium
CN109992482B (en) * 2019-04-11 2023-10-31 广州方硅信息技术有限公司 Method, device, computer equipment and storage medium for observing middleware destructor
CN110851187A (en) * 2019-11-19 2020-02-28 北京百度网讯科技有限公司 Video memory processing method, device, equipment and medium
CN110851187B (en) * 2019-11-19 2023-06-02 北京百度网讯科技有限公司 Video memory processing method, device, equipment and medium

Also Published As

Publication number Publication date
CN107741891B (en) 2020-12-08

Similar Documents

Publication Publication Date Title
CN106547678B (en) Method and apparatus for white-box testing
CN109446063A (en) Interface test method, device, computer equipment and storage medium
CN109284463A (en) A kind of method of data capture and system based on dynamic template
CN104536890B (en) Test system, method and apparatus
CN112100250B (en) Data processing method and device
CN104994219B (en) A kind of data processing method and system
CN107741891A (en) Destructed method, medium, device and the computing device of object
CN109710428A (en) A kind of dynamic call method and device for realizing class
CN105450772B (en) Exempt from flow method for down loading and device
CN106648556A (en) Front end and back end integrated development testing method and device
CN107609122A (en) Update method, device, server and the storage medium of advertisement shielding rules
CN110058850A (en) A kind of development approach of application, device and storage medium
CN110097331A (en) Method of calibration, device, storage medium and the electronic equipment of business form
US11232019B1 (en) Machine learning based test coverage in a production environment
CN110175833A (en) A kind of computer installation, method, system and medium for binding bank card information
CN104994220B (en) A kind of data processing method and system
CN107436846A (en) Method of testing, device, calculate readable storage medium storing program for executing and computing device
US20210385297A1 (en) Systems and methods for regulating service behavior
CN108647315A (en) Collecting method and system
KR102119213B1 (en) Platform system for correspondence training of cyber threat
CN106598642A (en) Method and device for using services in plug-in
CN110427277A (en) Data verification method, device, equipment and storage medium
CN108762809A (en) Software function extended method, device, computer equipment and storage medium
CN110134579A (en) Code check method and apparatus
CN108563578A (en) SDK compatibility detection method, device, equipment and readable storage medium

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