JP4575252B2 - Memory leak detection program, memory leak detection device, and memory leak detection method - Google Patents

Memory leak detection program, memory leak detection device, and memory leak detection method Download PDF

Info

Publication number
JP4575252B2
JP4575252B2 JP2005227849A JP2005227849A JP4575252B2 JP 4575252 B2 JP4575252 B2 JP 4575252B2 JP 2005227849 A JP2005227849 A JP 2005227849A JP 2005227849 A JP2005227849 A JP 2005227849A JP 4575252 B2 JP4575252 B2 JP 4575252B2
Authority
JP
Japan
Prior art keywords
memory
computer program
memory leak
character string
contents
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
JP2005227849A
Other languages
Japanese (ja)
Other versions
JP2007042007A (en
JP2007042007A5 (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.)
Yahoo Japan Corp
Original Assignee
Yahoo Japan Corp
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 Yahoo Japan Corp filed Critical Yahoo Japan Corp
Priority to JP2005227849A priority Critical patent/JP4575252B2/en
Publication of JP2007042007A publication Critical patent/JP2007042007A/en
Publication of JP2007042007A5 publication Critical patent/JP2007042007A5/ja
Application granted granted Critical
Publication of JP4575252B2 publication Critical patent/JP4575252B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Description

本発明は、メモリリークが発生したか否かを検出するメモリリーク検出プログラム、メモリリーク検出装置およびメモリリーク検出方法に関し、特に、検査対象となるコンピュータプログラムを変更することなく、メモリリークの発生を容易かつ効率的に検出することができるメモリリーク検出プログラム、メモリリーク検出装置およびメモリリーク検出方法に関する。   The present invention relates to a memory leak detection program, a memory leak detection apparatus, and a memory leak detection method for detecting whether or not a memory leak has occurred, and in particular, to prevent occurrence of a memory leak without changing a computer program to be inspected. The present invention relates to a memory leak detection program, a memory leak detection device, and a memory leak detection method that can be detected easily and efficiently.

従来、コンピュータプログラムのソースコードに含まれる誤りを、コンピュータプログラムの開発者が容易に発見できるようにするために、デバッガとよばれるソフトウェアツールが利用されている。   2. Description of the Related Art Conventionally, a software tool called a debugger has been used so that a computer program developer can easily find an error included in a source code of a computer program.

このデバッガは、コンピュータプログラムの実行を、ブレークポイントと呼ばれるあらかじめ設定された位置で停止させながら、変数の内容などの情報を出力する。開発者は、出力された情報を参照することにより、ソースコードのどこに誤りがあるかを見つけ出す作業をおこなう。   This debugger outputs information such as variable contents while stopping execution of a computer program at a preset position called a breakpoint. The developer works to find out where the error is in the source code by referring to the output information.

このようなデバッガがブレークポイントを設定できる領域は、RAM領域に展開されたコンピュータプログラムに限定される。そのため、ROM領域に記憶されたコンピュータプログラムのデバッグをおこなう場合にはブレークポイントの設定が困難であるという問題があった。   The area where such a debugger can set breakpoints is limited to the computer program expanded in the RAM area. Therefore, there is a problem that it is difficult to set a breakpoint when debugging a computer program stored in the ROM area.

この問題を解決するために、ROM領域に記憶されたコンピュータプログラムをRAM領域にコピーするとともに、RAM領域にコピーされたコンピュータプログラムにブレークポイントを設定し、さらにコンピュータプログラムの実行アドレスをRAM領域に設定することにより、あたかもROM領域にブレークポイントを設定したかのようにしてデバッグを実行する技術が開示されている(特許文献1を参照)。   In order to solve this problem, the computer program stored in the ROM area is copied to the RAM area, a breakpoint is set in the computer program copied to the RAM area, and the execution address of the computer program is set in the RAM area. By doing so, a technique has been disclosed in which debugging is executed as if a breakpoint was set in the ROM area (see Patent Document 1).

特開2001−265620号公報JP 2001-265620 A

しかしながら、上述した従来技術では、コンピュータプログラムにより動的に確保されたメモリ領域が解放されないことによって生じるメモリリークを検出することが難しいという問題があった。   However, the above-described prior art has a problem that it is difficult to detect a memory leak caused by a memory area dynamically secured by a computer program not being released.

具体的には、コンピュータプログラムの実行をブレークポイントを設定することにより停止させ、各変数の内容を確認したとしても、その変数を格納しているメモリ領域が解放されるべきものであるか否かを変数の内容から判断することは難しく、メモリリークを検出する目的には適さないという問題があった。   Specifically, even if the execution of a computer program is stopped by setting a breakpoint and the contents of each variable are confirmed, whether or not the memory area storing the variable should be released Is difficult to determine from the contents of the variable, and there is a problem that it is not suitable for the purpose of detecting a memory leak.

また、従来、検査対象となるコンピュータプログラムがメモリ領域の確保や解放を実行した場合に、その情報をメモリ領域を確保または解放した回数だけ記録するようにコンピュータプログラムを変更し、メモリ領域の確保と解放とが対応しているか否かを確認することによりメモリリークを検出する方法が用いられているが、この方法では、検査対象となるコンピュータプログラムを変更しなければならないという問題があった。   Conventionally, when a computer program to be inspected executes allocation or release of a memory area, the computer program is changed so that the information is recorded as many times as the memory area is allocated or released, and the memory area is allocated and released. A method of detecting a memory leak by confirming whether or not the release corresponds is used, but this method has a problem that the computer program to be inspected must be changed.

このような場合、たとえば、メモリリークの発生原因であると予想されるコンピュータプログラムが変更困難な外部ライブラリであると、メモリリークの検出が非常に難しくなるという問題があった。   In such a case, for example, if a computer program that is expected to cause a memory leak is an external library that is difficult to change, there is a problem that it is very difficult to detect the memory leak.

利用される頻度の少ないコンピュータプログラムでは、たとえメモリリークが発生したとしてもその影響は大きくないが、頻繁に利用されるコンピュータプログラムでメモリリークが発生すると、メモリが不足し、コンピュータがダウンするなどの障害を発生させてしまう。そのため、検査対象となるコンピュータプログラムを変更することなく、メモリリークの発生をいかに容易かつ効率的に検出することができるかが重要な課題として挙げられている。   Even if a memory leak occurs in a computer program that is used infrequently, the effect is not significant. However, if a memory leak occurs in a computer program that is used frequently, the memory will run out and the computer will go down. It will cause a failure. Therefore, an important issue is how easily and efficiently the occurrence of a memory leak can be detected without changing the computer program to be inspected.

この発明は、上述した従来技術による問題点を解消するためになされたものであり、検査対象となるコンピュータプログラムを変更することなく、メモリリークの発生を容易かつ効率的に検出することができるメモリリーク検出プログラム、メモリリーク検出装置およびメモリリーク検出方法を提供することを目的とする。   The present invention has been made to solve the above-described problems caused by the prior art, and a memory capable of easily and efficiently detecting the occurrence of a memory leak without changing a computer program to be inspected. An object of the present invention is to provide a leak detection program, a memory leak detection device, and a memory leak detection method.

上述した課題を解決し、目的を達成するため、本発明は、コンピュータプログラムを実行した場合に当該コンピュータプログラムに割り当てられる範囲のメモリにおいてメモリリークが発生したか否かを検出するメモリリーク検出プログラムであって、前記コンピュータプログラムをp 1 回連続かつその間に前記メモリの内容を初期化することなく実行した時点の前記メモリの内容と、前記コンピュータプログラムをp 2 連続かつその間に前記メモリの内容を初期化することなく実行した時点前記メモリの内容とを読み出して出力するメモリ内容出力手順と、前記コンピュータプログラムをp 1 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 1 を文字列パターンごとに計測し、また、前記コンピュータプログラムをp 2 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 2 を文字列パターンごとに計測し、同一の文字列パターンの出現回数a 1 およびa 2 の差が、前記コンピュータプログラムの実行回数p 1 およびp 2 の差の整数倍となる文字列パターンがある場合に、メモリリークが発生したことを検出するメモリリーク検出手順と、をコンピュータに実行させることを特徴とする。 In order to solve the above-described problems and achieve the object, the present invention provides a memory leak detection program that detects whether or not a memory leak has occurred in a range of memory allocated to a computer program when the computer program is executed. The contents of the memory at the time when the computer program is executed p 1 times continuously and without initializing the contents of the memory during the period, and the contents of the memory are executed p 2 times consecutively during the period. and memory contents output procedure for the reading of the contents of the memory output at the time it was performed without initializing the contents of the memory at which the computer program has been executed once p, the functions included in the computer program the number of occurrences a 1 a string pattern of the string pattern that represents the argument Measuring each emission, also the computer program from the contents of the memory at the time of executing p 2 times, each number of occurrences a 2 string patterns of the character string pattern representing the argument of a function contained in the computer program A memory leak occurs when there is a character string pattern that is measured and the difference between the appearance times a 1 and a 2 of the same character string pattern is an integral multiple of the difference between the computer program execution times p 1 and p 2 And a memory leak detection procedure for detecting the occurrence of the failure.

また、本発明は、コンピュータプログラムを実行した場合に当該コンピュータプログラムに割り当てられる範囲のメモリにおいてメモリリークが発生したか否かを検出するメモリリーク検出装置であって、前記コンピュータプログラムをp 1 回連続かつその間に前記メモリの内容を初期化することなく実行した時点の前記メモリの内容と、前記コンピュータプログラムをp 2 連続かつその間に前記メモリの内容を初期化することなく実行した時点前記メモリの内容とを読み出して出力するメモリ内容出力手段と、前記コンピュータプログラムをp 1 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 1 を文字列パターンごとに計測し、また、前記コンピュータプログラムをp 2 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 2 を文字列パターンごとに計測し、同一の文字列パターンの出現回数a 1 およびa 2 の差が、前記コンピュータプログラムの実行回数p 1 およびp 2 の差の整数倍となる文字列パターンがある場合に、メモリリークが発生したことを検出するメモリリーク検出手段と、を備えたことを特徴とする。 Further, the present invention is a memory leak detection device for detecting whether a memory leak has occurred in a memory range assigned to the computer program when running a computer program, p 1 consecutive said computer program and said memory at the time of running without initializing the contents of the memory at the time it was performed without initializing the contents of the memory during which the contents of the memory the computer program continuously and during p 2 times The memory content output means for reading out and outputting the contents of the memory, and the number of appearances a 1 of the character string pattern representing the argument of the function included in the computer program from the contents of the memory when the computer program is executed p 1 times Is measured for each character string pattern, and the computer program Grams from the contents of the memory at the time of executing p 2 times, the number of occurrences a 2 character string pattern representing the argument of a function contained in the computer program to measure for each character string pattern, the appearance of the same character string pattern Memory leak detection means for detecting that a memory leak has occurred when there is a character string pattern in which the difference between the times a 1 and a 2 is an integer multiple of the difference between the computer program execution times p 1 and p 2 , Provided.

また、本発明は、上記発明において、前記メモリリーク検出手段によりメモリリークの発生が検出された場合に、前記パターンに基づいてメモリリークの原因に係る情報を抽出し、抽出した情報を出力するメモリリーク原因情報出力手段をさらに備えたことを特徴とする。   Further, according to the present invention, in the above invention, when the occurrence of a memory leak is detected by the memory leak detection unit, the memory extracts the information related to the cause of the memory leak based on the pattern and outputs the extracted information A leak cause information output means is further provided.

また、本発明は、コンピュータプログラムを実行した場合に当該コンピュータプログラムに割り当てられる範囲のメモリにおいてメモリリークが発生したか否かを検出するメモリリーク検出方法であって、前記コンピュータプログラムをp 1 回連続かつその間に前記メモリの内容を初期化することなく実行した時点の前記メモリの内容と、前記コンピュータプログラムをp 2 連続かつその間に前記メモリの内容を初期化することなく実行した時点前記メモリの内容とを読み出して出力するメモリ内容出力工程と、前記コンピュータプログラムをp 1 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 1 を文字列パターンごとに計測し、また、前記コンピュータプログラムをp 2 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 2 を文字列パターンごとに計測し、同一の文字列パターンの出現回数a 1 およびa 2 の差が、前記コンピュータプログラムの実行回数p 1 およびp 2 の差の整数倍となる文字列パターンがある場合に、メモリリークが発生したことを検出するメモリリーク検出工程と、を含んだことを特徴とする。 Further, the present invention is a memory leak detection method for detecting whether a memory leak has occurred in a memory range assigned to the computer program when running a computer program, p 1 consecutive said computer program and said memory at the time of running without initializing the contents of the memory at the time it was performed without initializing the contents of the memory during which the contents of the memory the computer program continuously and during p 2 times From the memory content output step of reading and outputting the contents of the memory, and the contents of the memory at the time when the computer program is executed p 1 times, the number of appearances a 1 of the character string pattern representing the argument of the function included in the computer program Is measured for each character string pattern, and the computer program Grams from the contents of the memory at the time of executing p 2 times, the number of occurrences a 2 character string pattern representing the argument of a function contained in the computer program to measure for each character string pattern, the appearance of the same character string pattern A memory leak detection step for detecting that a memory leak has occurred when there is a character string pattern in which the difference between the times a 1 and a 2 is an integer multiple of the difference between the execution times p 1 and p 2 of the computer program ; , Including.

本発明によれば、コンピュータプログラムを複数回実行した場合のメモリの内容を読み出して出力し、出力したメモリの内容に基づいてメモリリークが発生したか否かを検出することとしたので、コンピュータプログラムが複数回実行された場合にメモリリークが発生するとメモリの内容が変化することを利用して、検査対象となるコンピュータプログラムを変更することなく、メモリリークの発生を容易かつ効率的に検出することができるという効果を奏する。   According to the present invention, the contents of the memory when the computer program is executed a plurality of times are read and output, and it is determined whether or not a memory leak has occurred based on the contents of the output memory. When memory is leaked multiple times, the memory contents change when a memory leak occurs, and the memory leak can be detected easily and efficiently without changing the computer program to be inspected. There is an effect that can be.

また、本発明によれば、コンピュータプログラムをp1回実行した場合のコンピュータプログラムに割り当てられている範囲のメモリの内容と、コンピュータプログラムをp2回実行した場合のコンピュータプログラムに割り当てられている範囲のメモリの内容とを読み出して出力することとしたので、コンピュータプログラムの実行回数が異なる場合にメモリリーク時のメモリの内容が変化することを利用して、メモリリークの発生を容易かつ効率的に検出することができるという効果を奏する。 Further, according to the present invention, are assigned a computer program and the contents of the memory range assigned to the computer program when run once p, the computer program when run a computer program p 2 times range The memory contents can be easily and efficiently generated by using the fact that the contents of the memory changes when the number of executions of the computer program is different. There is an effect that it can be detected.

また、本発明によれば、コンピュータプログラムをp1回実行した場合のメモリの内容から同一のパターンの出現回数a1を計測し、また、コンピュータプログラムをp2回実行した場合のメモリの内容から同一のパターンの出現回数a2を計測し、当該同一のパターンの出現回数a1およびa2に基づいてメモリリークが発生したか否かを検出することとしたので、メモリリーク発生時にコンピュータプログラムの実行回数に応じて同一のパターンの出現回数が異なることを利用して、メモリリークの発生を容易かつ効率的に検出することができるという効果を奏する。 Further, according to the present invention, the number of appearances a 1 of the same pattern is measured from the contents of the memory when the computer program is executed p 1 times, and from the contents of the memory when the computer program is executed p 2 times. Since the number of appearances a 2 of the same pattern is measured and whether or not a memory leak has occurred is detected based on the number of appearances a 1 and a 2 of the same pattern, Using the fact that the number of appearances of the same pattern varies depending on the number of executions, it is possible to easily and efficiently detect the occurrence of a memory leak.

また、本発明によれば、同一のパターンの出現回数a1およびa2の差が、コンピュータプログラムの実行回数p1およびp2の差の整数倍である場合に、メモリリークが発生したことを検出することとしたので、メモリリーク発生時に同一のパターンの出現回数a1およびa2の差が、コンピュータプログラムの実行回数p1およびp2の差の整数倍となることを利用して、メモリリークの発生を容易かつ効率的に検出することができるという効果を奏する。 Further, according to the present invention, a memory leak occurs when the difference between the appearance times a 1 and a 2 of the same pattern is an integral multiple of the difference between the computer program execution times p 1 and p 2. Since the detection is performed, the memory is obtained by utilizing the fact that the difference between the appearance times a 1 and a 2 of the same pattern when the memory leak occurs is an integral multiple of the difference between the execution times p 1 and p 2 of the computer program. There is an effect that the occurrence of leak can be detected easily and efficiently.

また、本発明によれば、メモリリークの発生が検出された場合に、上記パターンに基づいてメモリリークの原因に係る情報を抽出し、抽出した情報を出力することとしたので、メモリリークを発生させるコンピュータプログラムの誤り部分を容易かつ効率的に検出することができるという効果を奏する。   In addition, according to the present invention, when the occurrence of a memory leak is detected, information related to the cause of the memory leak is extracted based on the pattern, and the extracted information is output. It is possible to easily and efficiently detect an error part of the computer program to be executed.

また、本発明によれば、上記パターンは、コンピュータプログラムにおける関数の引数を表すパターンであることとしたので、メモリリークの発生回数に応じて引数を表すパターンがメモリに格納されることを利用して、メモリリークの発生を容易かつ効率的に検出することができるという効果を奏する。   Further, according to the present invention, since the pattern is a pattern representing a function argument in a computer program, the pattern representing the argument is stored in the memory according to the number of occurrences of memory leak. As a result, it is possible to easily and efficiently detect the occurrence of the memory leak.

以下に添付図面を参照して、本発明に係るメモリリーク検出プログラム、メモリリーク検出装置およびメモリリーク検出方法の好適な実施例を詳細に説明する。   Exemplary embodiments of a memory leak detection program, a memory leak detection apparatus, and a memory leak detection method according to the present invention will be explained below in detail with reference to the accompanying drawings.

なお、ここでは、ウェブブラウザを搭載したクライアント装置からHTTP(HyperText Transfer Protocol)リクエストを受け付けた場合に実行されるHTML情報処理プログラムのメモリリークを検出する場合について説明する。   Here, a case where a memory leak of an HTML information processing program executed when an HTTP (HyperText Transfer Protocol) request is received from a client device equipped with a web browser will be described.

このHTML情報処理プログラムは、HTTPリクエストによりリクエストされたHTML(HyperText Markup Language)文書をクライアント装置に出力することにより、クライアント装置に対してウェブページの閲覧サービスを提供するプログラムであり、ウェブサーバ装置に搭載されるプログラムである。ただし、メモリリークの検出対象となるプログラムは、これに限定されるものではなく、その他のプログラムであってもよい。   This HTML information processing program is a program that provides a web page browsing service to a client device by outputting an HTML (HyperText Markup Language) document requested by the HTTP request to the client device. It is an installed program. However, the program to be detected for memory leak is not limited to this, and may be another program.

まず、本発明に係るメモリリーク検出処理について説明する。図1は、メモリリークを発生させるコンピュータプログラムの一例を示す図である。ここでは、プログラミング言語としてC言語を用いている。   First, the memory leak detection process according to the present invention will be described. FIG. 1 is a diagram illustrating an example of a computer program that generates a memory leak. Here, C language is used as a programming language.

図1に示すコンピュータプログラムは、memleak_func関数とmain関数とから構成されている。memleak_func関数は、解放しないメモリ領域を作り出し、メモリリークを発生させる関数である。具体的には、memleak_func関数は、strdup関数によりstrbufのメモリ領域を確保しているが、確保したメモリ領域の解放はおこなわない。   The computer program shown in FIG. 1 includes a memleak_func function and a main function. The memleak_func function is a function that creates a memory area that is not released and causes a memory leak. Specifically, the memleak_func function secures the strbuf memory area by the strdup function, but does not release the secured memory area.

また、main関数は、メモリリークが発生した場合にメモリの内容をコアファイルに書き出す関数である。具体的には、main関数は、memleak_func関数をcnt回だけ呼び出して実行し、その後、abort関数を用いて当該プログラムを強制的に中止し、プログラムを中止した時点のメモリの内容をコアファイルに書き出す。   The main function is a function that writes the contents of the memory to the core file when a memory leak occurs. Specifically, the main function calls and executes the memleak_func function cnt times, then forcibly stops the program using the abort function, and writes the contents of the memory at the time of stopping the program to the core file .

このメモリリーク検出処理では、cntを異なる値に設定してmain関数を2回実行し、2つのコアファイルを生成する。たとえば、1回目のmain関数の実行時にはcntを1,024に設定し、2回目のmain関数の実行時にはcntを1,234に設定する。   In this memory leak detection process, cnt is set to a different value and the main function is executed twice to generate two core files. For example, cnt is set to 1,024 when the first main function is executed, and cnt is set to 1,234 when the second main function is executed.

そして、以下のようなコマンドを実行することにより、2つのコアファイルにそれぞれ含まれる文字列パターンの出現回数を計測する。
(コマンド)strings corefile | sort | uniq -c | sort -r | head
Then, by executing the following command, the number of occurrences of the character string pattern included in each of the two core files is measured.
(Command) strings corefile | sort | uniq -c | sort -r | head

具体的には、上記コマンドは、コアファイルから文字列パターンを抽出して並べ替え、重複した文字列パターンの数を計測し、さらに並び順を逆にして先頭から10行分を出力させるコマンドである。   Specifically, the above command is a command for extracting and rearranging the character string patterns from the core file, measuring the number of duplicate character string patterns, and further outputting the 10 lines from the top with the arrangement order reversed. is there.

このコマンドを2つのコアファイルに適用した出力結果が図2および図3に示したものとなる。図2は、memleak_func関数の実行回数を1,024に設定した場合のコアファイルに対して文字列パターンの出現回数の計測を実行した結果の一例を示す図であり、図3は、memleak_func関数の実行回数を1,234に設定した場合のコアファイルに対して文字列パターンの出現回数の計測を実行した結果の一例を示す図である。   The output result when this command is applied to two core files is as shown in FIGS. FIG. 2 is a diagram showing an example of the result of measuring the number of occurrences of the character string pattern for the core file when the number of executions of the memleak_func function is set to 1,024. FIG. 3 is a diagram showing the result of the memleak_func function. It is a figure which shows an example of the result of having performed the measurement of the appearance frequency of a character string pattern with respect to the core file at the time of setting the execution frequency to 1,234.

図2に示した結果と図3に示した結果では、memleak_func関数の引数である「memleaked strings」という文字列パターンの出現回数のみが異なっている。具体的には、1回目にcntを1,024に設定してプログラムを実行した場合の文字列パターン「memleaked strings」の出現回数は1,025回となり、2回目にcntを1,234に設定してプログラムを実行した場合の文字列パターン「memleaked strings」の出現回数は1,235回となる。   The result shown in FIG. 2 differs from the result shown in FIG. 3 only in the number of occurrences of the character string pattern “memleaked strings” that is an argument of the memleak_func function. Specifically, when the program is executed with cnt set to 1,024 for the first time, the number of occurrences of the character string pattern “memleaked strings” is 1,025 times, and cnt is set to 1,234 for the second time When the program is executed, the number of appearances of the character string pattern “memleaked strings” is 1,235.

すなわち、1回目と2回目のmemleak_func関数の実行回数の差が210回(=1,234−1,024)である場合に、文字列パターン「memleaked strings」の出現回数の差は210回(=1,235−1,025)となり、memleak_func関数の実行回数の差と同じ値になる。   That is, when the difference in the number of executions of the first and second memleak_func functions is 210 (= 1, 234-1, 024), the difference in the number of appearances of the character string pattern “memleaked strings” is 210 (= 1, 235-1, 025), which is the same value as the difference in the number of executions of the memleak_func function.

なお、ここでは、1回のmemleak_func関数の処理でメモリリークが1回だけ発生する場合が示されているが、一般には、呼び出された関数内において、メモリリークが複数回発生する場合もある。   Note that, here, a case where a memory leak occurs only once in the process of one memleak_func function is shown, but in general, a memory leak may occur a plurality of times in a called function.

その場合には、1回の関数の処理で発生するメモリリークの回数をnとすると、当該関数の1回目と2回目の実行回数p1およびp2の差の絶対値|p1−p2|と、当該関数の1回目と2回目の実行時に、引数を現す文字列パターンがメモリ領域に出現する出現回数a1およびa2の差の絶対値|a1−a2|との間の関係は、
|p1−p2|×n=|a1−a2| ......(式1)
のようになる。
In this case, if the number of memory leaks occurring in one function process is n, the absolute value of the difference between the first and second execution times p 1 and p 2 of the function | p 1 −p 2 | And the absolute value | a 1 −a 2 | of the difference between the number of appearances a 1 and a 2 at which the character string pattern representing the argument appears in the memory area at the first and second execution of the function Relationship
| P 1 −p 2 | × n = | a 1 −a 2 | . . . . . (Formula 1)
become that way.

したがって、メモリリークが発生したか否かは、1回目と2回目の関数の実行回数p1およびp2、文字列パターンがメモリ領域に出現する出現回数a1およびa2が式1を満足するか否かを調べることにより判定することができる。 Therefore, whether or not a memory leak has occurred depends on the number of executions p 1 and p 2 of the first and second functions, and the number of appearances a 1 and a 2 at which the character string pattern appears in the memory area. It can be determined by examining whether or not.

なお、本実施例では、HTTPリクエストをそれぞれp1回およびp2回生成し、そのHTTPリクエストによりリクエストされたHTML情報の処理をおこなうHTML情報処理プログラムを1回目と2回目とに分けてそれぞれp1回およびp2回実行することにより、メモリリークが発生しているか否かの検出をおこなう。このHTML情報処理プログラムは、図1に示したような関数を多数組み合わせることにより構成されたプログラムである。 In this embodiment, HTTP requests are generated p 1 times and p 2 times, respectively, and the HTML information processing program for processing the HTML information requested by the HTTP request is divided into the first time and the second time. by executing one and p 2 times, and detects whether or not the memory leak. This HTML information processing program is a program configured by combining many functions as shown in FIG.

図4は、ウェブサーバに搭載されるHTML情報処理プログラムの処理実行サイクルについて説明する図である。図4に示すように、HTML情報処理プログラムの処理実行サイクルは、ウェブブラウザを搭載したクライアント装置により送信されたHTTPリクエストを受け付け、リクエストされたHTML文書をHTTPレスポンスとしてクライアント装置に送信する処理を繰り返すものとなっている。   FIG. 4 is a diagram for explaining the processing execution cycle of the HTML information processing program installed in the web server. As shown in FIG. 4, the processing execution cycle of the HTML information processing program repeats the process of accepting an HTTP request transmitted by a client device equipped with a web browser and transmitting the requested HTML document to the client device as an HTTP response. It has become a thing.

この場合、HTML情報処理プログラムにおいて、メモリの解放をおこなっていない関数があり、その関数がHTTPリクエストごとに変化しない場合には、HTTPリクエストにより確保されるメモリ領域の内容は同じ内容となる。   In this case, in the HTML information processing program, there is a function that does not release the memory, and when the function does not change for each HTTP request, the contents of the memory area secured by the HTTP request are the same contents.

そのため、このメモリリーク検出処理では、HTML情報処理プログラムを1回目と2回目とに分けてそれぞれp1回およびp2回実行し、メモリ領域に出現する文字列パターンの出現回数a1,a2が式1を満足するか否かを調べることによりメモリリークが発生したか否かを検出することとしている。これにより、メモリリークの発生を容易かつ効率的に検出することができる。 Therefore, in this memory leak detection process, the HTML information processing program is divided into the first time and the second time, and is executed p 1 times and p 2 times, respectively, so that the number of appearances a 1 and a 2 of the character string pattern appearing in the memory area. It is determined whether or not a memory leak has occurred by examining whether or not satisfies the expression (1). As a result, the occurrence of memory leak can be detected easily and efficiently.

つぎに、本実施例に係るメモリリーク検出装置の機能構成について説明する。図5は、本実施例に係るメモリリーク検出装置の機能構成を示す図である。   Next, a functional configuration of the memory leak detection apparatus according to the present embodiment will be described. FIG. 5 is a diagram illustrating a functional configuration of the memory leak detection apparatus according to the present embodiment.

図5に示すように、このメモリリーク検出装置は、入力部10、表示部11、記憶部12、プログラム実行処理部13、メモリ内容出力部14、同一パターン出現回数計測部15、メモリリーク検出部16、メモリリーク原因情報出力部17および制御部18を有する。   As shown in FIG. 5, the memory leak detection apparatus includes an input unit 10, a display unit 11, a storage unit 12, a program execution processing unit 13, a memory content output unit 14, an identical pattern appearance count measurement unit 15, and a memory leak detection unit. 16, a memory leak cause information output unit 17 and a control unit 18 are included.

入力部10は、キーボードやマウスなどの入力デバイスである。表示部11は、ディスプレイなどの表示デバイスである。記憶部12は、メモリやハードディスクなどの記憶デバイスである。   The input unit 10 is an input device such as a keyboard or a mouse. The display unit 11 is a display device such as a display. The storage unit 12 is a storage device such as a memory or a hard disk.

この記憶部12は、HTML情報処理プログラム12a、第1コアファイル12b、第2コアファイル12c、第1同一パターン出現回数データ12d、第2同一パターン出現回数データ12e、メモリリーク検出結果12f、および、メモリリーク原因データ12gを記憶している。   The storage unit 12 includes an HTML information processing program 12a, a first core file 12b, a second core file 12c, first identical pattern appearance count data 12d, second identical pattern appearance count data 12e, a memory leak detection result 12f, and Memory leak cause data 12g is stored.

HTML情報処理プログラム12aは、ウェブブラウザを搭載したクライアント装置からHTTPリクエストを受け付けた場合に実行されるウェブサーバ用のプログラムである。このHTML情報処理プログラム12aは、リクエストされたHTML文書をクライアント装置に送信する処理をおこなう。   The HTML information processing program 12a is a web server program that is executed when an HTTP request is received from a client device equipped with a web browser. The HTML information processing program 12a performs processing for transmitting the requested HTML document to the client device.

このHTML情報処理プログラム12aは、図1に示したような関数を多数組み合わせることにより構成されたプログラムであり、メモリリークを発生させるか否かが検査されるプログラムである。   The HTML information processing program 12a is a program configured by combining a large number of functions as shown in FIG. 1, and is a program for checking whether or not a memory leak occurs.

第1コアファイル12bは、HTML情報処理プログラム12aがp1回実行された場合のメモリの内容を記憶したコアファイルである。第2コアファイル12cは、HTML情報処理プログラム12aがp2回実行された場合のメモリの内容を記憶したコアファイルである。 The first core file 12b is a core file that stores the contents of the memory when the HTML information processing program 12a is executed p 1 times. Second core file 12c is a core file that stores the contents of the memory when the HTML information processing program 12a is executed twice p.

第1同一パターン出現回数データ12dは、第1コアファイル12bに含まれる文字列パターンの出現回数を記憶したものである。具体的には、第1同一パターン出現回数データ12dは、関数の引数などの文字列パターンが第1コアファイル12bに出現した出現回数を記憶したものである。   The first identical pattern appearance number data 12d stores the number of appearances of the character string pattern included in the first core file 12b. Specifically, the first same pattern appearance number data 12d stores the number of appearances of a character string pattern such as a function argument in the first core file 12b.

第2同一パターン出現回数データ12eは、第2コアファイル12cに含まれる文字列パターンの出現回数を記憶したものである。具体的には、第2同一パターン出現回数データ12eは、関数の引数などの文字列パターンが第2コアファイル12cに出現した出現回数を記憶したものである。   The second identical pattern appearance number data 12e stores the number of appearances of the character string pattern included in the second core file 12c. Specifically, the second same pattern appearance number data 12e stores the number of appearances of a character string pattern such as a function argument in the second core file 12c.

メモリリーク検出結果12fは、メモリリークが発生したか否かを判定した判定結果の情報を記憶したものである。メモリリーク原因データ12gは、メモリリークの発生原因となっている関数の関数名や位置などの情報を記憶したものである。   The memory leak detection result 12f stores information on a determination result for determining whether or not a memory leak has occurred. The memory leak cause data 12g stores information such as the function name and position of the function causing the memory leak.

プログラム実行処理部13は、記憶部12からHTML情報処理プログラム12aを読み出して実行する処理部である。具体的には、プログラム実行処理部13は、HTTPリクエストをp1回生成することによりHTML情報処理プログラム12aをp1回実行し、また、HTTPリクエストをp2回生成することによりHTML情報処理プログラム12aをp2回実行する。 The program execution processing unit 13 is a processing unit that reads and executes the HTML information processing program 12a from the storage unit 12. Specifically, the program executing section 13, the HTML information processing program 12a executed once p by generating once HTTP request p, also, HTML information processing program by generating two p HTTP requests Execute 12a p 2 times.

メモリ内容出力部14は、プログラム実行処理部13によりHTML情報処理プログラム12aが1回目と2回目とに分けてp1,p2回実行された場合に、メモリの内容をそれぞれ出力し、記憶部12に第1コアファイル12bおよび第2コアファイル12cとして記憶させる出力部である。 The memory content output unit 14 outputs the contents of the memory when the program execution processing unit 13 executes the HTML information processing program 12a p 1 and p 2 times for the first time and the second time, respectively. 12 is an output unit that stores the first core file 12b and the second core file 12c as the first core file 12c.

同一パターン出現回数計測部15は、記憶部12から第1コアファイル12bおよび第2コアファイル12cを読み出して、第1コアファイル12bおよび第2コアファイル12cに出現する関数の引数などの文字列パターンの出現回数をそれぞれ計測し、その出現回数の情報を記憶部12に、第1同一パターン出現回数データ12dおよび第2同一パターン出現回数データ12eとして記憶させる計測部である。   The same pattern appearance count measuring unit 15 reads the first core file 12b and the second core file 12c from the storage unit 12, and character string patterns such as arguments of functions appearing in the first core file 12b and the second core file 12c. Is a measurement unit that measures the number of appearances of each and stores information on the number of appearances in the storage unit 12 as first identical pattern appearance number data 12d and second identical pattern appearance number data 12e.

メモリリーク検出部16は、記憶部12から第1同一パターン出現回数データ12dおよび第2同一パターン出現回数データ12eを読み出して、文字列パターンの出現回数が式1を満足するか否かを調べることにより、メモリリークが発生したか否かを検出する検出部である。   The memory leak detection unit 16 reads the first same pattern appearance number data 12d and the second same pattern appearance number data 12e from the storage unit 12, and checks whether or not the number of appearances of the character string pattern satisfies Expression 1. Thus, the detection unit detects whether or not a memory leak has occurred.

メモリリーク原因情報出力部17は、メモリリーク検出部16によりメモリリークの発生が検出された場合に、式1を満足した文字列パターン(本実施例では、この文字列パターンは関数の引数である。)を基にして、HTML情報処理プログラム12a中からその文字列パターンを含んだ関数を探索し、探索された関数の関数名や位置の情報を出力する出力部である。   When the occurrence of memory leak is detected by the memory leak detection unit 16, the memory leak cause information output unit 17 is a character string pattern that satisfies Expression 1 (in this embodiment, this character string pattern is a function argument) .) Is an output unit that searches the HTML information processing program 12a for a function including the character string pattern and outputs information on the function name and position of the searched function.

制御部18は、メモリリーク検出装置を全体制御する制御部であり、各機能部間のデータの授受などを司る。   The control unit 18 is a control unit that controls the entire memory leak detection device, and controls data exchange between the functional units.

つぎに、本実施例に係るメモリリーク検出処理の処理手順について説明する。図6は、本実施例に係るメモリリーク検出処理の処理手順を示すフローチャートである。   Next, a processing procedure of memory leak detection processing according to the present embodiment will be described. FIG. 6 is a flowchart illustrating the processing procedure of the memory leak detection processing according to the present embodiment.

図6に示すように、まず、メモリリーク検出装置のプログラム実行処理部13は、p1回HTTPリクエストを生成してHTML情報処理プログラム12aを実行する(ステップS101)。 As shown in FIG. 6, first, the program execution processing unit 13 of the memory leak detection apparatus generates an HTTP request p 1 times and executes the HTML information processing program 12a (step S101).

そして、メモリ内容出力部14は、メモリ領域に格納されているデータを第1コアファイル12bとして出力する(ステップS102)。続いて、同一パターン出現回数計測部15は、第1コアファイル12bにおける文字列パターンの出現回数a1を計測する(ステップS103)。 Then, the memory content output unit 14 outputs the data stored in the memory area as the first core file 12b (step S102). Subsequently, the same pattern appearance count measuring unit 15 measures the number of appearances a 1 of the character string pattern in the first core file 12b (step S103).

さらに、プログラム実行処理部13は、p2回HTTPリクエストを生成してHTML情報処理プログラム12aを実行する(ステップS104)。そして、メモリ内容出力部14は、メモリ領域に格納されているデータを第2コアファイル12cとして出力する(ステップS105)。続いて、同一パターン出現回数計測部15は、第2コアファイル12cにおける文字列パターンの出現回数a2を計測する(ステップS106)。 Further, the program execution processing unit 13 generates an HTTP request p 2 times and executes the HTML information processing program 12a (step S104). Then, the memory content output unit 14 outputs the data stored in the memory area as the second core file 12c (step S105). Subsequently, the same pattern appearance count measuring unit 15 measures the number of appearances a 2 of the character string pattern in the second core file 12c (step S106).

その後、メモリリーク検出部16は、p1,p2,a1およびa2の各値の間に式1の関係があるか否かを調べる(ステップS107)。各値の間に式1の関係がある場合には(ステップS107,Yes)、メモリリーク検出部16は、メモリリークが発生したと判定する(ステップS108)。 Thereafter, the memory leak detection unit 16 checks whether or not there is a relationship of Expression 1 among the values of p 1 , p 2 , a 1 and a 2 (step S107). If there is a relationship of Equation 1 between the values (step S107, Yes), the memory leak detection unit 16 determines that a memory leak has occurred (step S108).

そして、メモリリーク原因情報出力部17は、式1の関係を満足した文字列パターン(本実施例の場合は、関数の引数)を含んでいる関数の関数名や位置の情報をHTML情報処理プログラム12aから抽出し(ステップS109)、抽出した関数名や位置の情報を表示部11に出力して(ステップS110)、このメモリリーク検出処理を終了する。   Then, the memory leak cause information output unit 17 stores the function name and position information of the function including the character string pattern (in the case of the present embodiment, the function argument) satisfying the relationship of Expression 1 in the HTML information processing program. 12a (step S109), the extracted function name and position information are output to the display unit 11 (step S110), and the memory leak detection process is terminated.

ステップS107において、各値の間に式1の関係がなかった場合には(ステップS107,No)、メモリリーク検出部16は、メモリリークの発生は無いと判定し(ステップS111)、その判定結果を表示部11に出力して(ステップS112)、このメモリリーク検出処理を終了する。   In step S107, when there is no relationship of Formula 1 between the values (step S107, No), the memory leak detection unit 16 determines that no memory leak occurs (step S111), and the determination result Is output to the display unit 11 (step S112), and the memory leak detection process is terminated.

以上、上記実施例において、メモリリーク検出処理をコンピュータ上で実現する場合について説明してきたが、メモリリーク検出処理を実現するためのプログラムをコンピュータ読み取り可能な記録媒体に記録して、この記録媒体に記録されたプログラムをコンピュータに読み込ませ、実行することによりメモリリーク検出処理を実現してもよい。   In the above embodiment, the case where the memory leak detection process is realized on a computer has been described. However, a program for realizing the memory leak detection process is recorded on a computer-readable recording medium, and the recording medium is recorded on the recording medium. A memory leak detection process may be realized by causing a computer to read and execute a recorded program.

図7は、メモリリーク検出処理を実現するコンピュータ100のハードウェア構成を示すブロック図である。   FIG. 7 is a block diagram illustrating a hardware configuration of the computer 100 that realizes the memory leak detection process.

図7に示すように、このコンピュータ100は、上記プログラムを実行するCPU110と、データを入力する入力装置120と、各種データを記憶するROM130と、演算パラメータ等を記憶するRAM140と、メモリリーク検出処理を実現するためのプログラムを記録した記録媒体200からプログラムを読み取る読取装置150と、ディスプレイ等の出力装置160と、ネットワーク300を介して他のコンピュータとの間でデータの授受をおこなうネットワークインターフェース170とが、バス180で接続された構成となっている。   As shown in FIG. 7, the computer 100 includes a CPU 110 that executes the program, an input device 120 that inputs data, a ROM 130 that stores various data, a RAM 140 that stores calculation parameters and the like, and a memory leak detection process. A reading device 150 that reads a program from a recording medium 200 that records a program for realizing the above, an output device 160 such as a display, and a network interface 170 that exchanges data with other computers via the network 300 However, the bus 180 is connected.

CPU110は、読取装置150を経由して記録媒体200に記録されているプログラムを読み込んだ後、メモリリーク検出プログラムを実行することにより、メモリリーク検出処理を実現する。   The CPU 110 implements a memory leak detection process by reading a program recorded on the recording medium 200 via the reading device 150 and then executing a memory leak detection program.

なお、記録媒体200としては、光ディスク、フレキシブルディスク、CD−ROM、ハードディスク等が挙げられる。また、このメモリリーク検出プログラムは、ネットワーク300を介してコンピュータ100に導入することとしてもよい。   Examples of the recording medium 200 include an optical disk, a flexible disk, a CD-ROM, and a hard disk. The memory leak detection program may be installed in the computer 100 via the network 300.

上述してきたように、本実施例では、メモリリーク検出装置のメモリ内容出力部14が、HTML情報処理プログラム12aを複数回実行した場合のメモリの内容を読み出して出力し、メモリリーク検出部16が、出力したメモリの内容に基づいてメモリリークが発生したか否かを検出することとしたので、HTML情報処理プログラム12aが複数回実行された場合にメモリリークが発生するとメモリの内容が変化することを利用して、検査対象となるHTML情報処理プログラム12aを変更することなく、メモリリークの発生を容易かつ効率的に検出することができる。   As described above, in the present embodiment, the memory content output unit 14 of the memory leak detection device reads and outputs the memory content when the HTML information processing program 12a is executed a plurality of times, and the memory leak detection unit 16 Since it is determined whether or not a memory leak has occurred based on the contents of the output memory, if the memory information leak occurs when the HTML information processing program 12a is executed a plurality of times, the memory contents will change. The occurrence of a memory leak can be easily and efficiently detected without changing the HTML information processing program 12a to be inspected.

また、本実施例では、メモリ内容出力部14が、HTML情報処理プログラム12aをp1回実行した場合のコンピュータプログラムに割り当てられている範囲のメモリの内容と、HTML情報処理プログラム12aをp2回実行した場合のコンピュータプログラムに割り当てられている範囲のメモリの内容とを読み出して出力することとしたので、HTML情報処理プログラム12aの実行回数が異なる場合にメモリリーク時のメモリの内容が変化することを利用して、メモリリークの発生を容易かつ効率的に検出することができる。 Further, in the present embodiment, the memory content output unit 14, the contents of the memory range assigned to the computer program when the HTML information processing program 12a executed once p, the HTML information processing program 12a p 2 times Since the contents of the memory in the range assigned to the computer program when executed are read out and output, the contents of the memory at the time of memory leak change when the number of times the HTML information processing program 12a is executed is different. Can be used to easily and efficiently detect the occurrence of a memory leak.

また、本実施例では、同一パターン出現回数計測部15が、HTML情報処理プログラム12aをp1回実行した場合のメモリの内容から同一の引数の出現回数a1を計測し、また、HTML情報処理プログラム12aをp2回実行した場合のメモリの内容から同一のパターンの出現回数a2を計測し、メモリリーク検出部16が、当該同一の引数の出現回数a1およびa2に基づいてメモリリークが発生したか否かを検出することとしたので、メモリリーク発生時にHTML情報処理プログラム12aの実行回数に応じて同一の引数の出現回数が異なることを利用して、メモリリークの発生を容易かつ効率的に検出することができる。 In the present embodiment, the same pattern appearance count measuring unit 15 measures the appearance count a 1 of the same argument from the contents of the memory when the HTML information processing program 12a is executed p 1 times, and the HTML information processing The number of occurrences a 2 of the same pattern is measured from the contents of the memory when the program 12 a is executed p 2 times, and the memory leak detection unit 16 performs a memory leak based on the number of appearances a 1 and a 2 of the same argument. Therefore, it is possible to easily generate a memory leak by using the fact that the number of appearances of the same argument differs depending on the number of times the HTML information processing program 12a is executed when a memory leak occurs. It can be detected efficiently.

また、本実施例では、メモリリーク検出部16が、同一の引数の出現回数a1およびa2の差が、HTML情報処理プログラム12aの実行回数p1およびp2の差の整数倍である場合に、メモリリークが発生したことを検出することとしたので、メモリリーク発生時に同一の引数の出現回数a1およびa2の差が、HTML情報処理プログラム12aの実行回数p1およびp2の差の整数倍となることを利用して、メモリリークの発生を容易かつ効率的に検出することができる。 In the present embodiment, the memory leak detection unit 16 determines that the difference between the appearance times a 1 and a 2 of the same argument is an integral multiple of the difference between the execution times p 1 and p 2 of the HTML information processing program 12a. In addition, since it is detected that a memory leak has occurred, the difference between the appearance times a 1 and a 2 of the same argument when the memory leak occurs is the difference between the execution times p 1 and p 2 of the HTML information processing program 12a. The occurrence of a memory leak can be easily and efficiently detected by utilizing the fact that it is an integral multiple of.

また、本実施例では、メモリリーク原因情報出力部17が、メモリリーク検出部16によりメモリリークの発生が検出された場合に、上記引数に基づいてメモリリークの発生原因に係る情報を抽出し、抽出した情報を出力することとしたので、メモリリークを発生させるHTML情報処理プログラム12aの誤り部分を容易かつ効率的に検出することができる。   Further, in this embodiment, when the memory leak cause information output unit 17 detects the occurrence of the memory leak by the memory leak detection unit 16, the memory leak cause information output unit 17 extracts information related to the cause of the memory leak based on the argument, Since the extracted information is output, an error portion of the HTML information processing program 12a that causes a memory leak can be detected easily and efficiently.

また、本実施例では、HTML情報処理プログラム12aにおける関数の引数を表す文字列パターンの出現回数a1およびa2を用いてメモリリークの発生を検出することとしたので、メモリリークの発生回数に応じて引数がメモリに格納されることを利用して、メモリリークの発生を容易かつ効率的に検出することができる。 In this embodiment, the occurrence of a memory leak is detected using the number of occurrences a 1 and a 2 of the character string pattern representing the argument of the function in the HTML information processing program 12a. Accordingly, the occurrence of a memory leak can be detected easily and efficiently using the fact that the argument is stored in the memory.

さて、これまで本発明の実施例について説明したが、本発明は上述した実施例以外にも、特許請求の範囲に記載した技術的思想の範囲内において種々の異なる実施例にて実施されてもよいものである。   Although the embodiments of the present invention have been described so far, the present invention may be implemented in various different embodiments in addition to the above-described embodiments within the scope of the technical idea described in the claims. It ’s good.

たとえば、本実施例では、HTML情報処理プログラム12aを1回目と2回目とに分けてp1回およびp2回実行し、文字列パターンの出現回数a1およびa2が式1を満足するか否かを調べることによりメモリリークを検出することとしたが、本発明はこれに限定されるものではなく、HTML情報処理プログラム12aをp1回実行した際、引数などの文字列パターンが、たとえば、(p1の整数倍+1)回だけコアファイルに書き出されることがあらかじめ判明しているような場合には、文字列パターンが(p1の整数倍+1)回コアファイルに出現するか否かを検出することによりメモリリークを検出することとしてもよい。 For example, in this embodiment, the HTML information processing program 12a is executed p 1 and p 2 times for the first time and the second time, and whether the number of appearances a 1 and a 2 of the character string pattern satisfies Expression 1? was decided to detect memory leaks by examining whether, the present invention is not limited to this, when the HTML information processing program 12a executed once p, string pattern, such as arguments, for example, , whether appearing only when it is written in the core files that have been found previously, the string pattern (the p 1 integer times + 1) times core file times (integer multiple +1 p 1) It is also possible to detect a memory leak by detecting.

また、本実施例において説明した各処理のうち、自動的におこなわれるものとして説明した処理の全部または一部を手動的におこなうこともでき、あるいは、手動的におこなわれるものとして説明した処理の全部または一部を公知の方法で自動的におこなうこともできる。   In addition, among the processes described in this embodiment, all or part of the processes described as being performed automatically can be performed manually, or the processes described as being performed manually can be performed. All or a part can be automatically performed by a known method.

この他、上記文書中や図面中で示した処理手順、制御手順、具体的名称、各種のデータやパラメータを含む情報については、特記する場合を除いて任意に変更することができる。   In addition, the processing procedure, control procedure, specific name, and information including various data and parameters shown in the above-described document and drawings can be arbitrarily changed unless otherwise specified.

また、図示したメモリリーク検出装置の各構成要素は機能概念的なものであり、必ずしも物理的に図示のように構成されていることを要しない。すなわち、メモリリーク検出装置の分散・統合の具体的形態は図示のものに限られず、その全部または一部を、各種の負荷や使用状況などに応じて、任意の単位で機能的または物理的に分散・統合して構成することができる。   Each component of the illustrated memory leak detection apparatus is functionally conceptual and does not necessarily need to be physically configured as illustrated. That is, the specific form of distribution / integration of the memory leak detection device is not limited to the one shown in the figure, and all or a part thereof may be functionally or physically functioned in an arbitrary unit depending on various loads or usage conditions. It can be configured to be distributed and integrated.

さらに、メモリリーク検出装置にて行なわれる処理機能は、その全部または任意の一部が、CPUおよび当該CPUにて解析実行されるプログラムにて実現され、あるいは、ワイヤードロジックによるハードウェアとして実現され得る。   Furthermore, the processing functions performed by the memory leak detection apparatus can be realized in whole or in any part by a CPU and a program that is analyzed and executed by the CPU, or can be realized as hardware by wired logic. .

以上のように、本発明に係るメモリリーク検出プログラム、メモリリーク検出装置およびメモリリーク検出方法は、検査対象となるコンピュータプログラムを変更することなく、メモリリークの発生を容易かつ効率的に検出することが必要なメモリリーク検出システムに有用である。   As described above, the memory leak detection program, the memory leak detection apparatus, and the memory leak detection method according to the present invention can easily and efficiently detect the occurrence of a memory leak without changing the computer program to be inspected. This is useful for memory leak detection systems that require

メモリリークを発生させるコンピュータプログラムの一例を示す図である。It is a figure which shows an example of the computer program which generates a memory leak. memleak_func関数の実行回数を1,024に設定した場合のコアファイルに対して文字列パターンの出現回数の計測を実行した結果の一例を示す図である。It is a figure which shows an example of the result of having performed the measurement of the appearance frequency of a character string pattern with respect to the core file at the time of setting the execution frequency of a memleak_func function to 1,024. memleak_func関数の実行回数を1,234に設定した場合のコアファイルに対して文字列パターンの出現回数の計測を実行した結果の一例を示す図である。It is a figure which shows an example of the result of having performed the measurement of the appearance frequency of a character string pattern with respect to the core file at the time of setting the execution frequency of a memleak_func function to 1,234. ウェブサーバに搭載されるHTML情報処理プログラムの処理実行サイクルについて説明する図である。It is a figure explaining the process execution cycle of the HTML information processing program mounted in a web server. 本実施例に係るメモリリーク検出装置の機能構成を示す図である。It is a figure which shows the function structure of the memory leak detection apparatus concerning a present Example. 本実施例に係るメモリリーク検出処理の処理手順を示すフローチャートである。It is a flowchart which shows the process sequence of the memory leak detection process which concerns on a present Example. メモリリーク検出処理を実現するコンピュータ100のハードウェア構成を示すブロック図である。It is a block diagram which shows the hardware constitutions of the computer 100 which implement | achieves a memory leak detection process.

符号の説明Explanation of symbols

10 入力部
11 表示部
12 記憶部
12a HTML情報処理プログラム
12b 第1コアファイル
12c 第2コアファイル
12d 第1同一パターン出現回数データ
12e 第2同一パターン出現回数データ
12f メモリリーク検出結果
12g メモリリーク原因データ
13 プログラム実行処理部
14 メモリ内容出力部
15 同一パターン出現回数計測部
16 メモリリーク検出部
17 メモリリーク原因情報出力部
18 制御部
DESCRIPTION OF SYMBOLS 10 Input part 11 Display part 12 Storage part 12a HTML information processing program 12b 1st core file 12c 2nd core file 12d 1st same pattern appearance frequency data 12e 2nd same pattern appearance frequency data 12f Memory leak detection result 12g Memory leak cause data 13 Program execution processing unit 14 Memory content output unit 15 Same pattern appearance count measurement unit 16 Memory leak detection unit 17 Memory leak cause information output unit 18 Control unit

Claims (4)

コンピュータプログラムを実行した場合に当該コンピュータプログラムに割り当てられる範囲のメモリにおいてメモリリークが発生したか否かを検出するメモリリーク検出装置であって、
前記コンピュータプログラムをp 1 回連続かつその間に前記メモリの内容を初期化することなく実行した時点の前記メモリの内容と、前記コンピュータプログラムをp 2 連続かつその間に前記メモリの内容を初期化することなく実行した時点前記メモリの内容とを読み出して出力するメモリ内容出力手段と、
前記コンピュータプログラムをp 1 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 1 を文字列パターンごとに計測し、また、前記コンピュータプログラムをp 2 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 2 を文字列パターンごとに計測し、同一の文字列パターンの出現回数a 1 およびa 2 の差が、前記コンピュータプログラムの実行回数p 1 およびp 2 の差の整数倍となる文字列パターンがある場合に、メモリリークが発生したことを検出するメモリリーク検出手段と、
を備えたことを特徴とするメモリリーク検出装置。
A memory leak detection device that detects whether or not a memory leak has occurred in a range of memory allocated to a computer program when the computer program is executed ,
The contents of the memory at the time when the computer program is executed p 1 times continuously and without initializing the contents of the memory, and the contents of the memory are initialized p 2 times consecutively and during that time a memory content output means for outputting the read out and the contents of the memory at the time of running without,
The number of occurrences a 1 of a character string pattern representing an argument of a function included in the computer program is measured for each character string pattern from the contents of the memory when the computer program is executed p 1 times , and the computer program P 2 times, the number of appearances a 2 of the character string pattern representing the argument of the function included in the computer program is measured for each character string pattern, and the number of appearances of the same character string pattern is obtained. a memory leak detecting means for detecting that a memory leak has occurred when there is a character string pattern in which the difference between a 1 and a 2 is an integer multiple of the difference between the execution times p 1 and p 2 of the computer program ;
A memory leak detection apparatus comprising:
前記メモリリーク検出手段によりメモリリークの発生が検出された場合に、前記パターンに基づいてメモリリークの原因に係る情報を抽出し、抽出した情報を出力するメモリリーク原因情報出力手段をさらに備えたことを特徴とする請求項に記載のメモリリーク検出装置。 When the occurrence of a memory leak is detected by the memory leak detection means, it further comprises memory leak cause information output means for extracting information relating to the cause of the memory leak based on the pattern and outputting the extracted information The memory leak detection device according to claim 1 . コンピュータプログラムを実行した場合に当該コンピュータプログラムに割り当てられる範囲のメモリにおいてメモリリークが発生したか否かを検出するメモリリーク検出プログラムであって、
前記コンピュータプログラムをp 1 回連続かつその間に前記メモリの内容を初期化することなく実行した時点の前記メモリの内容と、前記コンピュータプログラムをp 2 連続かつその間に前記メモリの内容を初期化することなく実行した時点前記メモリの内容とを読み出して出力するメモリ内容出力手順と、
前記コンピュータプログラムをp 1 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 1 を文字列パターンごとに計測し、また、前記コンピュータプログラムをp 2 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 2 を文字列パターンごとに計測し、同一の文字列パターンの出現回数a 1 およびa 2 の差が、前記コンピュータプログラムの実行回数p 1 およびp 2 の差の整数倍となる文字列パターンがある場合に、メモリリークが発生したことを検出するメモリリーク検出手順と、
をコンピュータに実行させることを特徴とするメモリリーク検出プログラム。
A memory leak detection program for detecting whether or not a memory leak has occurred in a range of memory allocated to the computer program when the computer program is executed ,
The contents of the memory at the time when the computer program is executed p 1 times continuously and without initializing the contents of the memory, and the contents of the memory are initialized p 2 times consecutively and during that time and memory contents output procedure for the reading of the contents of the memory output at the time of running without,
The number of occurrences a 1 of a character string pattern representing an argument of a function included in the computer program is measured for each character string pattern from the contents of the memory when the computer program is executed p 1 times , and the computer program P 2 times, the number of appearances a 2 of the character string pattern representing the argument of the function included in the computer program is measured for each character string pattern, and the number of appearances of the same character string pattern is obtained. a memory leak detection procedure for detecting that a memory leak has occurred when there is a character string pattern in which the difference between a 1 and a 2 is an integer multiple of the difference between the execution times p 1 and p 2 of the computer program ;
A memory leak detection program characterized by causing a computer to execute.
コンピュータプログラムを実行した場合に当該コンピュータプログラムに割り当てられる範囲のメモリにおいてメモリリークが発生したか否かを検出するメモリリーク検出方法であって、
前記コンピュータプログラムをp 1 回連続かつその間に前記メモリの内容を初期化することなく実行した時点の前記メモリの内容と、前記コンピュータプログラムをp 2 連続かつその間に前記メモリの内容を初期化することなく実行した時点前記メモリの内容とを読み出して出力するメモリ内容出力工程と、
前記コンピュータプログラムをp 1 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 1 を文字列パターンごとに計測し、また、前記コンピュータプログラムをp 2 回実行した時点の前記メモリの内容から、前記コンピュータプログラムに含まれる関数の引数を表す文字列パターンの出現回数a 2 を文字列パターンごとに計測し、同一の文字列パターンの出現回数a 1 およびa 2 の差が、前記コンピュータプログラムの実行回数p 1 およびp 2 の差の整数倍となる文字列パターンがある場合に、メモリリークが発生したことを検出するメモリリーク検出工程と、
を含んだことを特徴とするメモリリーク検出方法。
A memory leak detection method for detecting whether or not a memory leak has occurred in a range of memory allocated to the computer program when the computer program is executed ,
The contents of the memory at the time when the computer program is executed p 1 times continuously and without initializing the contents of the memory, and the contents of the memory are initialized p 2 times consecutively and during that time and memory contents output step of the reading the contents of the memory output at the time of running without,
The number of occurrences a 1 of a character string pattern representing an argument of a function included in the computer program is measured for each character string pattern from the contents of the memory when the computer program is executed p 1 times , and the computer program P 2 times, the number of appearances a 2 of the character string pattern representing the argument of the function included in the computer program is measured for each character string pattern, and the number of appearances of the same character string pattern is obtained. a memory leak detection step of detecting that a memory leak has occurred when there is a character string pattern in which the difference between a 1 and a 2 is an integer multiple of the difference between the execution times p 1 and p 2 of the computer program ;
A memory leak detection method comprising:
JP2005227849A 2005-08-05 2005-08-05 Memory leak detection program, memory leak detection device, and memory leak detection method Expired - Fee Related JP4575252B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2005227849A JP4575252B2 (en) 2005-08-05 2005-08-05 Memory leak detection program, memory leak detection device, and memory leak detection method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2005227849A JP4575252B2 (en) 2005-08-05 2005-08-05 Memory leak detection program, memory leak detection device, and memory leak detection method

Publications (3)

Publication Number Publication Date
JP2007042007A JP2007042007A (en) 2007-02-15
JP2007042007A5 JP2007042007A5 (en) 2008-04-17
JP4575252B2 true JP4575252B2 (en) 2010-11-04

Family

ID=37799904

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2005227849A Expired - Fee Related JP4575252B2 (en) 2005-08-05 2005-08-05 Memory leak detection program, memory leak detection device, and memory leak detection method

Country Status (1)

Country Link
JP (1) JP4575252B2 (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000293400A (en) * 1999-04-08 2000-10-20 Nec Corp System and method for detecting memory leak and recording medium
JP2001265620A (en) * 2000-03-22 2001-09-28 Kyocera Corp Program debugging system for rom
JP2001331368A (en) * 2000-05-19 2001-11-30 Oki Electric Ind Co Ltd Method for discriminating omission of memory release

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04135256A (en) * 1990-09-27 1992-05-08 Nippon Telegr & Teleph Corp <Ntt> Garbage detecting method
JPH10269105A (en) * 1997-01-27 1998-10-09 N T T Data Tsushin Kk Trace system, resource release omission detection system, and recording medium
JPH10269133A (en) * 1997-03-25 1998-10-09 Hitachi Ltd Memory release omission inspecting system for computer system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000293400A (en) * 1999-04-08 2000-10-20 Nec Corp System and method for detecting memory leak and recording medium
JP2001265620A (en) * 2000-03-22 2001-09-28 Kyocera Corp Program debugging system for rom
JP2001331368A (en) * 2000-05-19 2001-11-30 Oki Electric Ind Co Ltd Method for discriminating omission of memory release

Also Published As

Publication number Publication date
JP2007042007A (en) 2007-02-15

Similar Documents

Publication Publication Date Title
JP4148527B2 (en) Functional test script generator
Costa et al. What's wrong with my benchmark results? Studying bad practices in JMH benchmarks
US5987250A (en) Transparent instrumentation for computer program behavior analysis
CN101473301B (en) Iterative static and dynamic software analysis
US7849450B1 (en) Devices, methods and computer program products for reverse execution of a simulation
US6662362B1 (en) Method and system for improving performance of applications that employ a cross-language interface
US9411616B2 (en) Classloader/instrumentation approach for invoking non-bound libraries
US8381175B2 (en) Low-level code rewriter verification
JP2006185211A (en) Program analysis system, test execution device, and analysis method and program thereof
US8701084B1 (en) Preview of auto-fix changes to software code
US20080028378A1 (en) Utilizing prior usage data for software build optimization
JPWO2009075116A1 (en) Program debug method, program conversion method, program debug device using the same, program conversion device, and storage medium
US12093398B2 (en) Vulnerability analysis and reporting for embedded systems
US20110067013A1 (en) Systems and methods for deferring software implementation decisions until load time
JP6303749B2 (en) Method and system for analyzing a software program and non-transitory computer readable medium
JP5303795B2 (en) Application analysis method, analysis system, and analysis program
Winzinger et al. Model-based analysis of serverless applications
US10380313B1 (en) Implementation and evaluation of designs for heterogeneous computing platforms with hardware acceleration
US7530060B1 (en) Methods and computer program product for optimizing binaries with coding style formalization
Fedorova et al. Performance comprehension at WiredTiger
KR20150100586A (en) Appratus for detectiing similarity of software and method thereof
JP6878707B2 (en) Test equipment, test methods and test programs
US8756580B2 (en) Instance-based field affinity optimization
JP4575252B2 (en) Memory leak detection program, memory leak detection device, and memory leak detection method
Karnick et al. A qualitative analysis of java obfuscation

Legal Events

Date Code Title Description
A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20080305

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20080305

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20091020

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20100518

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20100720

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20100810

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20100819

R150 Certificate of patent or registration of utility model

Ref document number: 4575252

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130827

Year of fee payment: 3

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees