CN108664394A - A kind of RAM leakage process tracing method and device - Google Patents
A kind of RAM leakage process tracing method and device Download PDFInfo
- Publication number
- CN108664394A CN108664394A CN201810316302.8A CN201810316302A CN108664394A CN 108664394 A CN108664394 A CN 108664394A CN 201810316302 A CN201810316302 A CN 201810316302A CN 108664394 A CN108664394 A CN 108664394A
- Authority
- CN
- China
- Prior art keywords
- internal memory
- operation function
- memory
- memory operation
- update
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
- G06F11/366—Software debugging using diagnostics
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
- G06F11/3636—Software debugging by tracing the execution of the program
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation 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/5016—Allocation 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
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation 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/5022—Mechanisms to release resources
Abstract
The embodiment of the invention discloses a kind of RAM leakage process tracing methods and device, method to include:Internal memory operation function obtains the second memory to the first memory addition head of primary internal memory operation function distribution and tail portion after generating update according to primary internal memory operation function;If being known the address of internal memory operation function after updating in the start-stop address according to the start-stop address judgement obtained in advance, it is determined that the second memory can trace;Second memory is added in global chained list or is removed from global chained list;If overall situation chained list is not sky after executable program executes, then determine that there are RAM leakages, and the process of RAM leakage is traced according to the call relation of internal memory operation function after update, the execution route of internal memory operation function after updating can be obtained to obtain the implementation procedure for leading to memory overflow, so that exploitation and tester are to the position of memory overflow and to occur memory overflow why very clear, go to analyze code logic again without expending time and efforts.
Description
Technical field
The present embodiments relate to field of computer technology, and in particular to a kind of RAM leakage process tracing method and dress
It sets.
Background technology
In software development process, interior nuclear leakage is common problem, it directly affects the fortune steady in a long-term of software systems
Row.Memory overflow refers to that the heap memory that oneself dynamically distributes in program is not discharged or can not be discharged for some reason, causes system
The waste of memory causes program operation speed to slow down the even serious consequences such as system crash.
The method of detection memory overflow is mainly the method compared using memory image at present, i.e., every in program operation process
Every the snapshot of a period of time crawl Memory Allocation operation, the difference of the adjacent snapshot captured twice is searched by manual type, is looked for
Go out the memory block not discharged, but this method cost of labor is higher, and tester is needed to know quite well business.Another method
It is the address stack information for the memory for obtaining memory allocator distribution, by the base address of the dynamic base relied on executable program
Compare with tail address, obtain the corresponding more specific location information of address stack information, but this method is it is confirmed that memory overflow
Specific location can not determine the execution logic of program when memory overflow occurs, i.e., why can not obtain can occur memory overflow.
During realizing the embodiment of the present invention, inventor has found that existing method shortage chases after RAM leakage process
It traces back, it is necessary to code logic analysis manually be carried out by exploitation and tester, expend time and efforts.
Invention content
Since there are the above problem, a kind of RAM leakage process tracing method of proposition of the embodiment of the present invention and dresses for existing method
It sets.
In a first aspect, the embodiment of the present invention proposes a kind of RAM leakage process tracing method, including:
Internal memory operation function after updating is generated according to primary internal memory operation function, passes through internal memory operation function after the update
To the first memory addition head and tail portion of the primary internal memory operation function distribution, the second memory is obtained;
If being judged according to the start-stop address of the executable program obtained in advance and the virtual address for the dynamic base for retaining stack frame
Know the address of internal memory operation function after the update in the start-stop address, it is determined that second memory can trace;
Second memory is added in global chained list by internal memory operation function after the update, or, passing through memory
Release function removes second memory from the global chained list;
If the executable program after executing the global chained list be not sky, it is determined that there are RAM leakage, and root
The process of RAM leakage is traced according to the call relation of internal memory operation function after the update.
It is optionally, described that second memory is added in global chained list by internal memory operation function after the update,
It specifically includes:
Internal memory operation function is closed according to the call chain of the call stack acquisition of information current function of current function after the update
System, is stored in the head of second memory, and second memory is added in global chained list by the calling chain relation.
Optionally, the method further includes:
If the call number of the call chain once obtained afterwards is more than the call number of the preceding call chain once obtained, it is determined that
There are RAM leakages, and the process of RAM leakage is traced according to the call relation of internal memory operation function after the update.
Optionally, internal memory operation function after the generation update according to primary internal memory operation function, specifically includes:
Under conditions of calling the logic of the primary internal memory operation function in not changing executable program and calling code,
The environmental variance or Hook Function of the preloading of the primary internal memory operation function are changed, or redefines the primary memory behaviour
Make the linking relationship of function, or linker is preferentially parsed according to target identification.
Optionally, the information stored in the head includes:Recalls information, the memory address of distribution, actual use it is interior
Deposit address, the memory total size of distribution, the memory total size of actual use and memory overwriting confirmation message.
Second aspect, the embodiment of the present invention also propose a kind of RAM leakage process retrospective device, including:
Memory refreshing module, for internal memory operation function after being updated according to the generation of primary internal memory operation function, by described
The the first memory addition head and tail portion of primary internal memory operation function distribution described in internal memory operation function pair, obtain second after update
Memory;
Judgment module is traced, if for according to the executable program that obtains in advance and retaining the dynamic base of stack frame virtually
The start-stop address of location judges to know the address of internal memory operation function after the update in the start-stop address, it is determined that described the
Two memories can trace;
Internal memory operation module, for second memory to be added to global chain by internal memory operation function after the update
In table, second memory is removed from the global chained list or, discharging function by memory;
Trace back block is revealed, if the global chained list is not sky after being executed for the executable program, it is determined that
There are RAM leakages, and the process of RAM leakage is traced according to the call relation of internal memory operation function after the update.
Optionally, internal memory operation function is according to the tune of current function after the internal memory operation module is specifically used for the update
With the calling chain relation of stack acquisition of information current function, the calling chain relation is stored in the head of second memory, and
Second memory is added in global chained list.
Optionally, described device further includes:
Judgment module is revealed, if the call number of the call chain for once obtaining afterwards is more than the preceding call chain once obtained
Call number, it is determined that there are RAM leakages, and according to after the update internal memory operation function call relation trace memory
The process of leakage.
Optionally, the memory refreshing module is specifically used for calling the primary memory behaviour in not changing executable program
Under conditions of making the logic of function and calling code, the environmental variance or hook of the preloading of the primary internal memory operation function are changed
Subfunction, or the linking relationship of the primary internal memory operation function is redefined, or linker is preferentially parsed according to target identification.
Optionally, the information stored in the head includes:Recalls information, the memory address of distribution, actual use it is interior
Deposit address, the memory total size of distribution, the memory total size of actual use and memory overwriting confirmation message.
The third aspect, the embodiment of the present invention also propose a kind of electronic equipment, including:
At least one processor;And
At least one processor being connect with the processor communication, wherein:
The memory is stored with the program instruction that can be executed by the processor, and the processor calls described program to refer to
Order is able to carry out the above method.
Fourth aspect, the embodiment of the present invention also propose a kind of non-transient computer readable storage medium, the non-transient meter
Calculation machine readable storage medium storing program for executing stores computer program, and the computer program makes the computer execute the above method.
As shown from the above technical solution, the embodiment of the present invention can be traced by determining second memory and judge global chained list not
After sky, according to call relation trace RAM leakage process, by obtain update after internal memory operation function execution route come
Obtaining leads to the implementation procedure of memory overflow so that develops with tester in the position of memory overflow and why can occur
It is very clear to deposit leakage, analysis code logic is gone again without expending time and efforts.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with
Other attached drawings are obtained according to these figures.
Fig. 1 is a kind of flow diagram for RAM leakage process tracing method that one embodiment of the invention provides;
Fig. 2 is a kind of flow diagram for RAM leakage process tracing method that another embodiment of the present invention provides;
Fig. 3 is a kind of structural schematic diagram for RAM leakage process retrospective device that one embodiment of the invention provides;
Fig. 4 is the logic diagram for the electronic equipment that one embodiment of the invention provides.
Specific implementation mode
Below in conjunction with the accompanying drawings, the specific implementation mode of the present invention is further described.Following embodiment is only used for more
Technical scheme of the present invention is clearly demonstrated, and not intended to limit the protection scope of the present invention.
Fig. 1 shows a kind of flow diagram of RAM leakage process tracing method provided in this embodiment, including:
S101, internal memory operation function after update is generated according to primary internal memory operation function, grasped by memory after the update
The the first memory addition head and tail portion for making primary internal memory operation function distribution described in function pair, obtain the second memory.
Wherein, the primary internal memory operation function is the internal memory operation function that system carries, and is mainly used for carrying out memory point
Match.
Internal memory operation function is to increase part work(on the basis of the primary internal memory operation function after the update
Can, increased function includes that the first memory distributed for primary internal memory operation function adds head and tail portion in the present embodiment, is obtained
To the second memory.
The memory of primary internal memory operation function distribution is saved as in described first.
The memory that the first memory of internal memory operation function pair is handled after updating is saved as in described second.
The information stored in the head includes:Recalls information, the memory address of distribution, actual use memory address,
The memory total size of distribution, the memory total size of actual use and memory overwriting confirmation message.
Specifically, in practical implementation, the information stored in head includes not only above- mentioned information, is answered according to difference
With scene, may increase and decrease the information stored in some header informations, such as head is:Recalls information, distribution it is interior
Deposit the memory address of address and actual use;Or recalls information, the memory address of distribution, actual use memory address, point
The memory total size and poison information of the memory total size, actual use matched, wherein poison information are used for confirming memory
It crosses the border.
If S102, according to the start-stop address of the executable program that obtains in advance and the virtual address for the dynamic base for retaining stack frame
Judge the address for knowing internal memory operation function after the update in the start-stop address, it is determined that second memory can chase after
It traces back.
Wherein, the start-stop address is the initial address obtained in advance and end address, for judging in after above-mentioned update
Whether deposit the second memory of handling function generation can trace:The ground of internal memory operation function after second memory corresponding update
Location is in the start-stop address, it is determined that second memory can trace, and otherwise determine that second memory can not trace.
The address of internal memory operation function includes internal memory operation function and its all higher levels after the update after the update
The address of call function, the address are the virtual addresses of internal memory operation function after the update, it is therefore an objective to ensure the update
The address of internal memory operation function and its all higher level's call functions is in the start-stop address afterwards.
Such as by reading the file under the corresponding process of executable program, such as/proc/ [process number]/maps or
Smaps files, can obtain executable program and it relies on the stack information of dynamic base, to obtain executable program and reservation
There is the start-stop address of the virtual address of the dynamic base of stack frame.
Further, when second memory can trace, the process of RAM leakage can be traced according to subsequent operation;
Conversely, when second memory can not trace, then the process of RAM leakage can not be traced.
S103, second memory is added in global chained list by internal memory operation function after the update, or, passing through
Memory discharges function and removes second memory from the global chained list.
Wherein, the global chained list is the chained list for storing the memory distributed in executable program operational process, when complete
After memory release in office's chained list, then corresponding memory is removed from global chained list.
If S104, the executable program after executing the global chained list be not sky, it is determined that there are RAM leakage,
And the process of RAM leakage is traced according to the call relation of internal memory operation function after the update.
Specifically, global chained list is the chained list for storing the memory distributed in executable program operational process, when global chained list
In memory release after, then corresponding memory is removed from global chained list, therefore, after executable program end of run, just
In the case of often, the memory in global chained list will be all released, i.e., global chained list is sky.In other words, if executable program is held
The overall situation chained list is not sky after row, it is determined that there are RAM leakages.
The call relation of internal memory operation function is the recalls information of internal memory operation function after update, executable program after update
In the process of implementation, after the update of the library of executable program and its dependence calling when internal memory operation function, internal memory operation letter after update
Number can call internal memory operation function after updating according to the calling chain relation of the call stack acquisition of information of the current function function
Function, the function of function etc. for calling internal memory operation function after update, such as _ _ builtin_return_ can be passed through
Address functions etc. obtain the return address information of function, to obtain the call relation of function, and are chased after according to the call relation
It traces back the process of RAM leakage.
After the present embodiment is by determining that the second memory can trace and judge global chained list not for sky, traced according to call relation
The process of RAM leakage obtains the execution for leading to memory overflow by the execution route of internal memory operation function after acquisition update
Journey so that exploitation and tester are to the position of memory overflow and to occur memory overflow why very clear, without consuming
Time and efforts goes analysis code logic again.
Further, on the basis of above method embodiment, pass through internal memory operation letter after the update described in S103
Second memory is added in global chained list by number, is specifically included:
Internal memory operation function is closed according to the call chain of the call stack acquisition of information current function of current function after the update
System, is stored in the head of second memory, and second memory is added in global chained list by the calling chain relation.
Specifically, in the process of implementation, internal memory operation function is called in the library of executable program and its dependence to executable program
When, the internal memory operation function after being the update of calling, internal memory operation function can be according to the calling of current function after the update
The calling chain relation of the stack acquisition of information function calls the function of internal memory operation function, calls the function of internal memory operation function
Function etc., such as the return address information of function is obtained by _ _ builtin_return_address functions etc., to obtain
The call chain of function is taken, then which is suspended in global chained list by these information storages on the head of the memory of distribution, with
It is convenient subsequently to occur tracing RAM leakage process when Memory Leaks.
Further, on the basis of above method embodiment, the method further includes:
If the call number of S105, the call chain once obtained afterwards is more than the call number of the preceding call chain once obtained,
It then determines that there are RAM leakages, and traces the process of RAM leakage according to the call relation of internal memory operation function after the update.
Specifically, for executable program identical with system operation time (such as background process deamon processes) and
Speech, life cycle and system synchronization, therefore the executable program is not present in step S104 and executes the case where terminating, because should
At the end of executable program executes, system also terminates to run, and computer can not carry out judgement and subsequent processing.Therefore, Ke Yitong
The call number of statistics call chain is crossed, if number is incremented by, illustrates that the call chain results in memory overflow.
Specifically, the memory information on chained list is read, reading manner can be read in executable program specific position,
It can sometime be read in executable program by way of sending signal;Then identical call chain in memory information is counted
Number then illustrates that the corresponding implementation procedure of the call chain can occur memory and let out if twice in statistic processes, number has increase
Leakage can further trace the process of RAM leakage according to the call relation of internal memory operation function after the update.
For example, as shown in Figure 2, it is first determined the set of internal memory operation function, according to the primary internal memory operation letter
Number realizes new internal memory operation function, that is, internal memory operation function after updating so that internal memory operation function can after the update again
Record Memory Allocation information;Then internal memory operation function after the update in Hook executable programs is hooked up, executable program is run,
And the start-stop address of dynamic bank code for obtaining executable program and its being relied on, determine whether to trace according to start-stop address;
Judge whether current be memory release function, if it is, remove the memory of release from global chained list, otherwise by it is current more
The recalls information of internal memory operation function is recorded in the memory of distribution after new, while the memory of distribution is added to global chained list
On;By reading the memory information on chained list, the number of internal memory operation function call after statistical updating, if the number called is passed
Increase, it is determined that call chain occurs RAM leakage and determines RAM leakage mistake by call relation if RAM leakage process can be traced
Journey.
Further, it on the basis of above method embodiment, is generated according to primary internal memory operation function described in S101
Internal memory operation function after update, specifically includes:
Under conditions of calling the logic of the primary internal memory operation function in not changing executable program and calling code,
The environmental variance or Hook Function of the preloading of the primary internal memory operation function are changed, or redefines the primary memory behaviour
Make the linking relationship of function, or linker is preferentially parsed according to target identification.
Specifically, during realizing internal memory operation function again, primary internal memory operation letter can be obtained by dlsym
Number, such as malloc functions;Then by the prototype of the prototype for the internal memory operation function realized again and primary internal memory operation function
It is consistent, such as realizes malloc functions void*malloc (size_t size);Pass through the primary internal memory operation letter of acquisition
The memory of number distribution, the memory addition head and tail portion, head distributed to primary internal memory operation function contain to be used
Memory relevant information:Memory initial address, the recalls information of the function, memory total size etc., can also divide by other means
With memory.
The logic and tune of internal memory operation function are called in not changing executable program (library file etc. for including its dependence)
Under conditions of code, internal memory operation function after update can be generated in several ways:
For example, replacing executable program using the method for hook and its relying on the internal memory operation function in library file, hook
Method have:Change LD_PRELOAD environmental variances;Alternatively, hook (hook) function of primary internal memory operation function is changed,
Such as _ _ malloc_hook realizes internal memory operation function again;Alternatively, linked by-l when executable program links, with
After the linking relationship for redefining primary internal memory operation function, internal memory operation function after being updated;Again alternatively, passing through-wrap
(target identification) preferential parsing _ _ wrap_symbol linkers are identified, wherein symbol is the symbol of various internal memory operation functions,
Such as malloc, realloc function, then realization _ _ wrap_malloc.
The present embodiment can navigate to the position of memory overflow and lead to the process of memory overflow, rather than only position memory
Leakage point, why can allow exploitation and the open-and-shut position for knowing memory overflow of tester and can occur memory and let out
Leakage goes analysis code logic again without exploitation or tester.
Fig. 3 shows a kind of structural schematic diagram of RAM leakage process retrospective device provided in this embodiment, described device
Including:Memory refreshing module 301, retrospect judgment module 302, internal memory operation module 303 and leakage trace back block 304, wherein:
The memory refreshing module 301 is used to, according to internal memory operation function after the generation update of primary internal memory operation function, lead to
The the first memory addition head and tail portion for crossing primary internal memory operation function distribution described in internal memory operation function pair after the update, obtain
To the second memory;
If the retrospect judgment module 302 is used for according to the executable program obtained in advance and the dynamic base for retaining stack frame
The start-stop address of virtual address judges to know the address of internal memory operation function after the update in the start-stop address, it is determined that
Second memory can trace;
Second memory for being added to by the internal memory operation module 303 by internal memory operation function after the update
In global chained list, second memory is removed from the global chained list or, discharging function by memory;
If it is not sky that the leakage trace back block 304, which is used for the global chained list after the executable program executes,
It then determines that there are RAM leakages, and traces the process of RAM leakage according to the call relation of internal memory operation function after the update.
Specifically, internal memory operation function after the memory refreshing module 301 is updated according to the generation of primary internal memory operation function,
Head and tail portion are added by the first memory of primary internal memory operation function distribution described in internal memory operation function pair after the update,
Obtain the second memory;If the retrospect judgment module 302 is according to the dynamic base of the executable program and reservation stack frame that obtain in advance
The start-stop address of virtual address judge the address for knowing internal memory operation function after the update in the start-stop address, then really
Fixed second memory can trace;The internal memory operation module 303 is by internal memory operation function after the update by described second
Memory is added in global chained list, removes from the global chained list second memory or, discharging function by memory;Institute
If it is not sky to state the global chained list after leakage 304 executable program of trace back block executes, it is determined that there are memories
Leakage, and according to the process of the call relation retrospect RAM leakage of internal memory operation function after the update.
After the present embodiment is by determining that the second memory can trace and judge global chained list not for sky, traced according to call relation
The process of RAM leakage obtains the execution for leading to memory overflow by the execution route of internal memory operation function after acquisition update
Journey so that exploitation and tester are to the position of memory overflow and to occur memory overflow why very clear, without consuming
Time and efforts goes analysis code logic again.
Further, on the basis of above-mentioned apparatus embodiment, the internal memory operation module 303 is specifically used for the update
Internal memory operation function closes the call chain according to the calling chain relation of the call stack acquisition of information current function of current function afterwards
System is stored in the head of second memory, and second memory is added in global chained list.
Further, on the basis of above-mentioned apparatus embodiment, described device further includes:
Judgment module is revealed, if the call number of the call chain for once obtaining afterwards is more than the preceding call chain once obtained
Call number, it is determined that there are RAM leakages, and according to after the update internal memory operation function call relation trace memory
The process of leakage.
Further, on the basis of above-mentioned apparatus embodiment, the memory refreshing module has 301 bodies for not changing
Under conditions of calling the logic of the primary internal memory operation function in executable program and calling code, the primary memory is changed
The environmental variance or Hook Function of the preloading of handling function, or redefine the link pass of the primary internal memory operation function
System, or linker is preferentially parsed according to target identification.
Further, on the basis of above-mentioned apparatus embodiment, the information stored in the head includes:Recalls information,
The memory address of distribution, the memory address of actual use, the memory total size of distribution, the memory total size of actual use and memory
It crosses the border confirmation message.
RAM leakage process retrospective device described in the present embodiment can be used for execute above method embodiment, principle and
Technique effect is similar, and details are not described herein again.
Reference Fig. 4, the electronic equipment, including:Processor (processor) 401, memory (memory) 402 and total
Line 403;
Wherein,
The processor 401 and memory 402 complete mutual communication by the bus 403;
The processor 401 is used to call the program instruction in the memory 402, to execute above-mentioned each method embodiment
The method provided.
The present embodiment discloses a kind of computer program product, and the computer program product includes being stored in non-transient calculating
Computer program on machine readable storage medium storing program for executing, the computer program include program instruction, when described program instruction is calculated
When machine executes, computer is able to carry out the method that above-mentioned each method embodiment is provided.
The present embodiment provides a kind of non-transient computer readable storage medium, the non-transient computer readable storage medium
Computer instruction is stored, the computer instruction makes the computer execute the method that above-mentioned each method embodiment is provided.
The apparatus embodiments described above are merely exemplary, wherein the unit illustrated as separating component can
It is physically separated with being or may not be, the component shown as unit may or may not be physics list
Member, you can be located at a place, or may be distributed over multiple network units.It can be selected according to the actual needs
In some or all of module achieve the purpose of the solution of this embodiment.Those of ordinary skill in the art are not paying creativeness
Labour in the case of, you can to understand and implement.
Through the above description of the embodiments, those skilled in the art can be understood that each embodiment can
It is realized by the mode of software plus required general hardware platform, naturally it is also possible to pass through hardware.Based on this understanding, on
Stating technical solution, substantially the part that contributes to existing technology can be expressed in the form of software products in other words, should
Computer software product can store in a computer-readable storage medium, such as ROM/RAM, magnetic disc, CD, including several fingers
It enables and using so that a computer equipment (can be personal computer, server or the network equipment etc.) executes each implementation
Method described in certain parts of example or embodiment.
It should be noted that:The above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although reference
Invention is explained in detail for previous embodiment, it will be understood by those of ordinary skill in the art that:It still can be right
Technical solution recorded in foregoing embodiments is modified or equivalent replacement of some of the technical features;And this
A little modification or replacements, the spirit and model of various embodiments of the present invention technical solution that it does not separate the essence of the corresponding technical solution
It encloses.
Claims (12)
1. a kind of RAM leakage process tracing method, which is characterized in that including:
Internal memory operation function after updating is generated according to primary internal memory operation function, passes through internal memory operation function pair institute after the update
The the first memory addition head and tail portion for stating primary internal memory operation function distribution, obtain the second memory;
If judging to know according to the start-stop address of the executable program obtained in advance and the virtual address for the dynamic base for retaining stack frame
The address of internal memory operation function is in the start-stop address after the update, it is determined that second memory can trace;
Second memory is added in global chained list by internal memory operation function after the update, or, being discharged by memory
Function removes second memory from the global chained list;
If the global chained list is not sky after the executable program execution, it is determined that there are RAM leakages, and according to institute
State the process of the call relation retrospect RAM leakage of internal memory operation function after updating.
2. according to the method described in claim 1, it is characterized in that, described will be described by internal memory operation function after the update
Second memory is added in global chained list, is specifically included:
Internal memory operation function, will according to the calling chain relation of the call stack acquisition of information current function of current function after the update
The calling chain relation is stored in the head of second memory, and second memory is added in global chained list.
3. according to the method described in claim 1, it is characterized in that, the method further includes:
If the call number of the call chain once obtained afterwards is more than the call number of the preceding call chain once obtained, it is determined that exist
RAM leakage, and according to the process of the call relation retrospect RAM leakage of internal memory operation function after the update.
4. according to claim 1-3 any one of them methods, which is characterized in that described to be generated according to primary internal memory operation function
Internal memory operation function after update, specifically includes:
Under conditions of calling the logic of the primary internal memory operation function in not changing executable program and calling code, modification
The environmental variance or Hook Function of the preloading of the primary internal memory operation function, or redefine the primary internal memory operation letter
Several linking relationships, or linker is preferentially parsed according to target identification.
5. according to claim 1-3 any one of them methods, which is characterized in that the information stored in the head includes:It adjusts
It is always big with information, the memory address of distribution, the memory address of actual use, the memory total size of distribution, the memory of actual use
Small and memory overwriting confirmation message.
6. a kind of RAM leakage process retrospective device, which is characterized in that including:
Memory refreshing module, for according to internal memory operation function after the generation update of primary internal memory operation function, passing through the update
The the first memory addition head and tail portion of primary internal memory operation function distribution described in internal memory operation function pair afterwards, obtains in second
It deposits;
Judgment module is traced, if for according to the executable program obtained in advance and the virtual address for the dynamic base for retaining stack frame
Start-stop address judges the address for knowing internal memory operation function after the update in the start-stop address, it is determined that in described second
Depositing can trace;
Internal memory operation module, for second memory to be added to global chained list by internal memory operation function after the update
In, second memory is removed from the global chained list or, discharging function by memory;
Trace back block is revealed, if the global chained list is not sky after being executed for the executable program, it is determined that exist
RAM leakage, and according to the process of the call relation retrospect RAM leakage of internal memory operation function after the update.
7. device according to claim 6, which is characterized in that in the internal memory operation module is specifically used for after the update
Calling chain relation of the handling function according to the call stack acquisition of information current function of current function is deposited, the calling chain relation is deposited
Storage is added on the head of second memory, and by second memory in global chained list.
8. device according to claim 6, which is characterized in that described device further includes:
Judgment module is revealed, if the call number of the call chain for once obtaining afterwards is more than the tune of the preceding call chain once obtained
With number, it is determined that there are RAM leakages, and trace RAM leakage according to the call relation of internal memory operation function after the update
Process.
9. according to claim 6-8 any one of them devices, which is characterized in that the memory refreshing module is specifically used for not
Under conditions of changing the logic for calling the primary internal memory operation function in executable program and calling code, modification is described primary
The environmental variance or Hook Function of the preloading of internal memory operation function, or redefine the link of the primary internal memory operation function
Relationship, or linker is preferentially parsed according to target identification.
10. according to claim 6-8 any one of them devices, which is characterized in that the information stored in the head includes:It adjusts
It is always big with information, the memory address of distribution, the memory address of actual use, the memory total size of distribution, the memory of actual use
Small and memory overwriting confirmation message.
11. a kind of electronic equipment, which is characterized in that including:
At least one processor;And
At least one processor being connect with the processor communication, wherein:
The memory is stored with the program instruction that can be executed by the processor, and the processor calls described program to instruct energy
Enough methods executed as described in claim 1 to 5 is any.
12. a kind of non-transient computer readable storage medium, which is characterized in that the non-transient computer readable storage medium is deposited
Computer program is stored up, the computer program makes the computer execute the method as described in claim 1 to 5 is any.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810316302.8A CN108664394B (en) | 2018-04-10 | 2018-04-10 | Memory leakage process tracing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810316302.8A CN108664394B (en) | 2018-04-10 | 2018-04-10 | Memory leakage process tracing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108664394A true CN108664394A (en) | 2018-10-16 |
CN108664394B CN108664394B (en) | 2021-12-14 |
Family
ID=63783413
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810316302.8A Active CN108664394B (en) | 2018-04-10 | 2018-04-10 | Memory leakage process tracing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108664394B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109828916A (en) * | 2018-12-29 | 2019-05-31 | 航天信息股份有限公司 | A kind of method and system solving memory overflow |
CN110413521A (en) * | 2019-07-24 | 2019-11-05 | 杭州迪普信息技术有限公司 | A kind of the write-overflow detection method and device of heap memory |
CN111858112A (en) * | 2019-04-26 | 2020-10-30 | 腾讯科技(深圳)有限公司 | Method for detecting memory leak, client and server |
CN111931191A (en) * | 2020-09-09 | 2020-11-13 | 中国人民解放军国防科技大学 | Dynamic detection method and system for binary software stack overflow leakage hole of Linux platform |
CN113377522A (en) * | 2020-03-09 | 2021-09-10 | 大唐移动通信设备有限公司 | Method and device for processing memory blocks in memory pool, electronic equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101593152A (en) * | 2009-06-25 | 2009-12-02 | 青岛海信移动通信技术股份有限公司 | A kind of portable terminal memory leakage detecting method and device |
US20110093748A1 (en) * | 2007-05-25 | 2011-04-21 | International Business Machines Corporation | Software Memory Leak Analysis Using Memory Isolation |
CN106648893A (en) * | 2016-12-20 | 2017-05-10 | 北京匡恩网络科技有限责任公司 | Memory management method and memory management equipment |
CN106844216A (en) * | 2017-01-25 | 2017-06-13 | 深圳怡化电脑股份有限公司 | The localization method and system of a kind of RAM leakage |
CN106933733A (en) * | 2015-12-30 | 2017-07-07 | 华为技术有限公司 | A kind of method and apparatus for determining RAM leakage position |
-
2018
- 2018-04-10 CN CN201810316302.8A patent/CN108664394B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110093748A1 (en) * | 2007-05-25 | 2011-04-21 | International Business Machines Corporation | Software Memory Leak Analysis Using Memory Isolation |
CN101593152A (en) * | 2009-06-25 | 2009-12-02 | 青岛海信移动通信技术股份有限公司 | A kind of portable terminal memory leakage detecting method and device |
CN106933733A (en) * | 2015-12-30 | 2017-07-07 | 华为技术有限公司 | A kind of method and apparatus for determining RAM leakage position |
CN106648893A (en) * | 2016-12-20 | 2017-05-10 | 北京匡恩网络科技有限责任公司 | Memory management method and memory management equipment |
CN106844216A (en) * | 2017-01-25 | 2017-06-13 | 深圳怡化电脑股份有限公司 | The localization method and system of a kind of RAM leakage |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109828916A (en) * | 2018-12-29 | 2019-05-31 | 航天信息股份有限公司 | A kind of method and system solving memory overflow |
CN109828916B (en) * | 2018-12-29 | 2023-04-21 | 航天信息股份有限公司 | Method and system for solving memory leakage |
CN111858112A (en) * | 2019-04-26 | 2020-10-30 | 腾讯科技(深圳)有限公司 | Method for detecting memory leak, client and server |
CN111858112B (en) * | 2019-04-26 | 2023-04-25 | 腾讯科技(深圳)有限公司 | Method, client and server for detecting memory leakage |
CN110413521A (en) * | 2019-07-24 | 2019-11-05 | 杭州迪普信息技术有限公司 | A kind of the write-overflow detection method and device of heap memory |
CN110413521B (en) * | 2019-07-24 | 2023-01-24 | 杭州迪普信息技术有限公司 | Write-crossing detection method and device for heap memory |
CN113377522A (en) * | 2020-03-09 | 2021-09-10 | 大唐移动通信设备有限公司 | Method and device for processing memory blocks in memory pool, electronic equipment and storage medium |
CN111931191A (en) * | 2020-09-09 | 2020-11-13 | 中国人民解放军国防科技大学 | Dynamic detection method and system for binary software stack overflow leakage hole of Linux platform |
Also Published As
Publication number | Publication date |
---|---|
CN108664394B (en) | 2021-12-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108664394A (en) | A kind of RAM leakage process tracing method and device | |
CN105302738B (en) | A kind of memory allocation method and device | |
CN105446834B (en) | The generation method and device of virtual machine snapshot | |
CN110389843B (en) | Service scheduling method, device, equipment and readable storage medium | |
CN104063293B (en) | A kind of data back up method and stream calculation system | |
CN103399781B (en) | Cloud Server and virtual machine management method thereof | |
CN112769810B (en) | Firewall testing method and device, nonvolatile storage medium and electronic device | |
CN108491254A (en) | A kind of dispatching method and device of data warehouse | |
CN106685894B (en) | Risk identification method, device and system | |
CN106528293A (en) | Database access method and apparatus | |
CN116701043B (en) | Heterogeneous computing system-oriented fault node switching method, device and equipment | |
CN112579692A (en) | Data synchronization method, device, system, equipment and storage medium | |
CN110737504A (en) | deep learning model training fault-tolerant method, system, terminal and storage medium | |
CN105243003A (en) | Memory allocation monitoring method and apparatus | |
CN111176924B (en) | GPU card dropping simulation method, system, terminal and storage medium | |
CN110727585B (en) | Memory leak detection method, device, electronic equipment and readable storage medium | |
CN108055161A (en) | A kind of networking optimization method and device | |
CN103593606B (en) | Context information management method and system | |
CN108021448B (en) | Kernel space optimization method and device | |
CN105243011A (en) | Memory leak positioning method and apparatus | |
CN112637793B (en) | Scene charging method, system, electronic equipment and storage medium based on 5G | |
CN110795334B (en) | Testing device and method | |
CN110221952B (en) | Service data processing method and device and service data processing system | |
CN114064678A (en) | Event data processing method and device and terminal equipment | |
CN113011422A (en) | Supply chain supervision method and device based on pattern recognition and computer equipment |
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 | ||
CB02 | Change of applicant information |
Address after: Room 332, 3 / F, Building 102, 28 xinjiekouwei street, Xicheng District, Beijing 100088 Applicant after: Qianxin Technology Group Co.,Ltd. Address before: 100015 15, 17 floor 1701-26, 3 building, 10 Jiuxianqiao Road, Chaoyang District, Beijing. Applicant before: BEIJING QIANXIN TECHNOLOGY Co.,Ltd. |
|
CB02 | Change of applicant information | ||
GR01 | Patent grant | ||
GR01 | Patent grant |