CN110851279B - Memory leakage processing method, device, equipment and storage medium - Google Patents

Memory leakage processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN110851279B
CN110851279B CN201911101874.5A CN201911101874A CN110851279B CN 110851279 B CN110851279 B CN 110851279B CN 201911101874 A CN201911101874 A CN 201911101874A CN 110851279 B CN110851279 B CN 110851279B
Authority
CN
China
Prior art keywords
memory
time point
relation
relation set
pointer value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911101874.5A
Other languages
Chinese (zh)
Other versions
CN110851279A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201911101874.5A priority Critical patent/CN110851279B/en
Publication of CN110851279A publication Critical patent/CN110851279A/en
Application granted granted Critical
Publication of CN110851279B publication Critical patent/CN110851279B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • 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/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Quality & Reliability (AREA)
  • Storage Device Security (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a memory leakage processing method, device, equipment and storage medium, which are used for making up a short board which can not locate a memory leakage object when a weak reference table is manually maintained, and realizing accurate locating of the memory leakage object. The memory leakage processing method provided by the embodiment of the application comprises the following steps: acquiring memory information of at least one memory object, wherein the memory information comprises creation information; determining a first relation set, a second relation set and a third relation set of each memory object according to the creation information of each memory object, wherein each reference relation in the first relation set, the second relation set and the third relation set indicates that the memory object is referenced at a first time point, is referenced at a second time point and is referenced at a third time point respectively, the first time point is earlier than the second time point, and the second time point is earlier than the third time point; and determining a target object according to each reference relation in the first relation set, the second relation set and the third relation set.

Description

Memory leakage processing method, device, equipment and storage medium
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a memory leakage processing method, a memory leakage processing device, memory leakage processing equipment and a memory medium.
Background
In computer science, a memory leak refers to a situation in which a program fails to release memory that has been no longer used due to negligence or error. Memory leaks can reduce the performance of a computer by reducing the amount of available memory, and excessive allocation of available memory can cause all or a portion of the device to cease functioning properly, or an application program to crash. In general, only a programmer of program source code can analyze which memory is being compromised.
In order to find out the memory leak, a global weak reference table is maintained, namely, all created resource objects are placed in the same weak reference table, memory recovery (garbage collection, GC) is forced after the program is run, then the weak reference table is checked, and if a certain memory object is still stored in the weak reference table at this time, the memory object is referred to, so that the memory object is leaked.
However, in the prior art, by manually maintaining all created resource objects in the same weak reference table, only the discovery of memory leakage is realized, but the object generating the memory leakage cannot be clearly located, so that the object cannot be successfully released.
Disclosure of Invention
The embodiment of the application provides a memory leakage processing method, device, equipment and storage medium, which are used for realizing accurate positioning of a memory leakage object, successfully releasing the object and making up for a short board which cannot position the memory leakage and omits the object with the memory leakage when a weak reference table is manually maintained.
In a first aspect, an embodiment of the present application provides a method for processing memory leak, including:
acquiring memory information of at least one memory object, wherein the memory information comprises creation information;
determining a first relation set, a second relation set and a third relation set of each memory object according to the creation information of each memory object, wherein each reference relation in the first relation set indicates that the memory object is referenced at a first time point, each reference relation in the second relation set indicates that the memory object is referenced at a second time point, and each reference relation in the third relation set indicates that the memory object is referenced at a third time point, the first time point is earlier than the second time point, and the second time point is earlier than the third time point;
And determining a target object according to each reference relation in the first relation set, each reference relation in the second relation set and each reference relation in the third relation set, wherein the target object is an object with memory leakage.
In a second aspect, an embodiment of the present application provides a device for processing memory leak, where the device for processing memory leak includes:
the memory information acquisition unit is used for acquiring memory information of at least one memory object, wherein the memory information comprises creation information;
a first determining unit, configured to determine, according to the creation information of each memory object acquired by the acquiring unit, a first relationship set, a second relationship set, and a third relationship set of each memory object, where each reference relationship in the first relationship set indicates that the memory object is referenced at a first time point, each reference relationship in the second relationship set indicates that the memory object is referenced at a second time point, and each reference relationship in the third relationship set indicates that the memory object is referenced at a third time point, and the first time point is earlier than the second time point, and the second time point is earlier than the third time point;
The second determining unit is configured to determine a target object according to each reference relationship in the first relationship set, each reference relationship in the second relationship set, and each reference relationship in the third relationship set, where the target object is an object with memory leak.
With reference to the second aspect, in a first possible implementation manner, the second determining unit includes:
the determining module is used for determining a target relation set from the first relation set, the first relation set and the third relation set according to a preset rule;
the determining module is configured to determine a memory object referenced by each reference relationship in the target relationship set as a target object.
With reference to the second aspect or the first possible manner of the second aspect, in a second possible manner, the first determining unit includes:
the traversing module is configured to traverse the creation information of each memory object at the first time point, the second time point and the third time point, so as to obtain a first object pointer value, a second object pointer value and a third object pointer value of each memory object respectively;
The generating module is used for generating the first relation set by at least one reference relation indicated by the first object pointer value, generating the second relation set by at least one reference relation indicated by the second object pointer value and generating the third relation set by at least one reference relation indicated by the third object pointer value.
With reference to the second possible manner of the second aspect, in a third possible implementation manner, the traversing module includes:
the acquisition sub-module is used for acquiring a registry in each type according to the object type, wherein the registry comprises at least one meta-table;
and the traversing sub-module is used for traversing the creation information of the memory object at the first time point through a first object function to obtain the first object pointer value, traversing the creation information of the memory object at the second time point through the first object function to obtain the second object pointer value and traversing the creation information of the memory object at the third time point through the first object function to obtain the third object pointer value when the meta table acquired by the acquiring sub-module is not the weak reference table.
In a third aspect, an embodiment of the present application provides a computer apparatus, including:
comprising the following steps: input/output (I/O) interfaces, a processor and memory,
program instructions are stored in the memory;
the processor is configured to execute program instructions stored in the memory for implementing a method as described above in any one of the possible implementations of the first aspect.
A fourth aspect of the application provides a computer readable storage medium having stored therein computer executable instructions for performing a method as in any one of the possible implementations of the first aspect.
A fifth aspect of an embodiment of the application provides a computer program product comprising instructions which, when run on a computer or processor, cause the computer or processor to perform the method of any of the above aspects.
From the above technical solutions, the embodiment of the present application has the following advantages:
in the embodiment of the application, the first relation set, the second relation set and the third relation set of each memory object are determined according to the creation information, and each reference relation in the first relation set indicates that the memory object is referenced at the first time point, each reference relation in the second relation set indicates that the memory object is referenced at the second time point, and each reference relation in the third relation set also indicates that the memory object is referenced at the third time point.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an architecture provided in an embodiment of the present application;
FIG. 2 is a schematic diagram of an embodiment of a method for handling memory leaks according to an embodiment of the present application;
FIG. 3 is a flow chart of traversal of object types provided in an embodiment of the application;
FIG. 4 is a schematic diagram of traversing creation information of a table-type memory object provided in an embodiment of the present application;
FIG. 5 is a schematic diagram of another embodiment of a method for handling memory leaks according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a memory snapshot provided in an embodiment of the present application;
FIG. 7 is a diagram of a comparative memory snapshot provided in an embodiment of the present application;
FIG. 8 is a diagram showing the results of a target object in an embodiment of the present application;
FIG. 9 is a schematic diagram of an embodiment of a processing apparatus for memory leak according to an embodiment of the present application;
FIG. 10 is a schematic diagram of another embodiment of a memory leak processing apparatus according to the present application;
fig. 11 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The embodiment of the application provides a memory leakage processing method, device, equipment and storage medium, which are used for realizing accurate positioning of a memory leakage object, successfully releasing the object and making up for a short board which cannot position the memory leakage and omits the object with the memory leakage when a weak reference table is manually maintained.
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terms "first," "second," "third," "fourth" and the like in the description and in the claims and in the above drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. The naming or numbering of the steps in the present application does not mean that the steps in the method flow must be executed according to the time/logic sequence indicated by the naming or numbering, and the execution sequence of the steps in the flow that are named or numbered may be changed according to the technical purpose to be achieved, so long as the same or similar technical effects can be achieved.
The application scenario adapted to the embodiment of the present application is described below:
the method provided by the embodiment of the application is mainly applied to the application scene of the Lua script running environment, for example: and positioning the memory leakage at the game client, and the like. Based on the application scenario, the architecture proposed in the embodiment of the present application is shown in fig. 1, and the architecture mainly includes a client, for example: game clients, web page clients, and so forth. The client determines the reference relation of each memory object at different time points based on the created information of each memory object, so that the object with the memory leakage is positioned according to the reference relation.
It should be understood that the client described above may be installed on a terminal device. The "terminal device" used, also called User Equipment (UE), mobile Station (MS), mobile Terminal (MT), terminal, etc., is a device that provides voice and/or data connectivity to a user, or a chip disposed within the device, such as a handheld device, a vehicle-mounted device, etc., with wireless connection capability. Currently, examples of some terminal devices are: a mobile phone, a tablet, a notebook, a palm, a mobile internet device (mobile internet device, MID), a wearable device, a Virtual Reality (VR) device, an augmented reality (augmented reality, AR) device, a wireless terminal in industrial control (industrial control), a wireless terminal in unmanned (self driving), a wireless terminal in teleoperation (remote medical surgery), a wireless terminal in smart grid (smart grid), a wireless terminal in transportation security (transportation safety), a wireless terminal in smart city (smart city), a wireless terminal in smart home (smart home), and the like. The terminal device provided by the embodiment of the application can be a low-complexity terminal device and/or a terminal device in a coverage enhancement A mode and the like.
The method for processing memory leak in this embodiment may be applicable to other system architectures besides the system architecture shown in fig. 1, and is not limited herein.
In order to better understand the solution proposed by the embodiment of the present application, a specific flow in this embodiment is described below, and as shown in fig. 2, an embodiment of a method for processing memory leakage provided by the embodiment of the present application is shown schematically, where the method includes:
201. memory information of at least one memory object is acquired, wherein the memory information comprises creation information.
In this embodiment, the object refers to a section of area on the memory, and the memory information may be used to represent information of a memory creation or release record of the object, and specifically, the memory information of each object may include creation information of all memories that have already been created or creation information of memories to be created. It should be understood that the creation information of the memory, whether already created or to be created, is generated after the terminal device or the server receives the creation request message input by the user. For example: when the user wants to purchase the product A from the XX shopping APP, and at the moment, the user needs to open the XX shopping APP and input the product A, the terminal device receives the creation request message, and accordingly creates corresponding creation information according to the creation request message and stores the creation information in the memory information.
The memory objects described above may refer to combat objects, game characters, players, objects, etc. in a game scene, and may include objects in other scenes in practical applications, which are not limited herein.
202. And determining a first relation set, a second relation set and a third relation set of each memory object according to the creation information of each memory object, wherein each reference relation in the first relation set indicates that the memory object is referenced at a first time point, each reference relation in the second relation set indicates that the memory object is referenced at a second time point, and each reference relation in the third relation set indicates that the memory object is referenced at a third time point, the first time point is earlier than the second time point, and the second time point is earlier than the third time point.
In this embodiment, the first relationship set may include one or more reference relationships, where each reference relationship indicates that the memory object is externally referenced to the reference at the first point in time, so that the memory object is not completely released at the first point in time; after the first point in time, the second set of relationships may also include one or more reference relationships, each reference relationship indicating that the memory object was externally referenced to the reference at the second point in time, such that the memory object is not completely freed at the second point in time; likewise, after the second point in time, the third set of relationships may also include one or more reference relationships, each indicating that the memory object was externally referenced to the reference at the third point in time, such that the memory object is not completely freed at the third point in time.
It should be understood that, the first relationship set, the second relationship set and the third relationship set described above are respectively used for snapshot the creation information of each memory object in a memory snapshot manner at the first time point, the second time point and the third time point, and after snapshot the creation information of each memory object, the reference relationship corresponding to each memory object is obtained correspondingly, that is, the memory object has a reference relationship with external references, and the memory object with memory leakage can be located and found through the reference relationship of the memory objects at a plurality of different time points.
It will be appreciated that the first point in time described above may be some point in time before entering the XXXX scene, while the second point in time may be some point in time after entering the XXXX scene and before not exiting the XXXX scene, while the third point in time is some point in time after exiting the XXXX scene.
For example: in the game scene of the A hand game or the B hand game, the first time point is before entering the game scene of the A hand game or the B hand game, the second time point is in the game scene of the A hand game or the B hand game, and the third time point is after the game scene of the A hand game or the B hand game is finished. In practical applications, the first time point, the second time point and the third time point should also include, but are not limited to, time points of the game scene of the a-hand game or the B-hand game, which are not specifically limited in the embodiments of the present application.
Alternatively, in some embodiments, the determination of the set of relationships may be done in such a way that:
traversing the creation information of each memory object at the first time point, the second time point and the third time point to obtain a first object pointer value, a second object pointer value and a third object pointer value of each memory object respectively; generating the first relation set by at least one reference relation indicated by the first object pointer value, generating the second relation set by at least one reference relation indicated by the second object pointer value, and generating the third relation set by at least one reference relation indicated by the third object pointer value.
In this embodiment, since each memory object has an object pointer key corresponding to the object pointer key, and the object pointer value corresponding to the object pointer key is at least one reference relation describing the referenced corresponding memory object in sufficient detail, the created information of each memory object can be traversed, so that the corresponding object pointer value can be obtained. Thus, after the first object pointer value is obtained at the first time point, the first relation set can be generated by at least one reference relation indicated by the first object pointer value; similarly, after the second object pointer value is obtained at the second time point, the second relation set may be generated by at least one reference relation indicated by the second object pointer value, and after the third object pointer value is obtained at the third time point, the third relation set may be generated by at least one reference relation indicated by the third object pointer value.
Alternatively, based on the optional embodiments described above, in other embodiments, the following manner may be used for how to traverse the object pointer value, namely:
acquiring a registry in each type according to the object type, wherein the registry comprises at least one meta-table; when the meta table is not a weak reference table, traversing the creation information of the memory object at the first time point through a first object function to obtain the first object pointer value, traversing the creation information of the memory object at the second time point through the first object function to obtain the second object pointer value, and traversing the creation information of the memory object at the third time point through the first object function to obtain the third object pointer value.
In this embodiment, the object types may include, but are not limited to, a table type, a user data type, a run data type, or a thread type. Since the memory objects can be distinguished by the object types, and the memory objects of different types can be traversed by different type functions, refer to fig. 3, which is a flowchart for traversing the object types according to the embodiment of the present application. As can be seen from fig. 3, the creation information of the table type memory object may be traversed by the mark_table () function, the creation information of the user data type memory object may be traversed by the mark_userdata () function, the creation information of the operation data type memory object may be traversed by the mark_function () function, and the creation information of the thread type memory object may be traversed by the mark_thread () function. In addition, as can be seen from fig. 3, it is possible to determine the object type, and if the object type is not the creation information of the memory object of the corresponding object type, enter the traversal process of the next object type. Such as: whether the table type is the table type can be judged firstly, if the table type is the table type, the mark_table () function is utilized to traverse the creation information of the memory object of the table type; if the user data type is not the table type, judging whether the user data type is the user data type, if so, traversing the creation information of the memory object of the user data type by using a mark_userdata () function; if the data type is not the user data type, judging whether the data type is the operation data type, if the data type is the operation data type, traversing the creation information of the memory object of the operation data type by using a mark_function () function; if the thread type is not the running data type, judging whether the thread type is the thread type, if the thread type is the thread data type, traversing the creation information of the memory object of the thread type by using a mark_thread () function; if not, the next traversal of the memory object is entered. It should be understood that, in practical applications, the object type traversal order of the different types of memory objects is not limited in the embodiments of the present application.
For a certain type of memory object, a global registry of the type may be obtained, wherein the registry comprises at least one meta-table. The registry is deeply traversed through the corresponding object type function, whether the meta-table is a weak reference table can be judged, and when the meta-table is not the weak reference table, the created information of the memory object in the meta-table can be traversed according to the first object function, so that the object pointer value is obtained. Therefore, the first object pointer value is obtained by traversing the creation information of the memory object at the first time point by the first object function, the second object pointer value is obtained by traversing the creation information of the memory object at the second time point by the first object function, and the third object pointer value is obtained by traversing the creation information of the memory object at the third time point by the first object function.
For example: in the embodiment of the present application, taking a table type as an example, please refer to fig. 4, which is a schematic diagram illustrating traversing of creation information of a table type memory object provided in the embodiment of the present application.
As can be seen from fig. 4, with respect to the table type, the registry is traversed deeply by the object type function mark_table, so that it can be determined whether the meta-table metadata is a weak reference table, and when the meta-table is not a weak reference table, the created information of the memory object in the meta-table can be traversed according to the first object function mark_object, specifically, the object pointer key of the memory object is traversed by the mark_object, and then the value pointed by each object pointer key is traversed, so that the object pointer value can be obtained. It should be understood that, in practical application, the creation information of the memory object may also be traversed by a breadth-first algorithm, and the like, and in particular, the embodiment will not be limited in detail.
203. And determining a target object according to each reference relation in the first relation set, each reference relation in the second relation set and each reference relation in the third relation set, wherein the target object is an object with memory leakage.
In this embodiment, since the first relationship set, the second relationship set, and the third relationship set each include at least one reference relationship, and each reference relationship in the three relationship sets may be the same or different, that is, it is understood that each reference relationship in the first relationship set may be the same or different from each reference relationship in the second relationship set and each reference relationship in the third relationship set, which is not specifically limited in the embodiment of the present application. The target object can be determined from the reference relationships in the relationship set determined at the different time points, namely, the memory object with the memory leak is positioned and found.
In order to better understand the solution proposed by the embodiment of the present application, a specific flow in this embodiment is described below, and as shown in fig. 5, another embodiment of a method for processing memory leakage provided by the embodiment of the present application is shown, where the method includes:
501. memory information of at least one memory object is obtained, wherein the memory information comprises creation information.
502. Determining a first relation set, a second relation set and a third relation set of each memory object according to the creation information of each memory object, wherein each reference relation in the first relation set indicates that the memory object is referenced at a first time point, each reference relation in the second relation set indicates that the memory object is referenced at a second time point, and each reference relation in the third relation set indicates that the memory object is referenced at a third time point, the first time point is earlier than the second time point, and the second time point is earlier than the third time point.
In this embodiment, steps 501-502 are similar to steps 201-202 described in fig. 2, and detailed descriptions thereof are omitted herein.
503. Determining a target relation set from the first relation set, the first relation set and the third relation set according to a preset rule;
In this embodiment, the preset rule is a condition defined by the user in order to accurately locate the object of the memory leak from the first relationship set, the second relationship set and the third relationship set.
Specifically, the preset rule may be an intersection with the second relationship set based on a difference set between the third relationship set and the first relationship set, and the mathematical expression may be: (S3-S1). AndS 2, wherein S1 is a first set of relationships, S2 is a second set of relationships, and S3 is a third set of relationships. The meaning of this mathematical expression is to indicate that the reference relationship exists in S3, and not in S1, and in S2. The purpose of this is to avoid creating new creation information for some memory objects after the third time point, where the creation information is not present in the second time point and the third time point, and if the memory objects corresponding to the new creation information are not excluded, they are easily confused with the memory objects leaking from the memory to be located, and the accuracy of the location cannot be improved.
For example: in the game scene of the hand-tour, assuming that the first relation set s1= { a1, a2, a3, a4, a5, a6} obtained at the first time point, the second relation set s2= { a3, a5, a9, a10, b1, b2} obtained at the second time point, and the third relation set s3= { a3, a5, a7, a10, b1, b3} obtained at the third time point, the target set { a10, b1} can be obtained easily, and the memory object corresponding to the reference relation a10 and b1 at this time is the target object. It should be understood that the above-described reference relationships S1, S2, S3 are only an example, and other reference relationships x, y, etc. may be included in practical applications, which are not specifically limited in the embodiments of the present application.
504. And determining the memory object referenced by each reference relation in the target relation set as a target object.
Each reference relationship in the target relationship set indicates that the corresponding memory object is referenced by the outside, and the corresponding memory cannot be completely released, so that the memory object referenced by each reference relationship in the target set can be taken as the target object.
It should be noted that, since the first relationship set, the second relationship set, and the third relationship set are described above, the creation information of each memory object is snapshot in a memory snapshot manner at the first time point, the second time point, and the third time point, respectively. Fig. 6 is a schematic diagram of a memory snapshot according to an embodiment of the application. Specifically, a memory snapshot S1 may be completed by clicking the "snapshot button" at a first time point, a memory snapshot S2 may be completed by clicking the "snapshot button" at a second time point, and a memory snapshot S3 may be completed by clicking the "snapshot button" at a third time point. Fig. 7 is a schematic diagram of a comparative memory snapshot according to an embodiment of the present application. After three memory snapshots are obtained, clicking the contrast button can automatically display the target object in the target relation set.
It will be appreciated that the determined target object may exhibit the corresponding data result through a Windows window. Referring to fig. 8, a diagram of a result of a target object according to an embodiment of the application is shown. As can be seen from fig. 8, the result display diagram shows a target relationship set, and the target relationship set includes a plurality of target objects that cannot be completely released from the corresponding memory, for example: the target object of ' 9307C7D8 ' is still referenced by ' table ox97fcdd28: [ upvalue ]. In addition, in practical application, the target object can be displayed through a web page.
In the embodiment of the application, the first relation set, the second relation set and the third relation set of each memory object are determined according to the creation information, and each reference relation in the first relation set indicates that the memory object is referenced at the first time point, each reference relation in the second relation set indicates that the memory object is referenced at the second time point, and each reference relation in the third relation set also indicates that the memory object is referenced at the third time point.
The foregoing description of the solution provided by the embodiments of the present application has been mainly presented in terms of a method. It should be understood that, in order to implement the above-described functions, hardware structures and/or software modules corresponding to the respective functions are included. Those of skill in the art will readily appreciate that the various illustrative modules and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the application can divide the functional modules of the device according to the method example, for example, each functional module can be divided corresponding to each function, and two or more functions can be integrated in one processing module. The integrated modules may be implemented in hardware or in software functional modules. It should be noted that, in the embodiment of the present application, the division of the modules is schematic, which is merely a logic function division, and other division manners may be implemented in actual implementation.
Referring to fig. 9 for a detailed description of the processing apparatus 90 for memory leak in the embodiment of the present application, fig. 9 is a schematic diagram of an embodiment of the processing apparatus 90 for memory leak in the embodiment of the present application, where the processing apparatus 90 for memory leak may include:
an obtaining unit 901, configured to obtain memory information of at least one memory object, where the memory information includes creation information;
a first determining unit 902, configured to determine, according to the creation information of each memory object acquired by the acquiring unit 901, a first relationship set, a second relationship set, and a third relationship set of each memory object, where each reference relationship in the first relationship set indicates that the memory object is referenced at a first time point, each reference relationship in the second relationship set indicates that the memory object is referenced at a second time point, and each reference relationship in the third relationship set indicates that the memory object is referenced at a third time point, and the first time point is earlier than the second time point, and the second time point is earlier than the third time point;
a second determining unit 903, configured to determine a target object according to each reference relationship in the first relationship set, each reference relationship in the second relationship set, and each reference relationship in the third relationship set determined by the first determining unit 902, where the target object is an object of memory leak.
Optionally, referring to fig. 10 on the basis of the embodiment corresponding to fig. 9, in another embodiment of the processing apparatus 90 for memory leak provided in the embodiment of the present application, the second determining unit 903 includes:
a determining module 9031, configured to determine a target relationship set from the first relationship set, and the third relationship set according to a preset rule;
the determining module 9031 is configured to determine, as a target object, a memory object referenced by each reference relationship in the target relationship set.
Optionally, on the basis of the embodiments corresponding to fig. 9 and fig. 10, in another embodiment of the processing apparatus 90 for memory leak provided in the embodiment of the present application, the first determining unit 902 includes:
the traversing module is configured to traverse the creation information of each memory object at the first time point, the second time point and the third time point, so as to obtain a first object pointer value, a second object pointer value and a third object pointer value of each memory object respectively;
the generating module is used for generating the first relation set by at least one reference relation indicated by the first object pointer value, generating the second relation set by at least one reference relation indicated by the second object pointer value and generating the third relation set by at least one reference relation indicated by the third object pointer value.
Optionally, based on the optional embodiments corresponding to fig. 9 and fig. 10, in another embodiment of the processing apparatus 90 for memory leak provided in the embodiment of the present application, the traversing module includes:
the acquisition sub-module is used for acquiring a registry in each type according to the object type, wherein the registry comprises at least one meta-table;
and the traversing sub-module is used for traversing the creation information of the memory object at the first time point through a first object function to obtain the first object pointer value, traversing the creation information of the memory object at the second time point through the first object function to obtain the second object pointer value and traversing the creation information of the memory object at the third time point through the first object function to obtain the third object pointer value when the meta table acquired by the acquiring sub-module is not the weak reference table.
In the embodiment of the present application, the acquiring unit 901 acquires the creation information of each memory object, and the first determining unit 902 determines the first relationship set, the second relationship set and the third relationship set of each memory object according to the creation information, where each reference relationship in the first relationship set indicates that the memory object is referenced at the first time point, each reference relationship in the second relationship set indicates that the memory object is referenced at the second time point, and each reference relationship in the third relationship set also indicates that the memory object is referenced at the third time point, and since the first time point is earlier than the second time point, the second time point is earlier than the third time point, so that the target object, which finally still has the reference relationship, can be determined through the difference set and the intersection set between the relationship sets of different time points, the object with memory leak can be accurately located, and the object with memory leak can be successfully released, so that the short board of the object with memory leak unable to be located when the weak reference table is manually maintained is made up.
The processing apparatus 90 for memory leak in the embodiment of the present application is described above from the point of view of modularized functional entities, and the computer device in the embodiment of the present application is described below from the point of view of hardware processing. Fig. 11 is a schematic structural diagram of a computer device according to an embodiment of the present application, where the computer device may include the processing apparatus 90 for memory leakage described above, and the computer device may have a large difference due to different configurations or performances, and may include at least one processor 1001, a communication line 1007, a memory 1003, and at least one communication interface 1004.
The processor 1001 may be a general purpose central processing unit (central processing unit, CPU), microprocessor, application-specific integrated circuit (server IC), or one or more integrated circuits for controlling the execution of the program of the present application.
Communication line 1007 may include a pathway to transfer information between the components.
Communication interface 1004, a device using any transceiver or the like for communicating with other devices or communication networks, such as ethernet, radio access network (radio access network, RAN), wireless local area network (wireless local area networks, WLAN), etc.
The memory 1003 may be a read-only memory (ROM) or other type of static storage device that may store static information and instructions, a random access memory (random access memory, RAM) or other type of dynamic storage device that may store information and instructions, and the memory may be stand alone and coupled to the processor via a communication line 1007. The memory may also be integrated with the processor.
The memory 1003 is used for storing computer-executable instructions for executing the present application, and is controlled to be executed by the processor 1001. The processor 1001 is configured to execute computer-executable instructions stored in the memory 1003, thereby implementing the method for processing memory leak provided in the above embodiment of the present application.
Alternatively, the computer-executable instructions in the embodiments of the present application may be referred to as application program codes, which are not particularly limited in the embodiments of the present application.
In a particular implementation, the computer device may include multiple processors, such as processor 1001 and processor 1002 in FIG. 11, as an embodiment. Each of these processors may be a single-core (single-CPU) processor or may be a multi-core (multi-CPU) processor. A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
In a specific implementation, the computer device can also include an output device 1005 and an input device 1006, as one embodiment. The output device 1005 communicates with the processor 1001 and may display information in a variety of ways. The input device 1006 is in communication with the processor 1001 and may receive user input in a variety of ways. For example, the input device 1006 may be a mouse, a touch screen device, a sensing device, or the like.
The computer apparatus may be a general-purpose device or a special-purpose device. In a specific implementation, the computer device may be a desktop, a laptop, a nas server, a wireless terminal apparatus, an embedded apparatus, or an apparatus having a similar structure as in fig. 11. The embodiments of the present application are not limited to the type of computer device.
In an embodiment of the present application, the processor 1001 included in the computer device further has the following functions:
acquiring memory information of at least one memory object, wherein the memory information comprises creation information;
determining a first relation set, a second relation set and a third relation set of each memory object according to the creation information of each memory object, wherein each reference relation in the first relation set indicates that the memory object is referenced at a first time point, each reference relation in the second relation set indicates that the memory object is referenced at a second time point, and each reference relation in the third relation set indicates that the memory object is referenced at a third time point, the first time point is earlier than the second time point, and the second time point is earlier than the third time point;
And determining a target object according to each reference relation in the first relation set, each reference relation in the second relation set and each reference relation in the third relation set, wherein the target object is an object with memory leakage.
Alternatively, in some embodiments of the application, the processor 1001 may be further specifically configured to,
determining a target relation set from the first relation set, the first relation set and the third relation set according to a preset rule;
and determining the memory object referenced by each reference relation in the target relation set as a target object.
Alternatively, in some embodiments of the application, the processor 1001 may also be used,
traversing the creation information of each memory object at the first time point, the second time point and the third time point to obtain a first object pointer value, a second object pointer value and a third object pointer value of each memory object respectively;
generating the first relation set by at least one reference relation indicated by the first object pointer value, generating the second relation set by at least one reference relation indicated by the second object pointer value, and generating the third relation set by at least one reference relation indicated by the third object pointer value.
Alternatively, in some embodiments of the application, the processor 1001 may be further specifically configured to,
acquiring a registry in each type according to the object type, wherein the registry comprises at least one meta-table;
when the meta table is not a weak reference table, traversing the creation information of the memory object at the first time point through a first object function to obtain the first object pointer value, traversing the creation information of the memory object at the second time point through the first object function to obtain the second object pointer value, and traversing the creation information of the memory object at the third time point through the first object function to obtain the third object pointer value.
Optionally, in some embodiments of the present application, the processor 1001 may be further specifically configured to use an object type including a table type, a user data type, a running data type, or a thread type.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of 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.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method of the various embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a read-only memory (ROM), a random access memory (random access memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. The memory leakage processing method is characterized by comprising the following steps:
acquiring memory information of at least one memory object, wherein the memory information comprises creation information;
determining a first relation set, a second relation set and a third relation set of each memory object according to the creation information of each memory object, wherein each reference relation in the first relation set indicates that the memory object is referenced at a first time point, each reference relation in the second relation set indicates that the memory object is referenced at a second time point, and each reference relation in the third relation set indicates that the memory object is referenced at a third time point, the first time point is earlier than the second time point, and the second time point is earlier than the third time point;
determining a target relation set from the first relation set, the first relation set and the third relation set according to a preset rule; the preset rule is a condition defined for accurately positioning the object with memory leakage from the first relation set, the second relation set and the third relation set;
and determining the memory object referenced by each reference relation in the target relation set as a target object, wherein the target object is an object of memory leakage.
2. The method of claim 1, wherein determining the first, second, and third sets of relationships for each memory object based on the creation information for each memory object comprises:
traversing the creation information of each memory object at the first time point, the second time point and the third time point to obtain a first object pointer value, a second object pointer value and a third object pointer value of each memory object respectively;
generating the first relation set by at least one reference relation indicated by the first object pointer value, generating the second relation set by at least one reference relation indicated by the second object pointer value, and generating the third relation set by at least one reference relation indicated by the third object pointer value.
3. The method of claim 2, wherein traversing the creation information of each memory object at the first point in time, the second point in time, and the third point in time to obtain the first object pointer value, the second object pointer value, and the third object pointer value of each memory object, respectively, comprises:
Acquiring a registry in each type according to the object type, wherein the registry comprises at least one meta-table;
when the meta table is not a weak reference table, traversing the creation information of the memory object at the first time point through a first object function to obtain the first object pointer value, traversing the creation information of the memory object at the second time point through the first object function to obtain the second object pointer value, and traversing the creation information of the memory object at the third time point through the first object function to obtain the third object pointer value.
4. A method according to claim 3, wherein the object type comprises a table type, a user data type, a run data type, or a thread type.
5. A processing device for memory leakage is characterized in that,
the memory management device comprises an acquisition unit, a memory management unit and a memory management unit, wherein the acquisition unit is used for acquiring memory information of at least one memory object, and the memory information comprises creation information;
a first determining unit, configured to determine, according to the creation information of each memory object acquired by the acquiring unit, a first relationship set, a second relationship set, and a third relationship set of each memory object, where each reference relationship in the first relationship set indicates that the memory object is referenced at a first time point, each reference relationship in the second relationship set indicates that the memory object is referenced at a second time point, and each reference relationship in the third relationship set indicates that the memory object is referenced at a third time point, and the first time point is earlier than the second time point, and the second time point is earlier than the third time point;
The second determining unit is used for determining a target relation set from the first relation set, the first relation set and the third relation set according to a preset rule; the preset rule is a condition defined for accurately positioning the object with memory leakage from the first relation set, the second relation set and the third relation set; and determining the memory object referenced by each reference relation in the target relation set as a target object, wherein the target object is an object of memory leakage.
6. The processing apparatus according to claim 5, wherein the first determination unit includes:
the traversing module is configured to traverse the creation information of each memory object at the first time point, the second time point and the third time point, so as to obtain a first object pointer value, a second object pointer value and a third object pointer value of each memory object respectively;
the generating module is used for generating the first relation set by at least one reference relation indicated by the first object pointer value, generating the second relation set by at least one reference relation indicated by the second object pointer value and generating the third relation set by at least one reference relation indicated by the third object pointer value.
7. The apparatus of claim 6, wherein the traversal module comprises:
the acquisition sub-module is used for acquiring a registry in each type according to the object type, wherein the registry comprises at least one meta-table;
and a traversing sub-module, configured to traverse, when the meta table is not a weak reference table, the creation information of the memory object at the first time point through a first object function to obtain the first object pointer value, traverse, at the second time point through the first object function, the creation information of the memory object to obtain the second object pointer value, and traverse, at the third time point through the first object function, the creation information of the memory object to obtain the third object pointer value.
8. The apparatus of claim 7, wherein the object type comprises a table type, a user data type, a run data type, or a thread type.
9. A computer device, the computer device comprising: input/output (I/O) interfaces, a processor and memory,
program instructions are stored in the memory;
the processor is configured to execute program instructions stored in a memory and to perform the method of any one of claims 1 to 4.
10. A computer readable storage medium comprising instructions which, when run on a computer device, cause the computer device to perform the method of any of claims 1 to 4.
CN201911101874.5A 2019-11-12 2019-11-12 Memory leakage processing method, device, equipment and storage medium Active CN110851279B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911101874.5A CN110851279B (en) 2019-11-12 2019-11-12 Memory leakage processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911101874.5A CN110851279B (en) 2019-11-12 2019-11-12 Memory leakage processing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110851279A CN110851279A (en) 2020-02-28
CN110851279B true CN110851279B (en) 2023-10-13

Family

ID=69600537

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911101874.5A Active CN110851279B (en) 2019-11-12 2019-11-12 Memory leakage processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110851279B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110276833A1 (en) * 2010-05-04 2011-11-10 Oracle International Corporation Statistical analysis of heap dynamics for memory leak investigations
CN107992429A (en) * 2016-10-27 2018-05-04 腾讯科技(深圳)有限公司 A kind of memory object adduction relationship determines method and device
CN108845934A (en) * 2018-05-24 2018-11-20 深圳市腾讯网络信息技术有限公司 The localization method and device in memory overflow source, storage medium, electronic device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110276833A1 (en) * 2010-05-04 2011-11-10 Oracle International Corporation Statistical analysis of heap dynamics for memory leak investigations
CN107992429A (en) * 2016-10-27 2018-05-04 腾讯科技(深圳)有限公司 A kind of memory object adduction relationship determines method and device
CN108845934A (en) * 2018-05-24 2018-11-20 深圳市腾讯网络信息技术有限公司 The localization method and device in memory overflow source, storage medium, electronic device

Also Published As

Publication number Publication date
CN110851279A (en) 2020-02-28

Similar Documents

Publication Publication Date Title
US9519401B2 (en) Providing context menu based on predicted commands
US9678680B1 (en) Forming a protection domain in a storage architecture
EP3937016A1 (en) Memory management method and apparatus
CN111506386A (en) Virtual machine online migration method, device, equipment and computer readable storage medium
CN110908865A (en) Memory leakage monitoring method and device and electronic equipment
CN106873960A (en) The update method and equipment of a kind of application software
CA2982272C (en) Automatic task tracking
CN106776342B (en) Method and device for analyzing memory object of mobile application
US10114731B2 (en) Including kernel object information in a user dump
US20180293437A1 (en) Capture object boundary jitter reduction
US9924002B1 (en) Managing stateless processes
CN110851279B (en) Memory leakage processing method, device, equipment and storage medium
CN111753330B (en) Determination method, apparatus, device and readable storage medium for data leakage main body
JP2023553220A (en) Process mining for multi-instance processes
CN108491457A (en) A kind of method and apparatus for synchronizing public cloud resource
EP3309657A1 (en) Role-based provision of virtual reality environment
CN108829391A (en) Control recognition methods and system in a kind of Fragment
CN109710609B (en) Method and device for generating data table identification
CN113420288B (en) Container mirror image sensitive information detection system and method
CN112487414B (en) Method, device, equipment and storage medium for acquiring process command line
CN107370785B (en) Method and equipment for processing user service state information
CN110825477A (en) Method, device and equipment for loading graphical interface and storage medium
CN104808985B (en) The management method and device of object in application program
US9838488B2 (en) Agent asynchronous transaction monitor
CN117459401B (en) Method, device, equipment and storage medium for generating network target range environment snapshot

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40021601

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant