CN111352734A - Memory leak detection method and memory management module - Google Patents

Memory leak detection method and memory management module Download PDF

Info

Publication number
CN111352734A
CN111352734A CN202010121573.5A CN202010121573A CN111352734A CN 111352734 A CN111352734 A CN 111352734A CN 202010121573 A CN202010121573 A CN 202010121573A CN 111352734 A CN111352734 A CN 111352734A
Authority
CN
China
Prior art keywords
memory
layer
current
management module
memories
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.)
Pending
Application number
CN202010121573.5A
Other languages
Chinese (zh)
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.)
Fiberhome Telecommunication Technologies Co Ltd
Original Assignee
Fiberhome Telecommunication Technologies 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 Fiberhome Telecommunication Technologies Co Ltd filed Critical Fiberhome Telecommunication Technologies Co Ltd
Priority to CN202010121573.5A priority Critical patent/CN111352734A/en
Publication of CN111352734A publication Critical patent/CN111352734A/en
Pending legal-status Critical Current

Links

Images

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/5016Allocation 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 the resource being the memory
    • 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/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics

Abstract

The embodiment of the invention provides a memory leak detection method and a memory management module, wherein the method comprises the following steps: adding a digital sequence number identifier in the memory, wherein the digital sequence number identifier is used for associating the upper-layer memory with the lower-layer memory; acquiring the lower-layer memory quantity related to the current memory in the memory management module based on the digital serial number identifier; and if the quantity of the lower-layer memories associated with the current memories in the memory management module is not equal to the statistical quantity of the service data modules, confirming that the lower-layer memories associated with the current memories have memory leakage. In the memory leak detection method and the memory management module provided by the embodiments of the present invention, the serial number identifier is added to the memory, and the upper and lower layer associations between the memories are determined by using the serial number identifier. Therefore, the data are verified with the incidence relation among the data in the service program, and whether the memory leakage condition occurs or not is accurately detected.

Description

Memory leak detection method and memory management module
Technical Field
The invention relates to the technical field of telecommunication system software, in particular to a memory leak detection method and a memory management module.
Background
The C language is a program development language capable of being executed efficiently, but the C language programming has a common problem of memory leakage, and the memory occupation amount of a process with the memory leakage will increase continuously until a system has no available memory. Memory leak, that is, a software program applies for a memory in the running process, and when the memory is not used any longer, the memory is not normally released, but the memory is not in the data structure in the service program, that is, the service program cannot find and no longer uses the memory, but for the operating system, the memory is still occupied by the service program and is not released, and as a result, the operating system marks the memory as being occupied all the time, and the service program may generate more and more memory leaks until the memory of the light-consuming system does not have an applicable memory any more.
In the prior art, a common method for detecting memory leakage is to interrupt all current services, release a memory that is not leaked by a service program, leave a memory that is not released or leaked, detect a service code to which the leaked memory belongs, check a possible place in the code where the memory is forgotten to be released, modify the code, and recompile and rerun the program. Such a method is generally performed in a test activity at a development stage, and if software is used by a client, all running services are interrupted to detect memory leakage, which affects normal services of the user.
Therefore, a method for detecting memory leakage is needed to solve the above problems.
Disclosure of Invention
In order to solve the above problems, embodiments of the present invention provide a memory leak detection method and a memory management module, which overcome the above problems or at least partially solve the above problems.
In a first aspect, an embodiment of the present invention provides a memory leak detection method, including:
adding a digital sequence number identifier in the memory, wherein the digital sequence number identifier is used for associating the upper-layer memory with the lower-layer memory;
acquiring the lower-layer memory quantity related to the current memory in the memory management module based on the digital serial number identifier;
and if the quantity of the lower-layer memories associated with the current memories in the memory management module is not equal to the statistical quantity of the service data modules, confirming that the lower-layer memories associated with the current memories have memory leakage.
Wherein, the increasing the number sequence number identification in the memory includes:
adding a memory associated application programming interface in the memory management module;
and based on the memory association application programming interface, associating the upper-layer memory with the lower-layer memory by using a digital serial number identifier, wherein the digital serial number identifier is recorded in the head information of the lower-layer memory.
Wherein, the obtaining of the lower-layer memory quantity associated with the current memory in the memory management module based on the digital serial number identifier includes:
adding a counting application programming interface in the memory management module;
acquiring the number sequence number of the current memory based on the counting application programming interface;
counting the number of memories with the number of the upper-level numbers equal to the number of the current memories in all the memory blocks in the memory management module.
After the determining that the memory leak occurs in the lower-layer memory associated with the current memory, the method further includes:
and eliminating memory leakage of the lower-layer memory associated with the current memory.
Wherein the performing memory leak elimination on the lower-layer memory associated with the current memory includes:
adding a memory leak detection application programming interface in the memory management module;
based on the memory leak detection application programming interface, all lower-layer memories associated with the current memory are called back to confirm a target lower-layer memory with memory leak;
and calling a memory release application programming interface to release the target lower-layer memory.
A second aspect of the present invention further provides a memory management module, including:
the digital sequence number mark adding module is used for adding a digital sequence number mark in the memory, and the digital sequence number mark is used for associating the upper-layer memory with the lower-layer memory;
the association number counting module is used for acquiring the lower-layer memory number associated with the current memory based on the digital serial number identifier;
and the memory leak detection module is used for confirming that the memory leak occurs in the lower-layer memory associated with the current memory if the number of the lower-layer memories associated with the current memory is not equal to the statistical number of the service data modules.
Wherein, the number serial number mark adding module is specifically configured to:
and associating the upper-layer memory with the lower-layer memory by using a digital serial number identifier, wherein the digital serial number identifier is recorded in the head information of the lower-layer memory.
Wherein the association number statistics module is specifically configured to:
acquiring a digital serial number of a current memory;
counting the number of memories with the number of the upper-level numbers equal to the number of the current memories in all the memory blocks in the memory management module.
Wherein, the memory management module further comprises:
and the memory leak elimination module is used for eliminating memory leak of the lower-layer memory associated with the current memory.
Wherein the memory leak elimination module is specifically configured to:
calling back all lower-layer memories associated with the current memory to confirm a target lower-layer memory with memory leakage;
and calling a memory release application programming interface to release the target lower-layer memory.
Third aspect an embodiment of the present invention provides an electronic device, including:
a processor, a memory, a communication interface, and a bus; the processor, the memory and the communication interface complete mutual communication through the bus; the memory stores program instructions executable by the processor, and the processor calls the program instructions to perform a memory leak detection method as described above.
In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute a memory leak detection method as described above.
In the memory leak detection method and the memory management module provided by the embodiments of the present invention, the serial number identifier is added to the memory, and the upper and lower layer associations between the memories are determined by using the serial number identifier. Therefore, the data are verified with the incidence relation among the data in the service program, and whether the memory leakage condition occurs or not is accurately detected.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic flow chart illustrating a method for detecting memory leakage according to an embodiment of the present invention;
fig. 2 is a schematic diagram of an operation structure of a telecommunication program provided by an embodiment of the present invention;
fig. 3 is a schematic diagram of a BGP protocol module hierarchy provided in an embodiment of the present invention;
fig. 4 is a data relationship diagram from a to J in the memory management module according to the embodiment of the present invention;
fig. 5 is a schematic diagram of a BGP protocol module hierarchy provided in the embodiment of the present invention after node F is removed;
fig. 6 is a schematic structural diagram of a memory management module according to an embodiment of the present invention;
fig. 7 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some embodiments, but not all embodiments, of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a schematic flow chart of a memory leak detection method according to an embodiment of the present invention, as shown in fig. 1, including:
101. adding a digital sequence number identifier in the memory, wherein the digital sequence number identifier is used for associating the upper-layer memory with the lower-layer memory;
102. acquiring the lower-layer memory quantity related to the current memory in the memory management module based on the digital serial number identifier;
103. and if the quantity of the lower-layer memories associated with the current memories in the memory management module is not equal to the statistical quantity of the service data modules, confirming that the lower-layer memories associated with the current memories have memory leakage.
It should be noted that the memory needs to be accessed at a high speed, so that the application and release of the memory need to have a very high efficiency, otherwise the performance of the service is affected. In order to apply and release a memory at high speed in software in the field of telecommunications, a layer of memory management module is encapsulated on a memory management of an operating system, fig. 2 is a schematic view of a telecommunications Program operating structure provided in an embodiment of the present invention, as shown in fig. 2, a memory management module mem _ adapt is encapsulated on a memory interface of the operating system, and a Program code directly uses an interface of the mem _ adapt to apply and release the memory, so that high efficiency in applying and releasing is achieved through the mem _ adapt. For efficient memory usage, no additional memory management structures can be added to detect memory leaks because the additional steps of accessing the management structures affect the efficiency of memory application and release.
Therefore, the embodiment of the invention does not increase an additional memory management structure on the premise of not influencing the application and release efficiency of the memory, and realizes the accurate detection of the leaked memory.
Specifically, in step 101, the embodiment of the present invention first adds a number serial number identifier to the memory, where the number serial number identifier is used to identify the upper and lower layer associations between the memories. It can be understood that there is a hierarchical relationship between the memories, that is, each next level of memory depends on its upper memory and is also depended on by its lower memory, and the hierarchical relationship between the memories is correspondingly related to the memory data stored in the memories. Applying for the memory generally calls a memory application API provided by a memory management module: void mem _ alloc (int size), size is the size of the applied memory, and the unit is byte; the API assigns a numerical sequence number to each memory datum in the memory header information. Taking a BGP protocol module in a telecommunication program as an example, fig. 3 is a schematic diagram of a hierarchical relationship of a BGP protocol module provided in an embodiment of the present invention, and as shown in fig. 3, in a Border Gateway Protocol (BGP) (border Gateway protocol) protocol module, BGP module root data is top-level service data, a neighbor data node of BGP is second-level data, a neighbor routing data node is third-level data, and an attribute data node of routing data is fourth-level data. Then the relationship, i.e., A, is the top level data, using the top level memory, B and C are the bottom level data associated with A, D and F are the bottom level data associated with B, E and G are the bottom level data associated with C, H and I are the bottom level data associated with D, and J is the bottom level data associated with E. The association information is recorded in the memory in a mode of digital serial number identification, so that any memory node can know the memory association of the upper layer and the lower layer. Fig. 4 is a data relationship diagram from a to J in the memory management module according to the embodiment of the present invention, and it can be understood that the diagram corresponds to each data node in the BGP protocol module in fig. 3, where a is numbered as (10, 0), 10 represents an identity of a itself, 0 represents that a does not have an upper node, and B is numbered as (20, 10), 20 represents an identity of B, 10 represents that an upper node of B is a (because an identity of a is 10), and so on, a corresponding number identifier may be added to all memory nodes from a to J to reflect upper and lower relationships between memory data. It should be noted that, when a memory application is performed, a number sequence, that is, the first number sequence in a to J, is actively allocated to each memory data, and what is added in the embodiment of the present invention is only the second number identifier reflecting the memory relationship between the upper layer and the lower layer.
Further, in step 102, according to the number serial number identifier added to the memory, in the embodiment of the present invention, the upper and lower layer memory relationship of the node may be obtained on any memory node, and as shown in fig. 3, it can be understood that the corresponding relationship between the upper layer and the lower layer is a one-to-many relationship, and then all the lower layer memories pointing to the upper layer memory may be counted by traversing in the remaining memories after reading the identifier of the upper layer memory, so that the number of the lower layer memories associated with the current memory may be counted in the memory management module.
Finally, in step 103, the embodiment of the present invention compares the statistical result in step 102 with the service data statistical result of the service data module, where the service data statistical result of the service data module is counted by the data structure in the code, for example, for a linked list, each node in the linked list needs to apply for a memory before being used, and the number of nodes in the linked list is also the number of memories applied by the service. If the numerical values are not consistent, it is determined that one of the memories in the current memories is leaked, so that the statistical data of the service data module is smaller than the statistical data of the memory management module. It can be understood that, because the memory release operation is not performed when the data node is deleted, the digital serial number of the node still remains in the memory, and thus the statistical data of the memory management module is not changed, and when the service data module is subjected to statistics, the number of the statistical data is small because the data node is deleted, so that the statistical result of the service data module is inconsistent with the statistical result of the memory management module. Fig. 5 is a schematic diagram of a hierarchical relationship between BGP protocol modules with a node F removed according to an embodiment of the present invention, as shown in fig. 5, the node F is deleted in an original BGP protocol module, but a memory occupied by data F is not released, so that statistics of a node B (i.e., a current node in the embodiment of the present invention) by a memory management module during statistics is still 2, and when an actual service data module performs service data statistics, the node B has only one lower layer data of a node D, and the statistical data is 1, so that it may be determined that a memory leak occurs in one of the lower layer nodes of the node B at this time.
In the method for detecting memory leak provided by the embodiment of the invention, the upper and lower layer associations between the memories are determined by adding the number sequence identifier in the memories and utilizing the number sequence identifier. Therefore, the data are verified with the incidence relation among the data in the service program, and whether the memory leakage condition occurs or not is accurately detected.
On the basis of the above embodiment, the adding of the number sequence number identifier in the memory includes:
adding a memory associated application programming interface in the memory management module;
and based on the memory association application programming interface, associating the upper-layer memory with the lower-layer memory by using a digital serial number identifier, wherein the digital serial number identifier is recorded in the head information of the lower-layer memory.
As can be seen from the content of the foregoing embodiment, in the embodiment of the present invention, a manner of adding a number serial number identifier to a memory is used to identify an association relationship between upper and lower memories, and a program code is implemented by an Interface in a memory management module, so specifically, when the number serial number identifier is added in the embodiment of the present invention, an Application Programming Interface (API) is newly added to the memory management module, where the API is referred to as a memory association API in the embodiment of the present invention, and a format is defined as void menu _ container (void _ upper, void _ lower), where the upper is a pointer of the upper memory and the lower is a pointer of the lower memory. The API interface can associate the upper-layer memory and the lower-layer memory pointed by the function entry parameters, the numerical sequence number is adopted during association, namely, each time lower data is added, the numerical sequence number is taken from the upper and is filled into the lower to form association, and the numerical sequence number is filled in the header information of the lower-layer memory so as to be associated with the upper-layer memory.
On the basis of the foregoing embodiment, the obtaining, based on the digital serial number identifier, the number of lower-layer memories associated with the current memory in the memory management module includes:
adding a counting application programming interface in the memory management module;
acquiring the number sequence number of the current memory based on the counting application programming interface;
counting the number of memories with the number of the upper-level numbers equal to the number of the current memories in all the memory blocks in the memory management module.
As can be seen from the content of the foregoing embodiment, in the embodiment of the present invention, it is detected whether the memory leaks by counting the number of lower-layer memories associated with the current memory in the memory management module, and the program code is implemented by an interface in the memory management module, so specifically, a mode of adding an API interface is adopted in the embodiment of the present invention when the embodiment of the present invention is counted, the interface is referred to as a counting application programming interface in the embodiment of the present invention, and the defined format is: int mem _ concern _ count (void _ upper), the number of the lower layer memories associated with the access memory can be calculated through the interface, namely the serial number in the header information of the access memory is taken, then statistics is carried out on the number of the upper layer serial numbers in the header information searched in all memories of the memory management module, which is equal to the number of the access parameters, and finally the function returns the statistical result.
On the basis of the foregoing embodiment, after the determining that the memory leak occurs in the underlying memory associated with the current memory, the method further includes:
and eliminating memory leakage of the lower-layer memory associated with the current memory.
As can be seen from the above description of the embodiments, the embodiments of the present invention can accurately perform memory leak detection, and it can be understood that a leaked memory needs to be eliminated before a free memory can be released, so that the embodiments of the present invention preferably need to perform memory leak elimination on a lower layer memory associated with a current memory after confirming that the lower layer memory associated with the current memory has a memory leak.
On the basis of the foregoing embodiment, the performing memory leak elimination on the underlying memory associated with the current memory includes:
adding a memory leak detection application programming interface in the memory management module;
based on the memory leak detection application programming interface, all lower-layer memories associated with the current memory are called back to confirm a target lower-layer memory with memory leak;
and calling a memory release application programming interface to release the target lower-layer memory.
Specifically, the embodiment of the present invention adopts a mode of adding an API interface when performing memory leak elimination, where the interface is referred to as a memory leak detection application programming interface in the embodiment of the present invention, and the defined format is: void mem _ leak _ chk (void upper, leak _ chk _ free lower _ chk _ free), wherein lower _ chk _ free is a callback function pointer for releasing the underlying memory; the function of the interface is referred to an example of an upper memory and a callback function for judging whether a lower memory associated with the upper memory leaks, the memory management module transmits each lower memory associated with the upper memory to the callback function of the service data module, and when the service data module finds that the transmitted lower memory is not in use in the callback function, the lower memory is judged to leak, and then the function for releasing the memory is called to release the memory. Specifically, in this embodiment, the memory of lower can be found out according to the sequence number of upper, that is, the memory of mem _ alloc application is used by the service, and each block memory pointer is transmitted into lower _ chk _ free to be judged by the service data module, and if the service data module considers that the content of the memory pointer is already released, that is, belongs to a leaked memory, the service calls mem _ free to release. If the business data module considers that the memory block is in use and not leaked, the next memory block is checked to be lower. In this embodiment, calling the memory release API typically releases the memory API for void mem _ free (void ptr), where ptr is the memory pointer to be released, while other data associated with the leaked memory is flushed.
The embodiment of the present invention is described by taking a BGP service data processing module as an example, and reference may be made to the contents of fig. 3, fig. 4, and fig. 5.
Firstly, a service data module calls a memory applying API to apply for a memory of service data, the preferred size of the memory is set to be 100 bytes, then each memory data forms a tree structure as shown in figure 3, and then a memory association API is called to perform association of upper and lower memories, and the specific code implementation logic is as follows:
mem _ alloc (100); v/BGP example, Top-level memory has only A flow
pm _ alloc (100); treeaded (pA, pB); mem _ concern (pA, pB); v/ABC flow of neighbor part
pC=mem_alloc(100);treeadd(pA,pC);mem_concern(pA,pC);
pD — mem _ alloc (100); treead (pB, pD); mem _ concern (pB, pD); v/ABC flow of routing section
pE=mem_alloc(100);treeadd(pC,pE);mem_concern(pC,pE);
pF=mem_alloc(100);treeadd(pB,pF);mem_concern(pB,pF);
pG=mem_alloc(100);treeadd(pC,pG);mem_concern(pC,pG);
pH mem _ alloc (100); treead (pD, pH); mem _ concern (pD, pH); v/ABC flow of the route Attribute section
pI=mem_alloc(100);treeadd(pD,pI);mem_concern(pD,pI);
pJ=mem_alloc(100);treeadd(pE,pJ);mem_concern(pE,pJ);
Then, an upper and lower layer data tree diagram as shown in fig. 3 and a number sequence identification diagram of each node as shown in fig. 4 are formed, and when the service data module deletes the F node therein, refer to fig. 5, and the code process is: treedel (pB, pF), but when a memory leak is caused by a deletion node not performing memory release, at this time, the embodiment of the present invention calls a counting application programming interface to count to obtain that the lower layer memory count of the current memory B of the memory management module is 2, that is, both D and F are included, and the data counted by the service data module is only 1, that is, only D lower layer data is included, so that it can be determined that the lower layer node of the BGP service node B has a memory leak, and the memory leak starts to be eliminated.
When the memory leakage is eliminated, the memory leakage detection API is called first, and the code process is as follows: mem _ leak _ chk (pB, bgp _ chk _ route _ leak), the memory management module searches the lower memory of B, which is numbered 20 in the memory header information, the number of the upper layer memory in the header information of D and F is 20, as shown in fig. 4, the memory management module sequentially transfers the memories of D and F to the callback function bgp _ chk _ route _ leak, the callback function finds D in the data structure of the service, judges that the memory of D is normally used, if F is not found in the data structure of the service, it is determined that the memory of F is not in the data structure of the route and is a leaked memory, such as a linked list for the service, and if there is a D data pointer in the linked list, then the memory of D is in use, if F can not be found in the linked list, the F memory is not used for the service, namely the leakage, so that the memory release API needs to be called to release the memory to solve the leakage problem. If the routing data of the F memory also contains routing attributes and other related data, the memory needs to be released continuously or the data needs to be cleaned, and the F memory does not have other data to be processed, the callback function can quit execution, and the whole set of memory leak detection and elimination work is completed through the above process.
Fig. 6 is a schematic structural diagram of a memory management module according to an embodiment of the present invention, as shown in fig. 6, including: a number serial number identifier adding module 601, an association number counting module 602, and a memory leak detection module 603, wherein:
the digital sequence number identifier adding module 601 is configured to add a digital sequence number identifier in a memory, where the digital sequence number identifier is used to associate an upper-layer memory with a lower-layer memory;
the association number counting module 602 is configured to obtain the number of lower-layer memories associated with the current memory based on the digital serial number identifier;
the memory leak detection module 603 is configured to determine that a memory leak occurs in the lower memory associated with the current memory if the number of the lower memory associated with the current memory is not equal to the statistical number of the service data modules.
Specifically, how to add the module 601, the associated quantity counting module 602, and the memory leak detection module 603 through the number identifier can be used to execute the technical solution of the embodiment of the memory leak detection method shown in fig. 1, and the implementation principle and the technical effect are similar, which is not described herein again.
In the memory management module provided in the embodiment of the present invention, the serial number identifier is added to the memory, and the upper and lower layer associations between the memories are determined by using the serial number identifier. Therefore, the data are verified with the incidence relation among the data in the service program, and whether the memory leakage condition occurs or not is accurately detected.
On the basis of the above embodiment, the number serial number identifier adding module is specifically configured to:
and associating the upper-layer memory with the lower-layer memory by using a digital serial number identifier, wherein the digital serial number identifier is recorded in the head information of the lower-layer memory.
On the basis of the above embodiment, the association number statistics module is specifically configured to:
acquiring a digital serial number of a current memory;
counting the number of memories with the number of the upper-level numbers equal to the number of the current memories in all the memory blocks in the memory management module.
On the basis of the above embodiment, the memory management module further includes:
and the memory leak elimination module is used for eliminating memory leak of the lower-layer memory associated with the current memory.
On the basis of the foregoing embodiment, the memory leak elimination module is specifically configured to:
calling back all lower-layer memories associated with the current memory to confirm a target lower-layer memory with memory leakage;
and calling a memory release application programming interface to release the target lower-layer memory.
Fig. 7 is a block diagram of an electronic device according to an embodiment of the present invention, and referring to fig. 7, the electronic device includes: a processor (processor)701, a communication Interface (Communications Interface)702, a memory (memory)703 and a bus 704, wherein the processor 701, the communication Interface 702 and the memory 703 complete communication with each other through the bus 704. The processor 701 may call logic instructions in the memory 703 to perform the following method: adding a digital sequence number identifier in the memory, wherein the digital sequence number identifier is used for associating the upper-layer memory with the lower-layer memory; acquiring the lower-layer memory quantity related to the current memory in the memory management module based on the digital serial number identifier; and if the quantity of the lower-layer memories associated with the current memories in the memory management module is not equal to the statistical quantity of the service data modules, confirming that the lower-layer memories associated with the current memories have memory leakage.
An embodiment of the present invention discloses a computer program product, which includes a computer program stored on a non-transitory computer readable storage medium, the computer program including program instructions, when the program instructions are executed by a computer, the computer can execute the methods provided by the above method embodiments, for example, the method includes: adding a digital sequence number identifier in the memory, wherein the digital sequence number identifier is used for associating the upper-layer memory with the lower-layer memory; acquiring the lower-layer memory quantity related to the current memory in the memory management module based on the digital serial number identifier; and if the quantity of the lower-layer memories associated with the current memories in the memory management module is not equal to the statistical quantity of the service data modules, confirming that the lower-layer memories associated with the current memories have memory leakage.
Embodiments of the present invention provide a non-transitory computer-readable storage medium, which stores computer instructions, where the computer instructions cause the computer to perform the methods provided by the above method embodiments, for example, the methods include: adding a digital sequence number identifier in the memory, wherein the digital sequence number identifier is used for associating the upper-layer memory with the lower-layer memory; acquiring the lower-layer memory quantity related to the current memory in the memory management module based on the digital serial number identifier; and if the quantity of the lower-layer memories associated with the current memories in the memory management module is not equal to the statistical quantity of the service data modules, confirming that the lower-layer memories associated with the current memories have memory leakage.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to each embodiment or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention 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 solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for detecting a memory leak, comprising:
adding a digital sequence number identifier in the memory, wherein the digital sequence number identifier is used for associating the upper-layer memory with the lower-layer memory;
acquiring the lower-layer memory quantity related to the current memory in the memory management module based on the digital serial number identifier;
and if the quantity of the lower-layer memories associated with the current memories in the memory management module is not equal to the statistical quantity of the service data modules, confirming that the lower-layer memories associated with the current memories have memory leakage.
2. The method of claim 1, wherein the adding a numerical serial number identifier to the memory comprises:
adding a memory associated application programming interface in the memory management module;
and based on the memory association application programming interface, associating the upper-layer memory with the lower-layer memory by using a digital serial number identifier, wherein the digital serial number identifier is recorded in the head information of the lower-layer memory.
3. The method according to claim 2, wherein the obtaining the amount of the lower-layer memory associated with the current memory in the memory management module based on the digital serial number identifier comprises:
adding a counting application programming interface in the memory management module;
acquiring the number sequence number of the current memory based on the counting application programming interface;
counting the number of memories with the number of the upper-level numbers equal to the number of the current memories in all the memory blocks in the memory management module.
4. The method according to claim 1, wherein after the determining that the memory leak occurs in the underlying memory associated with the current memory, the method further comprises:
and eliminating memory leakage of the lower-layer memory associated with the current memory.
5. The method according to claim 4, wherein the performing memory leak elimination on the underlying memory associated with the current memory comprises:
adding a memory leak detection application programming interface in the memory management module;
based on the memory leak detection application programming interface, all lower-layer memories associated with the current memory are called back to confirm a target lower-layer memory with memory leak;
and calling a memory release application programming interface to release the target lower-layer memory.
6. A memory management module, comprising:
the digital sequence number mark adding module is used for adding a digital sequence number mark in the memory, and the digital sequence number mark is used for associating the upper-layer memory with the lower-layer memory;
the association number counting module is used for acquiring the lower-layer memory number associated with the current memory based on the digital serial number identifier;
and the memory leak detection module is used for confirming that the memory leak occurs in the lower-layer memory associated with the current memory if the number of the lower-layer memories associated with the current memory is not equal to the statistical number of the service data modules.
7. The memory management module of claim 6, wherein the number serial number identifier adding module is specifically configured to:
and associating the upper-layer memory with the lower-layer memory by using a digital serial number identifier, wherein the digital serial number identifier is recorded in the head information of the lower-layer memory.
8. The memory management module of claim 7, wherein the association number statistics module is specifically configured to:
acquiring a digital serial number of a current memory;
counting the number of memories with the number of the upper-level numerical sequence equal to the number of the numerical sequence of the current memory in all the memory blocks.
9. The memory management module of claim 6, further comprising:
and the memory leak elimination module is used for eliminating memory leak of the lower-layer memory associated with the current memory.
10. The memory management module of claim 9, wherein the memory leak elimination module is specifically configured to:
calling back all lower-layer memories associated with the current memory to confirm a target lower-layer memory with memory leakage;
and calling a memory release application programming interface to release the target lower-layer memory.
CN202010121573.5A 2020-02-26 2020-02-26 Memory leak detection method and memory management module Pending CN111352734A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010121573.5A CN111352734A (en) 2020-02-26 2020-02-26 Memory leak detection method and memory management module

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010121573.5A CN111352734A (en) 2020-02-26 2020-02-26 Memory leak detection method and memory management module

Publications (1)

Publication Number Publication Date
CN111352734A true CN111352734A (en) 2020-06-30

Family

ID=71197171

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010121573.5A Pending CN111352734A (en) 2020-02-26 2020-02-26 Memory leak detection method and memory management module

Country Status (1)

Country Link
CN (1) CN111352734A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11755473B2 (en) 2022-01-03 2023-09-12 Samsung Electronics Co., Ltd. Method and system for managing memory leaks in a linear memory model

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050268286A1 (en) * 2004-04-12 2005-12-01 Motoki Obata Method of detecting memory leak causing portion and execution program thereof
CN101162436A (en) * 2006-10-13 2008-04-16 中兴通讯股份有限公司 Ems memory leakage testing method in communication apparatus system
US20090328007A1 (en) * 2008-06-27 2009-12-31 International Business Machines Corporation Memory leak diagnosis
CN103714004A (en) * 2014-01-02 2014-04-09 金蝶软件(中国)有限公司 JVM online memory leak analysis method and system
CN107783908A (en) * 2017-11-07 2018-03-09 晶晨半导体(上海)股份有限公司 A kind of detection method based on linux kernel RAM leakage

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050268286A1 (en) * 2004-04-12 2005-12-01 Motoki Obata Method of detecting memory leak causing portion and execution program thereof
CN101162436A (en) * 2006-10-13 2008-04-16 中兴通讯股份有限公司 Ems memory leakage testing method in communication apparatus system
US20090328007A1 (en) * 2008-06-27 2009-12-31 International Business Machines Corporation Memory leak diagnosis
CN103714004A (en) * 2014-01-02 2014-04-09 金蝶软件(中国)有限公司 JVM online memory leak analysis method and system
CN107783908A (en) * 2017-11-07 2018-03-09 晶晨半导体(上海)股份有限公司 A kind of detection method based on linux kernel RAM leakage

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11755473B2 (en) 2022-01-03 2023-09-12 Samsung Electronics Co., Ltd. Method and system for managing memory leaks in a linear memory model

Similar Documents

Publication Publication Date Title
CN106250310B (en) A kind of method for generating test case and device
CN110289983B (en) Load balancing application creation method and device, computer equipment and storage medium
US11663322B2 (en) Distributed security introspection
CN112181804A (en) Parameter checking method, equipment and storage medium
CN114116065B (en) Method and device for acquiring topological graph data object and electronic equipment
CN111352734A (en) Memory leak detection method and memory management module
CN114995859A (en) Page hot updating method, device, equipment and storage medium
CN111124382A (en) Attribute assignment method and device in Java and server
US8224933B2 (en) Method and apparatus for case-based service composition
CN111563215B (en) Method and device for controlling front-end operation authority and related equipment
CN113722114A (en) Data service processing method and device, computing equipment and storage medium
CN112115401A (en) Webpage data processing method, device and system based on cloud platform
CN115934199A (en) Service performance monitoring tool, method, device and medium
CN113268401B (en) Log information output method and device and computer readable storage medium
CN113726855B (en) Service aggregation method, device, electronic equipment and computer-readable storage medium
CN100388206C (en) Method with management of an opaque user identifier for checking complete delivery of a service using a set of servers
CN109426720B (en) Interface parameter verification method and related device
CN111736806A (en) Control injection method and device and terminal equipment
CN109308256A (en) A kind of java dynamically analyzing of program method, equipment and storage medium
CN113114493B (en) Network element configuration constraint checking method and system
CN117407204A (en) Application program fault positioning method, device, equipment and storage medium
WO2023093527A1 (en) Alarm association rule generation method and apparatus, and electronic device and storage medium
CN115756940A (en) Baffle system integrating fault scenes, application system and method
CN114860210A (en) Multi-party SDH frame structure data comparison method based on JAVA language
CN115220714A (en) Development method and device of application programming interface

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200630

RJ01 Rejection of invention patent application after publication