CN1248114C - Method for checking sofeware memory leak - Google Patents

Method for checking sofeware memory leak Download PDF

Info

Publication number
CN1248114C
CN1248114C CN 02121418 CN02121418A CN1248114C CN 1248114 C CN1248114 C CN 1248114C CN 02121418 CN02121418 CN 02121418 CN 02121418 A CN02121418 A CN 02121418A CN 1248114 C CN1248114 C CN 1248114C
Authority
CN
China
Prior art keywords
memory
internal memory
application
inspection
module
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.)
Expired - Fee Related
Application number
CN 02121418
Other languages
Chinese (zh)
Other versions
CN1466057A (en
Inventor
叶顺福
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN 02121418 priority Critical patent/CN1248114C/en
Publication of CN1466057A publication Critical patent/CN1466057A/en
Application granted granted Critical
Publication of CN1248114C publication Critical patent/CN1248114C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The present invention discloses a method for checking the leakage of a software memory. The method firstly determines memory blocks applied by an application and the time occupied by applying different memory blocks, and records the information of the application applying the memory blocks and releasing the memory blocks when the application runs. Finally, the method determines the memory blocks not released beyond occupation time, and determines the memory leakage points of the application through the memory blocks. The scheme has little influence on the application when the scheme is used for checking the memory leakage of the application, and the scheme is easy to realize and has low cost. The present invention is good for checking the memory leakage possible to occur for a long time in the running process of the application, and helps to find memory leakage mistakes generated by the application in some actual environments or hidden memory leakage mistakes.

Description

The inspection method that a kind of software memory is revealed
Technical field
The present invention relates to the method for testing of software performance, relate in particular to the inspection method that software memory is revealed.
Background technology
In many defectives of software (application program in other words), memory overflow is the mistake of a difficult discovery.Cause software memory leakage reasons possibility diversified, for example may cause, also may cause by operating system by design defect in software.In any case, if there is the defective of memory overflow in software, will cause system's free memory to reduce, operational efficiency descends; To those software that need run without interruption for a long time,, also can cause Installed System Memory to exhaust until paralysis through long-term accumulation even once only leak seldom internal memory.Therefore, the memory overflow inspection of software is important inspection item in the test.Present software memory is revealed and is checked that general some special-purpose internal memory checking tools that adopt carry out, although these instruments can detect the EMS memory error operation of most of software.But use these instruments that several weak points are also arranged: the one, these instruments all are large scale business software mostly, cost is higher; The 2nd, these instruments are to realize the operation monitoring of internal memory by insert the supervision code in executable file, make the program code or the capacity of software will increase a lot, operation is got up and is also wanted slow a lot, can only when being in test phase, use by software, promptly can only carry out static check, can't detect during the formal on-line operation of software, and some more hidden memory overflows, only under the commencement of commercial operation environment, could occur, catch these memory overflows, the method that above-mentioned special-purpose internal memory checking tool provides is powerless.
Summary of the invention
The inspection method that the object of the present invention is to provide a kind of cost software memory lower, that can when the software on-line operation, check to reveal.
For achieving the above object, the inspection method that software memory provided by the invention is revealed comprises:
A, determine the memory block of application program, and the occupied time of different memory blocks of being applied for; Definition memory block record sheet is with the information of records application program application memory block and releasing memory piece; The memory block counter is set, and the memory block that is used for application programs application and release manages;
B. when application program is moved, write down the information of its application memory block and releasing memory piece;
C. determine to surpass the memory block that holding time does not discharge as yet, determine the internal memory leak point of application program by above-mentioned memory block.
Said method is revealed the realization of inspection module by embed internal memory in application program.
Because the present invention is when application program is moved, write down the information of its application memory block and releasing memory piece, by determining to determine the internal memory leak point of software above the memory block that holding time does not discharge as yet, the realization of said method can be finished by embed special-purpose internal memory leakage module in application program, like this, the internal memory that adopts method of the present invention not only to be fit to application programs is revealed and is carried out On line inspection, also owing to when application program is moved, only write down the information of its application memory block and releasing memory piece, application programs has lessly to be influenced, and is easy to realization and with low cost; Therefore, adopt the present invention to help in the application program operational process, issuable internal memory leakage being detected for a long time, help to find just that occur or more hidden memory overflow mistake under some actual environments; Simultaneously, by the control module of special use internal memory being revealed the inspection module controls, make internal memory reveal each step time length of inspection (mainly being the state of wait release or the duration of step) and controlled, take the different memory block of duration thereby can adapt to.In addition, the memory overflow inspection of using this method to carry out can start and stop at any time, thereby the influence of checking application programs can further be controlled, and for example can avoid having a lot of work to do the phase of program, when program is idle, start and check, perhaps shorten duration of checking or the like.
Description of drawings
Fig. 1 is the embodiment process flow diagram of the method for the invention;
Fig. 2 is the graph of a relation that the memory overflow of the described embodiment employing of Fig. 1 is checked module and other module of application program;
Fig. 3 is that memory overflow is checked the inside modules building-block of logic;
Fig. 4 is that memory overflow is checked the state transition diagram of module when carrying out internal memory leakage inspection.
Embodiment
The present invention is described in further detail below in conjunction with accompanying drawing.
Fig. 1 is the embodiment process flow diagram of the method for the invention.The essence of the described method of Fig. 1, be to check module by in application program, embedding a memory overflow, internal memory applications all in the application program and releasing operation are all undertaken by this module, information such as the address of the memory block by this module records application program and release, time again, realize supervision, thereby finish the inspection that the application program internal memory is revealed the internal memory behaviour in service.
Implement the present invention according to Fig. 1, at first a memory overflow is set and checks module through step 1, and it is embedded in the application program, and define the information that a memory block record sheet comes the memory block of memory block that other modules of records application program are applied for and release, the memory block record sheet in this example is a Hash table.A memory block counter also is set simultaneously, is used for the memory block of Hash table is managed; Internal memory is set reveals the control module of checking module.The information of the memory block that writes down in Hash table comprises start address, memory block size, zero-time of memory block etc., can also write down some Debugging message, as the file at the code place of application for execution operation, row number etc., with the start address of memory block key word as Hash table, because the start address of two memory blocks of same process application is not the same, therefore can guarantee that the element key word in the Hash table does not repeat.When other module invokes memory overflow in the program is checked module application internal memory, the interface application internal memory that provides of call operation system at first is if an element is then added in the success of application internal memory in Hash table, write down the information of this memory block, and increase the value of counter.If other module invokes memory overflow in the application program is checked module releasing memory, is that key word is searched corresponding record in Hash table with the memory block start address then, find the back value of deleting this record and reducing corresponding counter.
The memory overflow that step 1 is provided with checks that the inside modules logical organization is with reference to figure 3.Shown in Figure 3, after application program is successfully applied for memory block, reveal the application memory interface of checking module by internal memory and in Hash table, insert a memory block information record, simultaneously the value of refresh counter; Behind application program success releasing memory piece, reveal the releasing memory interface of checking module by internal memory and in Hash table, delete a corresponding memory block information record, simultaneously the value of refresh counter.
The memory overflow that is provided with in step 1 checks that the relation of module and other module of application program and control module is with reference to figure 2.Shown in Figure 2, other module of application program is when the application of carrying out memory block and releasing operation, all to reveal and check module management, will reveal the memory block of checking module management application and release by internal memory when promptly carrying out the application of memory block and discharging in the call operation system through internal memory; Internal memory is revealed the inspection module and is controlled by control module, and gives the control module analyzing and processing with check result.
Determine the memory block of application program needs application in step 2 according to the concrete condition of application program then, and the occupied time of different memory blocks of being applied for, perhaps may the occupied time.Then run application, and in the information of step 3 with Hash table records application program application memory block and releasing memory piece; Carry out internal memory when reveal analyzing at needs, reveal the memory block that holding time does not discharge as yet that surpasses of checking that module determines in step 4 by internal memory, determine the internal memory leak point of application program by control module.
Control internal memory for ease of control module and reveal the inspection that the inspection module is carried out the leakage of application program internal memory, establish a mode field in addition in internal memory leakage inspection module in this example and come the current state of logging modle, and carry out corresponding action according to it.In control module internal memory tunnelling ray piece is controlled and to be carried out memory overflow when checking, reveal the inspection module by the internal memory in being embedded into application program and send signal or message, the memory overflow checked operation is carried out in the state transition that impels the memory overflow detection module to be fit to.It is as follows that internal memory is revealed each state and the transition relationship between state of checking module:
1) idle condition: under this state, memory overflow inspection module is not carried out record to internal memory application and releasing operation, and these operations are all passed to operating system pellucidly, and the Hash table sum counter in the module also is in the state of emptying.
2) operation note state: when under " idle condition ", receiving " starting record " signal that control module sends, enter this state.Under this state, memory overflow checks that module is according to internal memory application and releasing operation in the method logging program of front.
3) wait for release conditions: receive under " operation note state " that control module sends " stop to insert,, enter this state during signal.Under this state, memory overflow inspection module is only carried out record to the operation of releasing memory, and does not write down the operation of application internal memory.Why to there be this stage, be because the memory block of program application just discharges after always being to use a period of time, the release conditions of the memory block of applying for for complete record prevents wrong report, must be longer than record to the application operation to the record of releasing operation.Need to prove that the time span in this stage can be adjusted as required, principle is to have time enough to be released in the internal memory of being applied in " operation note state " by application program.Just think possible memory overflow through the internal memory that this stage does not also discharge.For example, if knowing certain partial memory resource of applying in the application program uses after one hour at most and will discharge, at first allow memory overflow check that module writes down some internal memory applications at " operation note state ", enter " wait release conditions " then, wait for one hour, if also have the memory source of this part not discharge, then can think memory overflow.
4) halted state: enter this state when under " wait release conditions ", receiving the "signal for " stop " that control module sends.Under this state, internal memory application and releasing operation are not write down in the memory overflow inspection yet, but the data of record when also keeping state 2 and state 3 in the Hash table sum counter can inquire about or allow memory overflow check that module outputs to file with data and carries out analyzing and processing by control module as required to these data.
During once complete memory overflow was checked, memory overflow inspection module will be passed through four kinds of top states successively, and the migration of its state is with reference to figure 4.As seen from Figure 4, by the control of control module, can allow memory overflow inspection module under any state, directly get back to idle condition.Signal or message control that switching between each state is sent by control module after once inspection finishes, just can come may produce in the analysis application place of leakage according to the information of the memory block that does not also discharge that writes down in the Hash table.
Check in the specific implementation of module at memory overflow, can select different hash algorithms, and adjust the size of Hash table, to adapt to the needs of various testing environments according to the frequent degree of internal memory application operation in the program.Simultaneously, the duration of each state of control module when internal memory is revealed inspection can be controlled, to satisfy actual control needs.

Claims (5)

1, a kind of inspection method of software memory leakage comprises:
A. determine the memory block of application program, and the occupied time of different memory blocks of being applied for; Define the memory block record sheet, be used for the information of records application program application memory block and releasing memory piece; The memory block counter is set, and the memory block that is used for application programs application and release manages;
B. when application program is moved, write down the information of its application memory block and releasing memory piece;
C. determine to surpass the memory block that holding time does not discharge as yet, determine the internal memory leak point of application program by above-mentioned memory block.
2, the inspection method of software memory leakage according to claim 1 is characterized in that: described memory block record sheet is Hash (HASH) table.
3, the inspection method of software memory leakage according to claim 1 and 2 is characterized in that: described method is revealed the realization of inspection module by embed internal memory in application program.
4, the inspection method of software memory leakage according to claim 3 is characterized in that: control module is set, carries out the inspection that internal memory is revealed to reveal the inspection module from application program external control internal memory.
5, the inspection method of software memory leakage according to claim 4 is characterized in that: control module control internal memory leakage inspection module realizes that according to following step the migration of state is to carry out the inspection of internal memory leakage:
(51) internal memory is revealed and checked that module is in idle condition, when needs carry out internal memory leakage analysis, check module transmit operation tracer signal, make it enter the internal memory application and the releasing operation of operation note state recording application program to the internal memory leakage;
(52) after record a period of time, reveal to check to internal memory that module sends and stop to insert tracer signal, make it enter the wait release conditions, only write down memory discharge operation and do not write down internal memory application operation, wait for that the memory block that does not discharge as yet that writes down in the Hash table discharges;
(53) when needs determine whether to exist internal memory to reveal, reveal the inspection module to internal memory and send stop signal, make it enter halted state and determine whether to exist internal memory to reveal with analysis;
(54) when needs restart internal memory leakage inspection, reveal the inspection module to internal memory and send reset signal, change the internal memory leakage inspection that step (51) is carried out a new round then.
CN 02121418 2002-06-20 2002-06-20 Method for checking sofeware memory leak Expired - Fee Related CN1248114C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 02121418 CN1248114C (en) 2002-06-20 2002-06-20 Method for checking sofeware memory leak

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 02121418 CN1248114C (en) 2002-06-20 2002-06-20 Method for checking sofeware memory leak

Publications (2)

Publication Number Publication Date
CN1466057A CN1466057A (en) 2004-01-07
CN1248114C true CN1248114C (en) 2006-03-29

Family

ID=34142185

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 02121418 Expired - Fee Related CN1248114C (en) 2002-06-20 2002-06-20 Method for checking sofeware memory leak

Country Status (1)

Country Link
CN (1) CN1248114C (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100504811C (en) * 2007-06-13 2009-06-24 中兴通讯股份有限公司 Method for detecting RAM leakage
CN107179949A (en) * 2016-12-16 2017-09-19 重庆大学 It is a kind of to be used for the quantization method that operating system memory in mobile device distributes fluency

Families Citing this family (31)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100382043C (en) * 2004-09-20 2008-04-16 华为技术有限公司 Device and method for internal storage monitoring
CN100389403C (en) * 2005-04-07 2008-05-21 华为技术有限公司 Memory leakage detection and prevention method
CN100392606C (en) * 2005-07-14 2008-06-04 中兴通讯股份有限公司 Method for leaking memory of positioning virtual operation system
CN100462925C (en) * 2005-12-08 2009-02-18 中兴通讯股份有限公司 Method for automatically releasing applied programe module leaked memory in inlaid system
CN100388233C (en) * 2005-12-29 2008-05-14 兆日科技(深圳)有限公司 Simple method for deciding embedded system internal storage disclose of no-operation system
CN101339533B (en) * 2007-07-04 2012-10-10 国际商业机器公司 Method and device for diagnosing Java system EMS memory leakage based on partition
CN101419568B (en) * 2007-10-26 2010-11-03 英业达股份有限公司 Computer executable translation software testing system and method thereof
CN101615143B (en) * 2008-06-27 2013-04-17 国际商业机器公司 Method and device for diagnosing memory leak
CN101414272B (en) * 2008-10-17 2011-06-08 上海华为技术有限公司 Method and apparatus for detecting memory leakage
CN101587455B (en) * 2008-12-11 2010-09-22 南京南瑞继保电气有限公司 Method for checking memory leak for vxWorks operating system
CN101539976B (en) * 2009-04-23 2011-08-31 南京大学 Real-time detection system of binary program memory decay attack
CN102043672A (en) * 2009-10-13 2011-05-04 中兴通讯股份有限公司 Method and system for managing iterators
CN102053868B (en) * 2009-11-04 2016-08-10 突触计算机系统(上海)有限公司 A kind of method for detecting memory leakage and device
CN101814049A (en) * 2010-03-23 2010-08-25 北京大学 Memory leak detection method
CN101819549B (en) * 2010-04-13 2012-10-10 东莞宇龙通信科技有限公司 Method and device for positioning memory leakage
CN102262582A (en) * 2010-05-25 2011-11-30 芯讯通无线科技(上海)有限公司 Mobile terminal and method for detecting memory leakage thereof
CN101908018B (en) * 2010-07-20 2012-09-26 北京海泰方圆科技有限公司 System and method for judging memory leak
US8626993B2 (en) * 2011-11-18 2014-01-07 Apple Inc. Method for tracking memory usages of a data processing system
CN104516817B (en) * 2012-05-15 2017-09-29 青岛海信移动通信技术股份有限公司 A kind of memory leakage detecting method and device
CN102681938B (en) * 2012-05-15 2015-02-18 青岛海信移动通信技术股份有限公司 Memory leakage detecting method and device
CN102904923B (en) * 2012-06-21 2016-01-06 华数传媒网络有限公司 A kind of method and system alleviating the digital independent of disk reading bottleneck
WO2014136182A1 (en) * 2013-03-04 2014-09-12 三菱電機株式会社 Management device and method for air conditioner
CN105302714B (en) * 2014-07-24 2019-02-05 腾讯科技(深圳)有限公司 The monitoring method and device of memory overflow in a kind of test process
CN105446871B (en) 2014-08-26 2018-08-17 华为技术有限公司 A kind of resource leakage detection method, apparatus and system
CN104731661B (en) * 2015-03-02 2018-12-14 大唐移动通信设备有限公司 A kind of method and device of the program operation resource of recycling leakage
CN105260313B (en) * 2015-10-27 2019-07-05 上海斐讯数据通信技术有限公司 Memory overflow checks system and method
CN105260314B (en) * 2015-11-03 2018-06-29 上海斐讯数据通信技术有限公司 The monitoring method of memory overflow
CN107436845A (en) * 2017-07-27 2017-12-05 南京华飞数据技术有限公司 A kind of Dram monitoring system and its monitoring method
CN108182146B (en) * 2017-12-27 2021-08-24 北京奇艺世纪科技有限公司 Method and system for detecting memory leakage
US10977105B2 (en) * 2018-12-14 2021-04-13 Uber Technologies, Inc. Memory crash prevention for a computing device
CN112527663A (en) * 2020-12-17 2021-03-19 杭州国芯科技股份有限公司 Method for detecting memory used by software in embedded system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100504811C (en) * 2007-06-13 2009-06-24 中兴通讯股份有限公司 Method for detecting RAM leakage
CN107179949A (en) * 2016-12-16 2017-09-19 重庆大学 It is a kind of to be used for the quantization method that operating system memory in mobile device distributes fluency
CN107179949B (en) * 2016-12-16 2020-11-24 重庆大学 Quantification method for operating system memory distribution fluency in mobile equipment

Also Published As

Publication number Publication date
CN1466057A (en) 2004-01-07

Similar Documents

Publication Publication Date Title
CN1248114C (en) Method for checking sofeware memory leak
CN110457277B (en) Service processing performance analysis method, device, equipment and storage medium
US7734666B2 (en) Method and system for inspecting memory leaks and analyzing contents of garbage collection files
US8141053B2 (en) Call stack sampling using a virtual machine
US7689872B2 (en) Autonomic program error detection and correction
CN100538656C (en) The method and apparatus of debugging computer program in distributed debugger
US7992136B2 (en) Method and apparatus for automatic application profiling
US6539341B1 (en) Method and apparatus for log information management and reporting
US20090024679A1 (en) Apparatus, system, and method for improving system performance in a large memory heap environment
US20080148241A1 (en) Method and apparatus for profiling heap objects
US20080091978A1 (en) Apparatus, system, and method for database management extensions
CN100440163C (en) Method and system for analysis processing of computer program
US20100031238A1 (en) Method and Apparatus for Locating Memory Leak in a Program
CA2549453A1 (en) Method and apparatus for synchronizing an industrial controller with a redundant controller
US8793289B2 (en) Method and system for detecting memory leaks and copying garbage collection files
CN103109276A (en) System testing method
CN101853200A (en) High-efficiency dynamic software vulnerability exploiting method
CN103488563A (en) Data race detection method and device for parallel programs and multi-core processing system
US20100131472A1 (en) Detection and utilzation of inter-module dependencies
US7634496B1 (en) Techniques for managing state changes of a data storage system utilizing the object oriented paradigm
US7174359B1 (en) Apparatus and methods for sequentially scheduling a plurality of commands in a processing environment which executes commands concurrently
US6240529B1 (en) Debugging method and debugging apparatus for microcomputer system and recording medium on which debug program is recorded
CN1845080A (en) Memory leakage detection and prevention method
CN1776644A (en) Method for monitoring internal memory varible rewrite based on finite-state-machine
CN118426689A (en) Data processing method, system and equipment for solid state disk

Legal Events

Date Code Title Description
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20060329

Termination date: 20120620