A zombie object attribution method and device

By recording and analyzing the release information of instance objects, the problem of difficult to detect and attribute zombie objects in the prior art is solved, and the reasons for zombie objects are clarified are achieved, and the application repair is promoted.

CN114090384BActive Publication Date: 2025-03-14DOUYIN VISION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111402742.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-19
Publication Date
2025-03-14
Estimated Expiration
2041-11-19

AI Technical Summary

Technical Problem

The prior art is difficult to detect and attribute the generation reasons of zombie objects during program operation, which makes it difficult to repair applications.

Method used

By recording the release information of the instance object, in response to the release function call of the instance object, determine whether the instance object is the object to be monitored, and when a zombie object is detected, the target release information of the target instance object is found from the recorded release information to determine the reason for the generation of the zombie object.

Benefits of technology

It implements attribution of zombie objects during program operation, helping users understand the reasons for zombie objects generation, thereby repairing applications more effectively.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114090384B_ABST
    Figure CN114090384B_ABST
Patent Text Reader

Abstract

The present disclosure provides a zombie object attribution method and device. The method first responds to a release function call for an instance object to determine whether the instance object is an object to be monitored; then, if the instance object is an object to be monitored, the release information of the instance object is recorded; thereafter, if a zombie object is detected, the target release information of the target instance object corresponding to the zombie object is searched from the recorded release information; wherein, the accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released; finally, if the target release information is found, the generation reason of the zombie object is determined based on the target release information. The embodiment of the present disclosure records the release information of the instance object, so that when a zombie object is detected, the generation reason of the zombie object is determined by using the recorded release information, thereby achieving the attribution of the zombie object.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a zombie object attribution method and device. Background Art

[0002] A zombie object is a common abnormality in program execution. It is essentially an accessible instance object that exists in memory, but the memory of the instance object has been recycled and released. When the memory of an instance object is released, the instance object becomes a zombie object. A wild pointer is a pointer to a zombie object.

[0003] Usually, the program can only detect the existence of zombie objects. The user can only know that a certain object is a zombie object, but does not know the reason why the object is a zombie, which is not conducive to repairing the application. Summary of the invention

[0004] The embodiments of the present disclosure at least provide a method and device for attributing zombie objects.

[0005] In a first aspect, an embodiment of the present disclosure provides a zombie object attribution method, including:

[0006] In response to a release function call for an instance object, determining whether the instance object is an object to be monitored;

[0007] When the instance object is an object to be monitored, recording release information of the instance object;

[0008] In the case where a zombie object is detected, searching the recorded release information for target release information of a target instance object corresponding to the zombie object; wherein an accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released;

[0009] When the target release information is found, the generation reason of the zombie object is determined based on the target release information.

[0010] In an optional implementation manner, the recording of the release information of the instance object includes:

[0011] The release information of the instance object is recorded in a stack form.

[0012] In an optional implementation manner, the method further includes:

[0013] If the target release information is not found, determining at least one possible release time of the target instance object based on the logic code corresponding to the target instance object;

[0014] Based on the possible release timing, a reason for generating the zombie object is determined.

[0015] In an optional implementation manner, the method further includes:

[0016] When at least one optional release timing of the target instance object cannot be determined, the target instance object is set as an object to be detected, so that the release information of the target instance object is recorded when a release function call for the target instance object is monitored next time.

[0017] In an optional implementation manner, when the instance object is an object to be monitored, recording release information of the instance object includes:

[0018] In the case where the instance object is the object to be monitored, if the storage space occupied by the currently recorded release information is less than a preset threshold, the release information of the instance object is recorded.

[0019] In an optional implementation, the instance object is an object released by a main thread or a child thread of the iOS system.

[0020] In an optional implementation, the method further comprises:

[0021] When it is detected that the zombie object is released, the stored release information of the target instance object corresponding to the zombie object is deleted.

[0022] In a second aspect, the embodiment of the present disclosure further provides a zombie object attribution device, including:

[0023] A response module, configured to determine whether the instance object is an object to be monitored in response to a release function call for the instance object;

[0024] A recording module, used for recording release information of the instance object when the instance object is an object to be monitored;

[0025] A search module, used for searching, when a zombie object is detected, target release information of a target instance object corresponding to the zombie object from the recorded release information; wherein the accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released;

[0026] The attribution module is used to determine the generation reason of the zombie object based on the target release information when the target release information is found.

[0027] In an optional implementation manner, when recording the release information of the instance object, the recording module is used to:

[0028] The release information of the instance object is recorded in a stack form.

[0029] In an optional implementation manner, the attribution module is further configured to:

[0030] If the target release information is not found, determining at least one possible release time of the target instance object based on the logic code corresponding to the target instance object;

[0031] Based on the possible release timing, a reason for generating the zombie object is determined.

[0032] In an optional implementation manner, the device further includes a setting module, configured to:

[0033] When at least one optional release timing of the target instance object cannot be determined, the target instance object is set as an object to be detected, so that the release information of the target instance object is recorded when a release function call for the target instance object is monitored next time.

[0034] In an optional implementation manner, the recording module is specifically used to:

[0035] In the case where the instance object is the object to be monitored, if the storage space occupied by the currently recorded release information is less than a preset threshold, the release information of the instance object is recorded.

[0036] In an optional implementation, the instance object is an object released by a main thread or a child thread of the iOS system.

[0037] In an optional implementation, the recording module is further used to:

[0038] When it is detected that the zombie object is released, the stored release information of the target instance object corresponding to the zombie object is deleted.

[0039] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are performed.

[0040] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned first aspect or any possible implementation of the first aspect are executed.

[0041] The zombie object attribution method and device provided by the embodiment of the present disclosure first responds to the release function call for the instance object to determine whether the instance object is an object to be monitored; then, if the instance object is an object to be monitored, the release information of the instance object is recorded; thereafter, if a zombie object is detected, the target release information of the target instance object corresponding to the zombie object is searched from the recorded release information; wherein, the accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released; finally, if the target release information is found, the generation reason of the zombie object is determined based on the target release information. The embodiment of the present disclosure records the release information of the instance object, so that when the zombie object is detected, the generation reason of the zombie object is determined by using the recorded release information, thereby realizing the attribution of the zombie object.

[0042] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0044] Figure 1 A flowchart of a zombie object attribution method provided by an embodiment of the present disclosure is shown;

[0045] Figure 2 A flowchart of another zombie object attribution method provided by an embodiment of the present disclosure is shown;

[0046] Figure 3 A schematic diagram of a zombie object attribution device provided by an embodiment of the present disclosure is shown;

[0047] Figure 4 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0049] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0050] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0051] Research has found that when the program is running, it usually only supports the detection of zombie objects, that is, it can only find zombie objects, but does not support the analysis of the causes of their formation. The attribution solution for zombie objects is usually determined by analyzing the code in offline scenarios, and it is impossible to achieve attribution in online environments.

[0052] Based on the above research, the present disclosure provides a zombie object attribution method, which records the release information of instance objects, so that when a zombie object is detected, the recorded release information is used to determine the cause of the zombie object's generation, thereby achieving the attribution of the zombie object.

[0053] To facilitate understanding of this embodiment, a zombie object attribution method disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the zombie object attribution method provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example, a terminal device or a server or other processing device. In some possible implementations, the zombie object attribution method can be implemented by a processor calling a computer-readable instruction stored in a memory.

[0054] See also Figure 1FIG. 1 is a flowchart of a zombie object attribution method provided by an embodiment of the present disclosure, wherein the method includes steps S101 to S104, wherein:

[0055] S101 . In response to a release function call for an instance object, determine whether the instance object is an object to be monitored.

[0056] In this step, the release function call can be monitored. When it is detected that an instance object has triggered a release function call, it can be determined whether the instance object is an object to be monitored. The object to be monitored can be an object pre-set by the user. The user can set the instance object that needs to be attributed to a zombie object according to needs and monitor the specific instance object.

[0057] The above release function may be a dealloc method, which is a memory release function under the iOS platform and is used to release memory resources occupied by an instance object or a class.

[0058] In a possible implementation, it can be determined first whether the detected instance function is the object to be monitored. If so, the storage space occupancy of the currently recorded release information can be determined. If the storage space occupancy is less than a preset threshold, the release information of the above instance object is recorded.

[0059] Exemplarily, the release information currently recorded may point to the release information of the instance function, or may point to all release information recorded globally.

[0060] In this way, the storage space occupied by the released information can be kept within a certain range, preventing other problems caused by excessive storage space occupation.

[0061] S102: When the instance object is an object to be monitored, record release information of the instance object.

[0062] In this step, the release information of the instance object can be stored in a specific stack. The stack is a data structure. The stored data items can be arranged in order and the above release information is recorded in the form of a stack. The stack can be a software stack in the internal memory or a hardware stack composed of registers.

[0063] The release information may include the time when the instance object is released, the object that calls the release function, the code segment to which the instance object belongs, and other information used to analyze the cause of the zombie object.

[0064] S103. When a zombie object is detected, search the recorded release information for target release information of a target instance object corresponding to the zombie object; wherein an accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released.

[0065] In this step, zombie objects can be monitored at the same time. When a zombie object is detected, the release information corresponding to the zombie object can be searched from the stack storing the release information to obtain the target release information.

[0066] S104: When the target release information is found, determine the generation reason of the zombie object based on the target release information.

[0067] In this step, if the target release information is found, it is possible to determine when, which process, and which code performed the memory release based on the found target release information, thereby determining the reason for the generation of the zombie object.

[0068] In some possible implementations, the zombie object that may be detected is not a pre-set object to be detected. Therefore, the release information of the target instance object corresponding to the zombie object will not be recorded in the stack. Therefore, when at least one optional release timing of the target instance object cannot be determined, the target instance object is set as the object to be detected. In this way, the release information of the target instance object is recorded when the release function call for the target instance object is monitored next time, so that when a zombie object of the target instance object is generated, the generated zombie object can be attributed.

[0069] In one possible implementation, the above scheme can be applied to the iOS system. Since the iOS system is provided with a main thread and a child thread, if the release function calls of the main thread and the child thread are monitored at the same time, the overall monitoring will require a large amount of waiting time for the child thread. Therefore, the instance objects of the main thread and the child thread can be monitored separately, and the objects released by the main thread can be monitored separately, or the objects released by the child thread can be monitored separately, thereby improving the monitoring efficiency.

[0070] In a possible implementation, if it is detected that the zombie object is released, the release information of the target instance object corresponding to the stored zombie object can be filtered out from the stack, so that unnecessary information can be released, thereby saving storage resources.

[0071] The zombie object attribution method and device provided by the embodiment of the present disclosure first responds to the release function call for the instance object to determine whether the instance object is an object to be monitored; then, if the instance object is an object to be monitored, the release information of the instance object is recorded; thereafter, if a zombie object is detected, the target release information of the target instance object corresponding to the zombie object is searched from the recorded release information; wherein, the accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released; finally, if the target release information is found, the generation reason of the zombie object is determined based on the target release information. The embodiment of the present disclosure records the release information of the instance object, so that when the zombie object is detected, the generation reason of the zombie object is determined by using the recorded release information, thereby realizing the attribution of the zombie object.

[0072] See also Figure 2 As shown, another zombie object attribution method provided by an embodiment of the present disclosure is provided. When detecting the release of an object (i.e., the instance object mentioned above), the method determines whether the object hits the class that needs to be attributed (i.e., whether it is an object to be monitored), and whether the storage space occupied by the recorded release stack does not exceed the threshold. If so, the release information of the object is recorded in the release stack, and monitoring is continued. When a zombie object zombie is detected to be triggered at a certain moment, it is queried whether there is a release stack that records the release information of the instance object corresponding to the zombie object. If so, the release information is obtained through the release stack of the zombie object, and then Attribute the zombie object to solve the zombie object problem; if there is no record, analyze the application code through offline analysis to determine in which code segment the zombie object is used, so as to find the cause of the zombie object; if the offline analysis method fails to successfully find the cause of the zombie object, it can be determined whether the class corresponding to the object is configured as the class that needs to be attributed. If it has been set as the class that needs to be attributed, it ends directly. If it has not been set, it is configured as the class that needs to be attributed, so that the zombie object can be attributed by releasing the stack when the zombie object is triggered again.

[0073] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0074] Based on the same inventive concept, the embodiment of the present disclosure also provides a zombie object attribution device corresponding to the zombie object attribution method. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned zombie object attribution method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0075] Reference Figure 3 FIG. 1 is a schematic diagram of a zombie object attribution device provided by an embodiment of the present disclosure, wherein the device comprises:

[0076] A response module 310, configured to determine whether the instance object is an object to be monitored in response to a release function call for the instance object;

[0077] A recording module 320, configured to record release information of the instance object when the instance object is an object to be monitored;

[0078] A search module 330 is used to search for target release information of a target instance object corresponding to the zombie object from the recorded release information when a zombie object is detected; wherein the accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released;

[0079] The attribution module 340 is used to determine the reason for generating the zombie object based on the target release information when the target release information is found.

[0080] In an optional implementation manner, when recording the release information of the instance object, the recording module 320 is used to:

[0081] The release information of the instance object is recorded in a stack form.

[0082] In an optional implementation manner, the attribution module 340 is further configured to:

[0083] If the target release information is not found, determining at least one possible release time of the target instance object based on the logic code corresponding to the target instance object;

[0084] Based on the possible release timing, a reason for generating the zombie object is determined.

[0085] In an optional implementation manner, the device further includes a setting module, configured to:

[0086] When at least one optional release timing of the target instance object cannot be determined, the target instance object is set as an object to be detected, so that the release information of the target instance object is recorded when a release function call for the target instance object is monitored next time.

[0087] In an optional implementation manner, the recording module 320 is specifically used for:

[0088] In the case where the instance object is the object to be monitored, if the storage space occupied by the currently recorded release information is less than a preset threshold, the release information of the instance object is recorded.

[0089] In an optional implementation, the instance object is an object released by a main thread or a child thread of the iOS system.

[0090] In an optional implementation manner, the recording module 320 is further used to:

[0091] When it is detected that the zombie object is released, the stored release information of the target instance object corresponding to the zombie object is deleted.

[0092] The embodiment of the present disclosure records the release information of the instance object so that when a zombie object is detected, the recorded release information is used to determine the generation reason of the zombie object, thereby achieving the attribution of the zombie object.

[0093] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0094] Corresponds to Figure 1 The zombie object attribution method in the present disclosure also provides an electronic device 400, such as Figure 4 FIG. 4 is a schematic diagram of the structure of an electronic device 400 provided in an embodiment of the present disclosure, including:

[0095] Processor 41, memory 42, and bus 43; memory 42 is used to store execution instructions, including internal memory 421 and external memory 422; the internal memory 421 is also called internal memory, which is used to temporarily store the operation data in the processor 41 and the data exchanged with the external memory 422 such as a hard disk. The processor 41 exchanges data with the external memory 422 through the internal memory 421. When the electronic device 400 is running, the processor 41 communicates with the memory 42 through the bus 43, so that the processor 41 executes the following instructions:

[0096] In response to a release function call for an instance object, determining whether the instance object is an object to be monitored;

[0097] When the instance object is an object to be monitored, recording release information of the instance object;

[0098] In the case where a zombie object is detected, searching the recorded release information for target release information of a target instance object corresponding to the zombie object; wherein an accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released;

[0099] When the target release information is found, the generation reason of the zombie object is determined based on the target release information.

[0100] In an optional implementation manner, in the instruction executed by the processor 41, recording the release information of the instance object includes:

[0101] The release information of the instance object is recorded in a stack form.

[0102] In an optional implementation manner, the processor 41 is further configured to execute:

[0103] If the target release information is not found, determining at least one possible release time of the target instance object based on the logic code corresponding to the target instance object;

[0104] Based on the possible release timing, a reason for generating the zombie object is determined.

[0105] In an optional implementation manner, the processor 41 is further configured to execute:

[0106] When at least one optional release timing of the target instance object cannot be determined, the target instance object is set as an object to be detected, so that the release information of the target instance object is recorded when a release function call for the target instance object is monitored next time.

[0107] In an optional implementation manner, in the instruction executed by the processor 41, when the instance object is an object to be monitored, recording the release information of the instance object includes:

[0108] In the case where the instance object is the object to be monitored, if the storage space occupied by the currently recorded release information is less than a preset threshold, the release information of the instance object is recorded.

[0109] In an optional implementation, the instance object is an object released by a main thread or a child thread of the iOS system.

[0110] In an optional implementation manner, the processor 41 is further configured to execute:

[0111] When it is detected that the zombie object is released, the stored release information of the target instance object corresponding to the zombie object is deleted.

[0112] The present disclosure also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of the zombie object attribution method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0113] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the zombie object attribution method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0114] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0115] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0116] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0117] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0118] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0119] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A zombie object attribution method, characterized in that: include: In response to a release function call for an instance object, determining whether the instance object is an object to be monitored; In the case where the instance object is the object to be monitored, recording release information of the instance object, wherein the release information includes at least one of the time when the instance object is released, the object that calls the release function, and the code segment corresponding to the instance object; In the case where a zombie object is detected, searching the recorded release information for target release information of a target instance object corresponding to the zombie object; wherein an accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released; When the target release information is found, the generation reason of the zombie object is determined based on the target release information.

2. The method according to claim 1, characterized in that The recording of the release information of the instance object includes: The release information of the instance object is recorded in a stack form.

3. The method according to claim 1, characterized in that The method further comprises: If the target release information is not found, determining at least one possible release time of the target instance object based on the logic code corresponding to the target instance object; Based on the possible release timing, a reason for generating the zombie object is determined.

4. The method according to claim 3, characterized in that The method further comprises: When at least one optional release timing of the target instance object cannot be determined, the target instance object is set as an object to be detected, so that the release information of the target instance object is recorded when a release function call for the target instance object is monitored next time.

5. The method according to claim 1, characterized in that When the instance object is the object to be monitored, recording the release information of the instance object includes: In the case where the instance object is the object to be monitored, if the storage space occupied by the currently recorded release information is less than a preset threshold, the release information of the instance object is recorded.

6. The method according to claim 1, characterized in that The instance object is an object released by the main thread or child thread of the iOS system.

7. The method according to claim 1, characterized in that The method further comprises: When it is detected that the zombie object is released, the stored release information of the target instance object corresponding to the zombie object is deleted.

8. A zombie object attribution device, characterized in that: include: A response module, configured to determine whether the instance object is an object to be monitored in response to a release function call for the instance object; a recording module, configured to record release information of the instance object when the instance object is an object to be monitored, wherein the release information includes at least one of a time when the instance object is released, an object that calls the release function, and a code segment corresponding to the instance object; A search module, used for searching, when a zombie object is detected, target release information of a target instance object corresponding to the zombie object from the recorded release information; wherein the accessible instance object exists in the memory of the zombie object, and the memory corresponding to the zombie object has been released; The attribution module is used to determine the generation reason of the zombie object based on the target release information when the target release information is found.

9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the zombie object attribution method as described in any one of claims 1 to 7 are performed.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the zombie object attribution method according to any one of claims 1 to 7 are executed.

Citation Information

Patent Citations

  • Object release method and device, equipment, and storage medium

    CN110442404A

  • Memory leak detection method and device, electronic equipment and readable storage medium

    CN111506500A