CN100504811C - Method for detecting RAM leakage - Google Patents
Method for detecting RAM leakage Download PDFInfo
- Publication number
- CN100504811C CN100504811C CNB2007100749443A CN200710074944A CN100504811C CN 100504811 C CN100504811 C CN 100504811C CN B2007100749443 A CNB2007100749443 A CN B2007100749443A CN 200710074944 A CN200710074944 A CN 200710074944A CN 100504811 C CN100504811 C CN 100504811C
- Authority
- CN
- China
- Prior art keywords
- memory block
- memory
- time
- long
- living
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
The present invention discloses a method for detecting the leaking of the memory. First, a linked list of the dynamic memory block information is established and the threshold value of the quantity of the long time-to-live memory block at the same application position is set; second the linked list is backtracked so as to check the time-to-live of the memory block gotten by the memory block information stored in the element of the linked list; the long time-to-live memory block is classified according to the applied position of the long time-to-live memory block; when the quantity of the long time-to-live memory block applied on the same application position is more than the threshold value of the quantity of the long time-to-live memory block on the same application position, the long time-to-live memory block is thought to have the memory leakage. On the premises of increasing a little additional expenditure, the technical proposal of the present invention improves the accuracy rate of the memory leakage inspection.
Description
Technical field
The present invention relates to a kind of method that internal memory is revealed that detects.
Background technology
General memory leaks the leakage that is meant heap memory.Heap memory is that program is distributed from heap, the internal memory of necessary explicit release after using, otherwise this piece internal memory can not be operated system recoveries, also can't be reused by program, has promptly produced memory overflow.
Memory overflow may cause program run unusual, and is bigger to the program influence of long-time running.Long memory overflow test and the product demand of going on the market as early as possible contradiction usually, and actual conditions test duration deficiency often.The little memory block that slowly occurs leaks and often can't be found in test, may go wrong after the client uses the sufficiently long time.In this case, need set up special mechanism at memory overflow and preserve wrong environment, help the developer to reappear environment, otherwise can only come the trouble-shooting point, can expend a large amount of manpowers by the investigation code.Whether long or application discharge whether judge whether to have taken place leakage in pairs to the method that existing detection internal memory is revealed according to the life span of internal memory, if there is memory overflow, when the size of free memory enters police circles' scope, by preserving internal storage state in order to reappearing in the future fault, and discharge the internal memory that leaks, make program can obtain abundant internal memory and normally move.These implementation methods have a shortcoming: because some memory blocks of dynamically applying for can not be released during program run all the time, their life cycle is equal to the life cycle of program, and this class memory block all can be mistaken for memory overflow as stated above.Program can obtain abundant internal memory because the memory overflow detection module also can discharge the memory block that has been considered to take place leakage normally moves, be mistaken for the internal memory of memory overflow and cause the normal memory blocks that use of program to be discharged if discharged these, serious consequence such as just may generating routine unusual by mistake.
Summary of the invention
The technical problem to be solved in the present invention provides the method that a kind of detection internal memory that can improve internal memory leak detection accuracy rate is revealed.
The technical solution adopted for the present invention to solve the technical problems is:
A kind of method that detects the internal memory leakage is characterized in that, comprising:
The first step is set up the chained list of dynamic memory memory block information, and sets the long-living time memory number of blocks threshold value of depositing of same application location;
Second step, travel through described chained list, check that the memory block information of each linked list element storage obtains the life span of each memory block, with each long-living deposit the time memory piece according to described each long-livingly deposit the position classification that the time memory piece is applied, if the described long-living time memory number of blocks of depositing that is applied on the same application location thinks then that greater than the long-living time memory number of blocks threshold value of depositing of described same application location the internal memory leakage has taken place described each long-living time memory piece of depositing.
In the such scheme, described same application location is meant the same delegation of the identical file of carrying out the memory block application and the position of same row.
In the such scheme, described life span is distribution time poor of current time of digital examination memory block information and described memory block.
In the such scheme, described each long-living memory block of depositing the time is meant that each life span surpasses the memory block of default life span thresholding.
In the such scheme, described memory block information comprises the distribution time of the size of the pointer that points to described memory block, described memory block, described memory block and the positional information of applying for described memory block.
In the such scheme, the positional information of described memory block comprise the file of applying for described memory block filename, the row number and row number.
Beneficial effect of the present invention mainly shows: technical scheme provided by the invention is slightly increasing under the prerequisite of overhead by setting the long-living time memory number of blocks threshold value of depositing of same application location, has improved the accuracy rate of internal memory leak detection.
Description of drawings
Fig. 1 detects the method flow diagram that internal memory is revealed for the present invention.
Embodiment
The invention will be further described below in conjunction with accompanying drawing.
As shown in Figure 1, set up the chained list of dynamic memory memory block information and set the long-living time memory number of blocks threshold value M that deposits of same application location, described memory block information comprises the distribution time of the size of the pointer that points to described memory block, described memory block, described memory block and the positional information of applying for described memory block, the positional information of described memory block comprises the filename, row number of the file of applying for described memory block and row number, and described positional information is by corresponding numbering storage.During the application memory block,, when discharging the memory block of having applied for, the memory block information of correspondence is deleted from chained list the memory block information adding chained list of correspondence; When carrying out the internal memory leak detection, travel through described chained list, check that the memory block information of each linked list element storage obtains the life span of each memory block, be distribution time poor of current time of calculating inspection memory block information and described memory block, then each long-living time memory piece of depositing is classified according to its position that is applied, if the described long-living time memory number of blocks of depositing that is applied on the same application location thinks then that greater than the long-living time memory number of blocks threshold value M that deposits of described same application location the internal memory leakage has taken place described each long-living time memory piece of depositing; Wherein, same application location is meant the same delegation of the identical file of carrying out the memory block application and the position of same row, and the long-living memory block of depositing the time is meant that life span surpasses the memory block of default life span thresholding.If M=2, and 3 memory blocks that have a same application location belong to the long-living memory block of depositing the time, and then these three memory blocks are considered to take place the internal memory leakage.
Claims (6)
1, a kind of method that detects the internal memory leakage is characterized in that, comprising:
The first step is set up the chained list of dynamic memory memory block information, and sets the long-living time memory number of blocks threshold value of depositing of same application location;
Second step, travel through described chained list, check that the memory block information of each linked list element storage obtains the life span of each memory block, with each long-living deposit the time memory piece according to described each long-livingly deposit the position classification that the time memory piece is applied, if the described long-living time memory number of blocks of depositing that is applied on the same application location thinks then that greater than the long-living time memory number of blocks threshold value of depositing of described same application location the internal memory leakage has taken place described each long-living time memory piece of depositing.
2, the method for detection internal memory leakage as claimed in claim 1, it is characterized in that: described same application location is meant the same delegation of the identical file of carrying out the memory block application and the position of same row.
3, the method revealed of detection internal memory as claimed in claim 2 is characterized in that: described life span is distribution time poor of current time of digital examination memory block information and described memory block.
4, the method for detection internal memory leakage as claimed in claim 3 is characterized in that: described each long-living memory block of depositing the time is meant that each life span surpasses the memory block of default life span thresholding.
5, the method for revealing as one of them described detection internal memory of claim 1 to 4, it is characterized in that: described memory block information comprises the distribution time of the size of the pointer that points to described memory block, described memory block, described memory block and the positional information of applying for described memory block.
6, the method revealed of detection internal memory as claimed in claim 5 is characterized in that: the positional information of described memory block comprises the filename, row number of the file of apply for described memory block and is listed as number.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2007100749443A CN100504811C (en) | 2007-06-13 | 2007-06-13 | Method for detecting RAM leakage |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2007100749443A CN100504811C (en) | 2007-06-13 | 2007-06-13 | Method for detecting RAM leakage |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101145128A CN101145128A (en) | 2008-03-19 |
CN100504811C true CN100504811C (en) | 2009-06-24 |
Family
ID=39207665
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2007100749443A Active CN100504811C (en) | 2007-06-13 | 2007-06-13 | Method for detecting RAM leakage |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100504811C (en) |
Families Citing this family (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101350744B (en) * | 2008-06-19 | 2013-08-07 | 中兴通讯股份有限公司 | Method for detecting descriptor resource of network processing system and system thereof |
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 |
CN102681938B (en) * | 2012-05-15 | 2015-02-18 | 青岛海信移动通信技术股份有限公司 | Memory leakage detecting method and device |
CN103914376A (en) * | 2014-03-12 | 2014-07-09 | 汉柏科技有限公司 | Method for rapidly positioning memory leak |
CN103914355A (en) * | 2014-03-12 | 2014-07-09 | 汉柏科技有限公司 | Method and device for positioning memory repeated release |
CN104572460A (en) * | 2014-12-30 | 2015-04-29 | 大唐移动通信设备有限公司 | Memory leak detecting method and memory leak detecting device |
CN105912458A (en) * | 2016-03-28 | 2016-08-31 | 中国电力科学研究院 | Method and system for dynamically detecting C/C++ memory leak |
CN107102922B (en) * | 2017-04-01 | 2020-08-07 | 北京三快在线科技有限公司 | Memory detection method and device and electronic equipment |
CN110858178A (en) * | 2018-08-07 | 2020-03-03 | 广州小鹏汽车科技有限公司 | Memory recovery method, device, equipment and medium |
CN109144872A (en) * | 2018-08-20 | 2019-01-04 | 杭州迪普科技股份有限公司 | Detection method, device, terminal device and the readable storage medium storing program for executing of memory overflow |
CN109992992B (en) * | 2019-01-25 | 2021-07-13 | 中国科学院数据与通信保护研究教育中心 | Credible sensitive data protection method and system |
CN112181830B (en) * | 2020-09-28 | 2022-08-09 | 厦门美柚股份有限公司 | Memory leak detection method, device, terminal and medium |
CN113687942B (en) * | 2021-07-16 | 2024-02-13 | 维沃移动通信有限公司 | Detection method and device and electronic equipment |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1248114C (en) * | 2002-06-20 | 2006-03-29 | 华为技术有限公司 | Method for checking sofeware memory leak |
CN1845080A (en) * | 2005-04-07 | 2006-10-11 | 华为技术有限公司 | Memory leakage detection and prevention method |
-
2007
- 2007-06-13 CN CNB2007100749443A patent/CN100504811C/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1248114C (en) * | 2002-06-20 | 2006-03-29 | 华为技术有限公司 | Method for checking sofeware memory leak |
CN1845080A (en) * | 2005-04-07 | 2006-10-11 | 华为技术有限公司 | Memory leakage detection and prevention method |
Also Published As
Publication number | Publication date |
---|---|
CN101145128A (en) | 2008-03-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN100504811C (en) | Method for detecting RAM leakage | |
CN100504807C (en) | EMS memory leakage testing method in communication apparatus system | |
CN205881469U (en) | Fault detection equipment of electronic equipment and memory that is used for having a plurality of memory locations of standing transient fault and permanent fault | |
CN112083338B (en) | Fuel cell power attenuation real-time monitoring and early warning method and system | |
CN103559115A (en) | SSD intelligent monitoring system based on SMART | |
CN101719095A (en) | Method and device for managing regression testing | |
CN100389403C (en) | Memory leakage detection and prevention method | |
CN105912458A (en) | Method and system for dynamically detecting C/C++ memory leak | |
CN104916875B (en) | Power battery pack fault diagnosis and maintenance method | |
CN102903395A (en) | Reliability testing method for memories | |
CN105025141A (en) | Method and device for testing electricity consumption of terminal | |
CN104244317A (en) | Method and device for determining indoor telephone traffic states and indoor telephone traffic amount | |
CN101819549B (en) | Method and device for positioning memory leakage | |
US9183139B2 (en) | Mainboard and method of backing up of baseboard management controller | |
CN117207778A (en) | Nondestructive testing method and system for vehicle parts | |
CN110888809B (en) | Risk prediction method and device for test task | |
CN102375776A (en) | Embedded equipment and method thereof for detecting and positioning leakage of memory | |
CN111413627A (en) | Fuel cell service life prediction method and device based on volt-ampere curve | |
CN103825273A (en) | Power distribution network accident process retrieval method by using feeder line contact group as unit | |
CN103885441B (en) | A kind of adaptive failure diagnostic method of controller local area network | |
CN101206616A (en) | Method for testing resource leakage of graphical interface program and method for locating question | |
CN108710573A (en) | It is a kind of that test method, device, storage medium and terminal a little are buried based on daily record | |
CN110661041A (en) | Method and device for diagnosing retired power battery | |
CN106226671A (en) | A kind of parallel test method of the hot carrier of wafer scale reliability | |
CN108231133A (en) | A kind of application method of Nand Flash bad blocks |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
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 | ||
C41 | Transfer of patent application or patent right or utility model | ||
TR01 | Transfer of patent right |
Effective date of registration: 20151118 Address after: 430223 East Lake Wuhan New Technology Development Zone Hua Hua Road, Optics Valley Industrial Park, ZTE building, building No. 3, building Patentee after: WUHAN ZHONGXING SOFTWARE CO., LTD. Address before: 518057 Nanshan District science and Technology Industrial Park, Guangdong high tech Industrial Park, ZTE building Patentee before: ZTE Corporation |