JP3735484B2 - Memory leak detection system, memory leak detection method, and recording medium - Google Patents

Memory leak detection system, memory leak detection method, and recording medium Download PDF

Info

Publication number
JP3735484B2
JP3735484B2 JP10077499A JP10077499A JP3735484B2 JP 3735484 B2 JP3735484 B2 JP 3735484B2 JP 10077499 A JP10077499 A JP 10077499A JP 10077499 A JP10077499 A JP 10077499A JP 3735484 B2 JP3735484 B2 JP 3735484B2
Authority
JP
Japan
Prior art keywords
memory area
stack
information
application program
memory
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
JP10077499A
Other languages
Japanese (ja)
Other versions
JP2000293400A (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.)
NEC Corp
Original Assignee
NEC 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 NEC Corp filed Critical NEC Corp
Priority to JP10077499A priority Critical patent/JP3735484B2/en
Publication of JP2000293400A publication Critical patent/JP2000293400A/en
Application granted granted Critical
Publication of JP3735484B2 publication Critical patent/JP3735484B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Description

【0001】
【発明の属する技術分野】
この発明は、アプリケーションプログラム等のデバッグ時に、メモリ領域の解放漏れを検出し、さらにその要因を的確に特定することのできるメモリリーク検出システム、メモリリーク検出方法及び記録媒体に関する。
【0002】
【従来の技術】
コンピュータシステムのOS(Operating System)上で実行されるアプリケーションプログラムは、一般に、OSの機能の一つであるシステムコールやAPI(Application Program Interface)等を介して、例えば、所定のメモリ領域を動的に確保し、確保したメモリ領域を使用して情報処理等を行う。そして、アプリケーションプログラムは、情報処理等を終えると、確保したメモリ領域を解放し、OSに返却する。
この際、アプリケーションプログラムに、何らかのバグがあり、メモリ領域の解放が行われないと、いわゆるメモリリークが発生する。すなわち、この場合、メモリリークとは、アプリケーションプログラム等が不要となったメモリ領域を適切に解放しない(システムに返還しない)ため、使用されないメモリ領域がメモリ空間に残ってしまう状態をいう。
【0003】
このようなメモリリークが発生すると、OSが、メモリ空間に残ったメモリ領域を他のアプリケーションプログラムに割り当てることができなくなり、システム全体として、使用可能なメモリの総量が減少することとなる。そして、使用可能なメモリの総量が、限界まで減少すると、アプリケーションプログラム等が異常終了してしまう。そのため、アプリケーションプログラムの開発において、メモリリークを発生させるようなバグを適切に取り除くように、テスト工程にて、デバッグされる。
【0004】
近年、ユーザの操作性の向上や多機能性等を実現するため、アプリケーションプログラムは、一般に、その規模が大きくなっている。アプリケーションプログラムの規模が、大きくなるに従って、プログラム中にメモリリークを発生するようなバグを含む可能性が高くなるだけでなく、メモリリークを検出することや、メモリリークを生じるバグの要因を特定することが困難となっている。
【0005】
このようなアプリケーションプログラムのメモリリークを、実用的に検出する技術が、特開平9−244948号公報に開示されている。この技術は、メモリ領域の割り当て時に割当情報を、またメモリ領域の解放時に解除情報をそれぞれ記憶し、解放されないメモリ領域が、プログラムのどの箇所で割り当てられたものかを調査するものである。
【0006】
【発明が解決しようとする課題】
しかし、特開平9−244948号公報に開示されている技術では、アプリケーションプログラムにおけるメモリ領域を割り当てた箇所を特定することができても、さらにその箇所を呼び出した関数の呼び出し経路を特定することはできない。
そのため、階層的に関数の呼び出しが行われているアプリケーションプログラム等では、十分な情報が得られないこととなり、メモリリークの原因を的確に特定することができなかった。
【0007】
この発明は、上記実状に鑑みてなされたもので、メモリ領域の解放漏れを検出し、さらにその要因を的確に特定することのできるメモリリーク検出システム、メモリリーク検出方法及び記録媒体を提供することを目的とする。
【0008】
【課題を解決するための手段】
上記目的を達成するため、本発明の第1の観点に係るメモリリーク検出システムは、
オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出システムであって、
起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保するメモリ領域確保手段と、
前記メモリ領域確保手段がメモリ領域を確保した時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタック情報を取得するスタック情報取得手段と、
前記スタック情報取得手段が取得したスタック情報を、前記メモリ領域確保手段が確保したメモリ領域と対応付けて記憶するスタック情報記憶手段と、
前記メモリ領域確保手段が確保したメモリ領域を、アプリケーションプログラムからの要求に従って解放するメモリ領域解放手段と、
前記メモリ領域解放手段により解放されたメモリ領域に対応するスタック情報を前記スタック情報記憶手段から削除するスタック情報削除手段と、
アプリケーションプログラムの起動が完了すると、前記スタック情報記憶手段にスタック情報が記憶されているか否かを判別するスタック情報判別手段と、
前記スタック情報判別手段によりスタック情報が前記スタック情報記憶手段に記憶されていると判別された場合に、前記スタック情報記憶手段からスタック情報を抽出し、各モジュールの実行履歴を表示するスタック情報表示手段と、
を備えることを特徴とする。
【0009】
この発明によれば、メモリ領域確保手段は、起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保する。スタック情報取得手段は、メモリ領域確保手段がメモリ領域を確保した時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタック情報を取得する。スタック情報記憶手段は、スタック情報取得手段が取得したスタック情報を、メモリ領域確保手段が確保したメモリ領域と対応付けて記憶する。メモリ領域解放手段は、メモリ領域確保手段が確保したメモリ領域を、アプリケーションプログラムからの要求に従って解放する。スタック情報削除手段は、メモリ領域解放手段により解放されたメモリ領域に対応するスタック情報をスタック情報記憶手段から削除する。スタック情報判別手段は、アプリケーションプログラムの起動が完了すると、スタック情報記憶手段にスタック情報が記憶されているか否かを判別する。スタック情報表示手段は、スタック情報判別手段によりスタック情報がスタック情報記憶手段に記憶されていると判別された場合に、スタック情報記憶手段からスタック情報を抽出し、各モジュールの実行履歴を表示する。この結果、アプリケーションプログラムにおけるメモリ領域の解放漏れを検出し、さらに、メモリリークの要因を的確に特定することができる。
【0010】
前記スタック情報取得手段が取得するスタック情報は、少なくともスタック上の一群のデータからなるスタックフレームを含み、
前記スタック情報表示手段は、スタック情報に含まれるスタックフレームに従って、前記メモリ領域確保手段にメモリ領域の確保を要求したアプリケーションプログラムにおけるモジュール階層を表示してもよい。この場合、メモリ領域の解放漏れを検出すると、表示されたアプリケーションプログラムにおけるモジュール階層から、メモリリークの要因を的確に特定することができる。
【0011】
上記目的を達成するため、本発明の第2の観点に係るメモリリーク検出システムは、
オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出システムであって、
起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保するメモリ領域確保手段と、
前記メモリ領域確保手段がメモリ領域を確保した時点でのスタックを解析し、メモリ領域の確保を要求したアプリケーションプログラムにおける各モジュールの実行履歴を得ることのできるスタック上の一群のデータからなるスタックフレームを特定するスタックフレーム特定手段と、
前記スタックフレーム特定手段により特定されたスタックフレーム及び、前記メモリ領域確保手段が確保したメモリ領域のアドレスからなるダンプ情報を生成するダンプ情報生成手段と、
前記ダンプ情報生成手段が生成したダンプ情報を逐次記憶するダンプ情報記憶手段と、
前記メモリ領域確保手段が確保したメモリ領域を、アプリケーションプログラムからの要求に従って解放するメモリ領域解放手段と、
前記メモリ領域解放手段により解放されたメモリ領域のアドレスに従って、ダンプ情報記憶手段に記憶された対応するダンプ情報を特定するダンプ情報特定手段と、
前記ダンプ情報特定手段により特定されたダンプ情報を前記ダンプ情報記憶手段から削除するダンプ情報削除手段と、
アプリケーションプログラムの起動が完了すると、前記ダンプ情報記憶手段にダンプ情報が記憶されているか否かを判別するダンプ情報判別手段と、
前記ダンプ情報判別手段によりダンプ情報が前記ダンプ情報記憶手段に記憶されていると判別された場合に、前記ダンプ情報記憶手段からダンプ情報を抽出するダンプ情報抽出手段と、
前記ダンプ情報抽出手段により抽出されたダンプ情報に含まれるスタックフレームの内容を所定の表示形式に加工し、各モジュールの実行履歴を表示するスタックフレーム表示手段と、
を備えることを特徴とする。
【0012】
この発明によれば、メモリ領域確保手段は、起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保する。スタックフレーム特定手段は、メモリ領域確保手段がメモリ領域を確保した時点でのスタックを解析し、メモリ領域の確保を要求したアプリケーションプログラムにおける各モジュールの実行履歴を得ることのできるスタック上の一群のデータからなるスタックフレームを特定する。ダンプ情報生成手段は、スタックフレーム特定手段により特定されたスタックフレーム及び、メモリ領域確保手段が確保したメモリ領域のアドレスからなるダンプ情報を生成する。ダンプ情報記憶手段は、ダンプ情報生成手段が生成したダンプ情報を逐次記憶する。メモリ領域解放手段は、メモリ領域確保手段が確保したメモリ領域を、アプリケーションプログラムからの要求に従って解放する。ダンプ情報特定手段は、メモリ領域解放手段により解放されたメモリ領域のアドレスに従って、ダンプ情報記憶手段に記憶された対応するダンプ情報を特定する。ダンプ情報削除手段は、ダンプ情報特定手段により特定されたダンプ情報をダンプ情報記憶手段から削除する。ダンプ情報判別手段は、アプリケーションプログラムの起動が完了すると、ダンプ情報記憶手段にダンプ情報が記憶されているか否かを判別する。ダンプ情報抽出手段は、ダンプ情報判別手段によりダンプ情報がダンプ情報記憶手段に記憶されていると判別された場合に、ダンプ情報記憶手段からダンプ情報を抽出する。スタックフレーム表示手段は、ダンプ情報抽出手段により抽出されたダンプ情報に含まれるスタックフレームの内容を所定の表示形式に加工し、各モジュールの実行履歴を表示する。この結果、アプリケーションプログラムにおけるメモリ領域の解放漏れを検出し、さらに、メモリリークの要因を的確に特定することができる。
【0013】
上記目的を達成するため、本発明の第3の観点に係るメモリリーク検出システムは、
オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出システムであって、
システムにおけるスタックを解析し、スタック上の一群のデータからなるスタックフレームを特定するスタック解析部と、
起動したアプリケーションプログラムから呼び出され、所定のメモリ領域を確保すると共に、前記スタック解析部により特定されるその時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタックフレームを取得するメモリ確保ライブラリと、
前記メモリ確保ライブラリが確保したメモリ領域のアドレス及び、取得したスタックフレームからなるダンプ情報を逐次記憶する管理テーブルと、
前記メモリ確保ライブラリが確保したメモリ領域を、アプリケーションプログラムからの要求に従って解放すると共に、前記管理テーブルに記憶されたダンプ情報を削除するメモリ解放ライブラリと、
アプリケーションプログラムの起動が完了すると、前記管理テーブルに記憶されているダンプ情報の有無を判別し、ダンプ情報が記憶されていると判別した場合に、ダンプ情報に含まれるスタックフレームの内容から、各モジュールの実行履歴を表示するテーブル表示部と、
を備えることを特徴とする。
【0014】
この発明によれば、スタック解析部は、システムにおけるスタックを解析し、スタック上の一群のデータからなるスタックフレームを特定する。メモリ確保ライブラリは、起動したアプリケーションプログラムから呼び出され、所定のメモリ領域を確保すると共に、スタック解析部により特定されるその時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタックフレームを取得する。管理テーブルは、メモリ確保ライブラリが確保したメモリ領域のアドレス及び、取得したスタックフレームからなるダンプ情報を逐次記憶する。メモリ解放ライブラリは、メモリ確保ライブラリが確保したメモリ領域を、アプリケーションプログラムからの要求に従って解放すると共に、管理テーブルに記憶されたダンプ情報を削除する。テーブル表示部は、アプリケーションプログラムの起動が完了すると、管理テーブルに記憶されているダンプ情報の有無を判別し、ダンプ情報が記憶されていると判別した場合に、ダンプ情報に含まれるスタックフレームの内容から、各モジュールの実行履歴を表示する。この結果、アプリケーションプログラムにおけるメモリ領域の解放漏れを検出し、さらに、メモリリークの要因を的確に特定することができる。
【0015】
上記目的を達成するため、本発明の第4の観点に係るメモリリーク検出方法は、
オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出方法であって、
起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保するメモリ領域確保ステップと、
前記メモリ領域確保ステップにてメモリ領域が確保された時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタック情報を取得するスタック情報取得ステップと、
前記スタック情報取得ステップにて取得されたスタック情報を、前記メモリ領域確保ステップにて確保されたメモリ領域と対応付けて所定の管理テーブルに格納するスタック情報格納ステップと、
前記メモリ領域確保ステップにて確保されたメモリ領域を、アプリケーションプログラムからの要求に従って解放するメモリ領域解放ステップと、
前記メモリ領域解放ステップにて解放されたメモリ領域に対応する管理テーブルに格納されたスタック情報を削除するスタック情報削除ステップと、
アプリケーションプログラムの起動が完了すると、前記スタック情報削除ステップにて管理テーブルから削除されずに残っているスタック情報の有無を判別するスタック情報判別ステップと、
前記スタック情報判別ステップにてスタック情報が管理テーブルに残っていると判別された場合に、管理テーブルに格納されたスタック情報を抽出し、各モジュールの実行履歴を表示するスタック情報表示ステップと、
を備えることを特徴とする。
【0016】
この発明によれば、メモリ領域確保ステップは、起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保する。スタック情報取得ステップは、メモリ領域確保ステップにてメモリ領域が確保された時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタック情報を取得する。スタック情報格納ステップは、スタック情報取得ステップにて取得されたスタック情報を、メモリ領域確保ステップにて確保されたメモリ領域と対応付けて所定の管理テーブルに格納する。メモリ領域解放ステップは、メモリ領域確保ステップにて確保されたメモリ領域を、アプリケーションプログラムからの要求に従って解放する。スタック情報削除ステップは、メモリ領域解放ステップにて解放されたメモリ領域に対応する管理テーブルに格納されたスタック情報を削除する。スタック情報判別ステップは、アプリケーションプログラムの起動が完了すると、スタック情報削除ステップにて管理テーブルから削除されずに残っているスタック情報の有無を判別する。スタック情報表示ステップは、スタック情報判別ステップにてスタック情報が管理テーブルに残っていると判別された場合に、管理テーブルに格納されたスタック情報を抽出し、各モジュールの実行履歴を表示する。この結果、アプリケーションプログラムにおけるメモリ領域の解放漏れを検出し、さらに、メモリリークの要因を的確に特定することができる。
【0017】
上記目的を達成するため、本発明の第5の観点に係る記録媒体は、
オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出方法をコンピュータに実行させるためのプログラムを記録したコンピュータ読み取り可能な記録媒体であって、
起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保するメモリ領域確保ステップと、前記メモリ領域確保ステップにてメモリ領域が確保された時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタック情報を取得するスタック情報取得ステップと、前記スタック情報取得ステップにて取得されたスタック情報を、前記メモリ領域確保ステップにて確保されたメモリ領域と対応付けて所定の管理テーブルに格納するスタック情報格納ステップと、前記メモリ領域確保ステップにて確保されたメモリ領域を、アプリケーションプログラムからの要求に従って解放するメモリ領域解放ステップと、前記メモリ領域解放ステップにて解放されたメモリ領域に対応する管理テーブルに格納されたスタック情報を削除するスタック情報削除ステップと、アプリケーションプログラムの起動が完了すると、前記スタック情報削除ステップにて管理テーブルから削除されずに残っているスタック情報の有無を判別するスタック情報判別ステップと、前記スタック情報判別ステップにてスタック情報が管理テーブルに残っていると判別された場合に、管理テーブルに格納されたスタック情報を抽出し、各モジュールの実行履歴を表示するスタック情報表示ステップとを有するメモリリーク検出方法をコンピュータに実行させるためのプログラムを記録する。
【0018】
【発明の実施の形態】
本発明の実施の形態にかかるメモリリーク検出システムについて、以下図面を参照して説明する。
【0019】
図1は、この発明の実施の形態に適用されるメモリリーク検出システムの一例を示す模式図である。このシステムは、所定のOSに起動制御されるアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出システムであって、アプリケーションプログラム1と、メモリ管理ライブラリ2と、スタック解析部3と、管理テーブル4と、テーブル表示制御部5とを備える。
【0020】
アプリケーションプログラム1は、メモリリークの検査対象となる所定のプログラムである。アプリケーションプログラム1は、メモリ管理ライブラリ2を介して、システムにおける所定のメモリ領域を動的に確保し、確保したメモリ領域を使用して情報処理等を行う。そして、アプリケーションプログラム1は、情報処理等を終えると、メモリ管理ライブラリ2を介して、確保したメモリ領域を解放する。
【0021】
メモリ管理ライブラリ2は、メモリ領域の確保および解放を行うライブラリプログラムである。
メモリ管理ライブラリ2は、メモリ領域を確保する際に、スタック解析部3を呼び出して、処理中のアプリケーションプログラム1におけるスタックフレームを取得する。そして、取得したスタックフレームと確保されたメモリ領域のアドレスとを管理テーブル4に記憶する。なお、スタックフレームについては、後述する。
また、メモリ管理ライブラリ2は、確保したメモリ領域を解放する際に、管理テーブル4に記憶されている対象のスタックフレーム等を削除する。
【0022】
スタック解析部3は、処理中のアプリケーションプログラム1におけるスタックの内容を解析し、スタックフレームを取得する。
【0023】
なお、スタックフレームとは、プログラムの実行履歴情報を得ることのできるスタック上の一群のデータ(フレーム)であり、例えば、図2(a)に示すように、アプリケーションプログラム1を構成する複数のモジュール(関数等)のうち、1モジュールが実行されると、そのモジュールにて使用される1フレーム分のスタックが生成される。
そして、複数のモジュールが階層的に実行されると、図2(b)に示すように、親フレームとその親フレームによって起動された子フレームというように、実行されたモジュールの履歴を示すスタックフレームが関連して生成される。
従って、スタックフレームの内容をトレースすることにより、例えば、どのような関数を経由してメモリ管理ライブラリ2が呼び出されたのか等、アプリケーションプログラム1の実行履歴が明確となる。
【0024】
図1に戻って、管理テーブル4は、メモリ管理ライブラリ2がメモリ領域を確保する際に、メモリ管理ライブラリ2から供給されたスタックフレームと確保されたメモリ領域のアドレスとを1組としたダンプ情報を記憶する。また、メモリ管理ライブラリ2がメモリ領域を確保する際に、対象のダンプ情報がメモリ管理ライブラリ2によって削除される。
すなわち、管理テーブル4は、現在確保された状態となっているメモリ領域に対応したダンプ情報を記憶する。なお、確保されたメモリ領域と管理テーブル4に記憶されたダンプ情報とは、1対1に対応するため、複数のメモリ領域が確保されている場合、ダンプ情報も複数存在することとなる。
【0025】
テーブル表示制御部5は、アプリケーションプログラム1の起動完了後(実行終了後)に、管理テーブル4にダンプ情報が記憶されている場合に、記憶されているダンプ情報抽出する。テーブル表示制御部5は、抽出したダンプ情報に含まれるスタックフレームの内容をユーザが容易にトレースできるように加工して、所定のディスプレイに表示する。
【0026】
以下、この実施の形態に係るメモリリーク検出システムにおけるメモリリーク検出処理について図面を参照して説明する。図3は、メモリリーク検出処理を説明するためのフローチャートである。図3に示すメモリリーク検出処理は、検査対象のアプリケーションプログラム1の起動の準備をした後、ユーザから所定の入力デバイスを介して入力された指示情報に応答して開始する。
【0027】
まず、テーブル表示制御部5は、管理テーブル4を初期化する(ステップS1)。すなわち、テーブル表示制御部5は、管理テーブル4に記憶されている情報を全てクリアする。
【0028】
管理テーブル4の初期化後、OSは、アプリケーションプログラム1の処理を起動する(ステップS2)。
【0029】
アプリケーションプログラム1は、処理中にメモリ確保の要求が発生した場合(ステップS3)、メモリ管理ライブラリ2を呼び出す。
【0030】
アプリケーションプログラム1に呼び出されたメモリ管理ライブラリ2は、所定のメモリ領域の確保と、スタックフレームの取得を行う(ステップS4)。すなわち、メモリ管理ライブラリ2は、アプリケーションプログラム1が要求したメモリ領域を確保すると共に、スタック解析部3を呼び出して、アプリケーションプログラム1におけるスタックの内容を解析し、スタック上の一群のデータからなるスタックフレームを取得する。
【0031】
メモリ管理ライブラリ2は、取得したスタックフレームと確保したメモリ領域のアドレスとからなるダンプ情報を管理テーブル4に記憶する(ステップS5)。
【0032】
アプリケーションプログラム1は、確保したメモリ領域を使用して、所定の情報処理を行う。アプリケーションプログラム1は、所定の情報処理を終え、確保したメモリ解放の要求が発生した場合(ステップS6)、メモリ管理ライブラリ2を呼び出す。
【0033】
アプリケーションプログラム1に呼び出されたメモリ管理ライブラリ2は、確保されたメモリ領域の解放と、ダンプ情報の削除を行う(ステップS7)。すなわち、メモリ管理ライブラリ2は、アプリケーションプログラム1が確保していたメモリ領域を解放すると共に、管理テーブル4に記憶された対応するダンプ情報を削除する。
【0034】
上記のステップS3〜S7の処理は、アプリケーションプログラム1の起動処理が完了するまで逐次繰り返される(ステップS8)。
【0035】
アプリケーションプログラム1の起動処理が完了すると、テーブル表示制御部5は、管理テーブル4を参照し、ダンプ情報が記録されているか否かを判別する(ステップS9)。すなわち、テーブル表示制御部5は、メモリリークの発生を示すダンプ情報が管理テーブル4に記憶されているか否かを判別する。
【0036】
テーブル表示制御部5は、管理テーブル4にダンプ情報が記録されていないと判別した場合、メモリリーク検出処理を終了する。この際、メモリリークが発生しなかった旨を表示してもよい。
一方、ダンプ情報が記録されていると判別した場合、テーブル表示制御部5は、ダンプ情報に含まれるスタックフレーム等を表示する(ステップS10)。例えば、テーブル表示制御部5は、図4に示すように、スタックフレームの内容と共に、アプリケーションプログラム1のソースコードを表示して、ユーザがメモリリークの要因を把握できるように、所定のディスプレイに表示する。
【0037】
この結果、メモリ領域の解放漏れを検出し、さらにその要因を的確に特定することができる。
【0038】
上記の実施の形態では、テーブル表示制御部5が、管理テーブル4から削除されなかったダンプ情報に含まれるスタックフレーム等のみを表示したが、削除されなかったダンプ情報のスタックフレームから辿った呼び出し元である親フレームをも表示してもよい。この場合、メモリリークの要因を更に的確に特定することができる。
【0039】
上記の実施の形態では、メモリ領域が解放された際に、管理テーブル4から対応するダンプ情報を削除したが、管理テーブル4からダンプ情報の削除を行わずに、全体のメモリ領域の確保と解放とを把握し、解放が行われなかったメモリ領域を検出してもよい。
【0040】
なお、この発明の実施の形態にかかるメモリリーク検出システムは、専用のシステムによらず、通常のコンピュータシステムを用いて実現可能である。例えば、コンピュータに上述のいずれかを実行するためのプログラムを格納した媒体(フロッピーディスク、CD−ROM等)から該プログラムをインストールすることにより、上述の処理を実行するメモリリーク検出システムを構成することができる。
【0041】
また、コンピュータにプログラムを供給するための媒体は、通信媒体(通信回線、通信ネットワーク、通信システムのように、一時的かつ流動的にプログラムを保持する媒体)でも良い。例えば、通信ネットワークの掲示板(BBS)に該プログラムを掲示し、これをネットワークを介して配信してもよい。
そして、このプログラムを起動し、OSの制御下で、他のアプリケーションプログラムと同様に実行することにより、上述の処理を実行することができる。
【0042】
【発明の効果】
以上説明したように、本発明によれば、メモリ領域の解放漏れを検出し、さらにその要因を的確に特定することができる。
【図面の簡単な説明】
【図1】本発明の実施の形態に係るメモリリーク検出システムの構成の一例を示す模式図である。
【図2】(a)がスタックフレームの一例を示す模式図であり、(b)が親フレームと子フレームとの関係を表す模式図である。
【図3】本発明の実施の形態に係るメモリリーク検出処理を説明するためのフローチャートである。
【図4】テーブル表示制御部により所定の画面に表示されるメモリリーク検出画面の一例を示す模式図である。
【符号の説明】
1 アプリケーションプログラム
2 メモリ管理ライブラリ
3 スタック解析部
4 管理テーブル
5 テーブル表示制御部
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a memory leak detection system, a memory leak detection method, and a recording medium capable of detecting a release leak of a memory area when debugging an application program or the like and further accurately identifying the cause.
[0002]
[Prior art]
In general, an application program executed on an OS (Operating System) of a computer system, for example, dynamically allocates a predetermined memory area via a system call or API (Application Program Interface) that is one of the functions of the OS. And information processing is performed using the reserved memory area. When the application program finishes the information processing and the like, it releases the secured memory area and returns it to the OS.
At this time, if there is some bug in the application program and the memory area is not released, a so-called memory leak occurs. That is, in this case, the memory leak means a state in which a memory area that is not used remains in the memory space because a memory area that is no longer required by an application program or the like is not properly released (not returned to the system).
[0003]
When such a memory leak occurs, the OS cannot allocate the memory area remaining in the memory space to another application program, and the total amount of usable memory is reduced as a whole system. When the total amount of usable memory decreases to the limit, the application program or the like ends abnormally. Therefore, in the development of application programs, debugging is performed in a test process so as to appropriately remove bugs that cause memory leaks.
[0004]
In recent years, in order to improve user operability, multi-functionality, and the like, application programs are generally increasing in scale. As the size of the application program increases, the probability of including a bug that causes a memory leak in the program increases, as well as detecting the memory leak and identifying the cause of the bug that causes the memory leak It has become difficult.
[0005]
Japanese Patent Application Laid-Open No. 9-244948 discloses a technique for practically detecting such a memory leak of an application program. This technique stores allocation information at the time of memory area allocation and release information at the time of memory area release, and investigates where in the program a memory area that is not released is allocated.
[0006]
[Problems to be solved by the invention]
However, with the technique disclosed in Japanese Patent Application Laid-Open No. 9-244948, even if the location where the memory area is allocated in the application program can be specified, it is possible to specify the call path of the function that called the location. Can not.
For this reason, in an application program or the like in which functions are called hierarchically, sufficient information cannot be obtained, and the cause of the memory leak cannot be accurately specified.
[0007]
The present invention has been made in view of the above circumstances, and provides a memory leak detection system, a memory leak detection method, and a recording medium capable of detecting a release leak of a memory area and accurately specifying the cause. With the goal.
[0008]
[Means for Solving the Problems]
In order to achieve the above object, a memory leak detection system according to a first aspect of the present invention includes:
A memory leak detection system for detecting a release leak of a memory area in an application program whose activation is controlled by an operating system and in which a plurality of modules can be executed hierarchically ,
Memory area securing means for securing a predetermined memory area in accordance with a request from the activated application program;
Stack information obtaining means for obtaining stack information for obtaining an execution history of each module in the application program at the time when the memory area securing means secures the memory area;
Stack information storage means for storing the stack information acquired by the stack information acquisition means in association with the memory area secured by the memory area securing means;
Memory area releasing means for releasing the memory area secured by the memory area securing means in accordance with a request from an application program;
Stack information deletion means for deleting stack information corresponding to the memory area released by the memory area release means from the stack information storage means;
When the activation of the application program is completed, stack information determination means for determining whether or not stack information is stored in the stack information storage means,
Stack information display means for extracting stack information from the stack information storage means and displaying an execution history of each module when the stack information determination means determines that the stack information is stored in the stack information storage means When,
It is characterized by providing.
[0009]
According to the present invention, the memory area securing means reserves a predetermined memory area in accordance with a request from the activated application program. The stack information acquisition means acquires stack information for obtaining an execution history of each module in the application program at the time when the memory area securing means secures the memory area. The stack information storage means stores the stack information acquired by the stack information acquisition means in association with the memory area secured by the memory area securing means. The memory area releasing means releases the memory area secured by the memory area securing means in accordance with a request from the application program. The stack information deleting unit deletes the stack information corresponding to the memory area released by the memory area releasing unit from the stack information storage unit. The stack information determination unit determines whether or not stack information is stored in the stack information storage unit when the activation of the application program is completed. The stack information display unit extracts the stack information from the stack information storage unit and displays the execution history of each module when the stack information determination unit determines that the stack information is stored in the stack information storage unit. As a result, it is possible to detect a memory area release leak in the application program and to accurately identify the cause of the memory leak.
[0010]
The stack information acquired by the stack information acquisition means includes at least a stack frame composed of a group of data on the stack,
The stack information display means may display a module hierarchy in an application program that has requested the memory area securing means to secure a memory area in accordance with a stack frame included in the stack information. In this case, if a memory area release leak is detected, the cause of the memory leak can be accurately identified from the module hierarchy in the displayed application program.
[0011]
In order to achieve the above object, a memory leak detection system according to a second aspect of the present invention includes:
A memory leak detection system for detecting a release leak of a memory area in an application program whose activation is controlled by an operating system and in which a plurality of modules can be executed hierarchically ,
Memory area securing means for securing a predetermined memory area in accordance with a request from the activated application program;
Analyzing the stack at the time when the memory area securing means secures the memory area and obtaining a stack frame consisting of a group of data on the stack that can obtain the execution history of each module in the application program that requested the memory area securing Stack frame identification means to identify;
Dump information generating means for generating dump information consisting of the stack frame specified by the stack frame specifying means and the address of the memory area secured by the memory area securing means;
Dump information storage means for sequentially storing dump information generated by the dump information generation means;
Memory area releasing means for releasing the memory area secured by the memory area securing means in accordance with a request from an application program;
Dump information specifying means for specifying the corresponding dump information stored in the dump information storage means according to the address of the memory area released by the memory area release means;
Dump information deleting means for deleting the dump information specified by the dump information specifying means from the dump information storage means;
When the activation of the application program is completed, dump information determination means for determining whether dump information is stored in the dump information storage means,
Dump information extracting means for extracting dump information from the dump information storage means when the dump information determination means determines that dump information is stored in the dump information storage means;
Stack frame display means for processing the contents of the stack frame included in the dump information extracted by the dump information extraction means into a predetermined display format and displaying the execution history of each module ;
It is characterized by providing.
[0012]
According to the present invention, the memory area securing means reserves a predetermined memory area in accordance with a request from the activated application program. The stack frame specifying means analyzes a stack at the time when the memory area securing means secures the memory area, and a group of data on the stack that can obtain an execution history of each module in the application program that requested the memory area securing. Specifies a stack frame consisting of The dump information generating unit generates dump information including the stack frame specified by the stack frame specifying unit and the address of the memory area secured by the memory area securing unit. The dump information storage unit sequentially stores the dump information generated by the dump information generation unit. The memory area releasing means releases the memory area secured by the memory area securing means in accordance with a request from the application program. The dump information specifying unit specifies the corresponding dump information stored in the dump information storage unit according to the address of the memory area released by the memory area releasing unit. The dump information deleting unit deletes the dump information specified by the dump information specifying unit from the dump information storage unit. The dump information determination unit determines whether or not the dump information is stored in the dump information storage unit when the activation of the application program is completed. The dump information extraction unit extracts the dump information from the dump information storage unit when the dump information determination unit determines that the dump information is stored in the dump information storage unit. The stack frame display means processes the contents of the stack frame included in the dump information extracted by the dump information extraction means into a predetermined display format, and displays the execution history of each module . As a result, it is possible to detect a memory area release leak in the application program and to accurately identify the cause of the memory leak.
[0013]
In order to achieve the above object, a memory leak detection system according to a third aspect of the present invention includes:
A memory leak detection system for detecting a release leak of a memory area in an application program whose activation is controlled by an operating system and in which a plurality of modules can be executed hierarchically ,
A stack analysis unit that analyzes a stack in the system and identifies a stack frame including a group of data on the stack;
A memory allocation library that is called from an activated application program, secures a predetermined memory area, and acquires a stack frame for obtaining an execution history of each module in the application program at that time specified by the stack analysis unit; ,
An address of a memory area secured by the memory securing library, and a management table for sequentially storing dump information including the acquired stack frame;
A memory release library that releases the memory area secured by the memory reservation library according to a request from an application program, and deletes dump information stored in the management table;
When startup of the application program is completed, the presence / absence of dump information stored in the management table is determined. When it is determined that dump information is stored , each module is determined from the contents of the stack frame included in the dump information. A table display for displaying the execution history of
It is characterized by providing.
[0014]
According to the present invention, the stack analysis unit analyzes a stack in the system and specifies a stack frame composed of a group of data on the stack. The memory securing library is called from the activated application program, secures a predetermined memory area, and obtains a stack frame for obtaining an execution history of each module in the application program at that time specified by the stack analysis unit. . The management table sequentially stores the address of the memory area secured by the memory securing library and dump information including the acquired stack frame. The memory release library releases the memory area secured by the memory securing library in accordance with a request from the application program and deletes dump information stored in the management table. When the application program startup is completed, the table display unit determines whether or not there is dump information stored in the management table. If it is determined that dump information is stored, the contents of the stack frame included in the dump information To display the execution history of each module . As a result, it is possible to detect a memory area release leak in the application program and to accurately identify the cause of the memory leak.
[0015]
In order to achieve the above object, a memory leak detection method according to a fourth aspect of the present invention includes:
A memory leak detection method for detecting a release leak of a memory area in an application program whose activation is controlled by an operating system and in which a plurality of modules can be executed hierarchically ,
A memory area securing step for securing a predetermined memory area in accordance with a request from the activated application program;
A stack information obtaining step for obtaining stack information for obtaining an execution history of each module in the application program at the time when the memory area is secured in the memory area securing step;
A stack information storage step of storing the stack information acquired in the stack information acquisition step in a predetermined management table in association with the memory area secured in the memory area securing step;
A memory area releasing step for releasing the memory area secured in the memory area securing step according to a request from an application program;
A stack information deletion step of deleting the stack information stored in the management table corresponding to the memory area released in the memory area release step;
When the activation of the application program is completed, a stack information determining step for determining whether there is stack information remaining without being deleted from the management table in the stack information deleting step;
When it is determined that the stack information remains in the management table in the stack information determination step, the stack information stored in the management table is extracted, and a stack information display step for displaying the execution history of each module ;
It is characterized by providing.
[0016]
According to the present invention, the memory area securing step secures a predetermined memory area in accordance with a request from the activated application program. The stack information acquisition step acquires stack information for obtaining an execution history of each module in the application program at the time when the memory area is secured in the memory area securing step. In the stack information storage step, the stack information acquired in the stack information acquisition step is stored in a predetermined management table in association with the memory area secured in the memory area securing step. The memory area releasing step releases the memory area secured in the memory area securing step in accordance with a request from the application program. In the stack information deletion step, the stack information stored in the management table corresponding to the memory area released in the memory area release step is deleted. The stack information determining step determines whether or not there is stack information that remains without being deleted from the management table in the stack information deleting step when the activation of the application program is completed. In the stack information display step, when it is determined in the stack information determination step that the stack information remains in the management table, the stack information stored in the management table is extracted and the execution history of each module is displayed. As a result, it is possible to detect a memory area release leak in the application program and to accurately identify the cause of the memory leak.
[0017]
In order to achieve the above object, a recording medium according to the fifth aspect of the present invention provides:
A computer-readable recording medium storing a program for causing a computer to execute a memory leak detection method for detecting a memory area release leak in an application program that is controlled by an operating system and that can execute a plurality of modules hierarchically There,
In accordance with a request from the activated application program, a memory area securing step for securing a predetermined memory area, and an execution history of each module in the application program at the time when the memory area is secured in the memory area securing step Stack information acquisition step for acquiring stack information, and stack information for storing the stack information acquired in the stack information acquisition step in a predetermined management table in association with the memory area secured in the memory area securing step A storage step, a memory area releasing step for releasing the memory area secured in the memory area securing step according to a request from an application program, and a management table corresponding to the memory area released in the memory area releasing step A stack information deleting step for deleting the stored stack information, and a stack information determining step for determining whether or not there is stack information remaining without being deleted from the management table in the stack information deleting step when the application program is started. A stack information display step for extracting stack information stored in the management table and displaying an execution history of each module when it is determined in the stack information determination step that the stack information remains in the management table; A program for causing a computer to execute the memory leak detection method having the above is recorded.
[0018]
DETAILED DESCRIPTION OF THE INVENTION
A memory leak detection system according to an embodiment of the present invention will be described below with reference to the drawings.
[0019]
FIG. 1 is a schematic diagram showing an example of a memory leak detection system applied to the embodiment of the present invention. This system is a memory leak detection system that detects a memory area release leak in an application program controlled to be started by a predetermined OS, and includes an application program 1, a memory management library 2, a stack analysis unit 3, and a management table. 4 and a table display control unit 5.
[0020]
The application program 1 is a predetermined program to be inspected for memory leaks. The application program 1 dynamically secures a predetermined memory area in the system via the memory management library 2, and performs information processing using the secured memory area. When the application program 1 finishes the information processing, the application program 1 releases the secured memory area via the memory management library 2.
[0021]
The memory management library 2 is a library program that secures and releases a memory area.
When the memory management library 2 reserves a memory area, it calls the stack analysis unit 3 to acquire a stack frame in the application program 1 being processed. Then, the acquired stack frame and the address of the reserved memory area are stored in the management table 4. The stack frame will be described later.
Further, the memory management library 2 deletes the target stack frame and the like stored in the management table 4 when releasing the secured memory area.
[0022]
The stack analysis unit 3 analyzes the contents of the stack in the application program 1 being processed and acquires a stack frame.
[0023]
The stack frame is a group of data (frames) on the stack from which program execution history information can be obtained. For example, as shown in FIG. 2A, a plurality of modules constituting the application program 1 When one module is executed among (function etc.), a stack for one frame used in the module is generated.
When a plurality of modules are executed hierarchically, as shown in FIG. 2B, a stack frame indicating a history of executed modules, such as a parent frame and a child frame activated by the parent frame. Are generated in association.
Therefore, by tracing the contents of the stack frame, the execution history of the application program 1 such as, for example, what function the memory management library 2 is called through becomes clear.
[0024]
Returning to FIG. 1, when the memory management library 2 secures a memory area, the management table 4 stores dump information in which the stack frame supplied from the memory management library 2 and the address of the secured memory area are set as one set. Remember. Further, when the memory management library 2 secures a memory area, the target dump information is deleted by the memory management library 2.
That is, the management table 4 stores dump information corresponding to the memory area that is currently secured. The secured memory area and the dump information stored in the management table 4 have a one-to-one correspondence. Therefore, when a plurality of memory areas are secured, a plurality of dump information also exist.
[0025]
The table display control unit 5 extracts the stored dump information when dump information is stored in the management table 4 after the start of the application program 1 (after completion of execution). The table display control unit 5 processes the contents of the stack frame included in the extracted dump information so that the user can easily trace it, and displays it on a predetermined display.
[0026]
The memory leak detection process in the memory leak detection system according to this embodiment will be described below with reference to the drawings. FIG. 3 is a flowchart for explaining the memory leak detection process. The memory leak detection process shown in FIG. 3 is started in response to instruction information input from a user via a predetermined input device after preparing to start the application program 1 to be inspected.
[0027]
First, the table display control unit 5 initializes the management table 4 (step S1). That is, the table display control unit 5 clears all information stored in the management table 4.
[0028]
After the initialization of the management table 4, the OS activates the process of the application program 1 (step S2).
[0029]
The application program 1 calls the memory management library 2 when a memory reservation request is generated during processing (step S3).
[0030]
The memory management library 2 called by the application program 1 secures a predetermined memory area and acquires a stack frame (step S4). That is, the memory management library 2 secures the memory area requested by the application program 1 and calls the stack analysis unit 3 to analyze the contents of the stack in the application program 1 and to form a stack frame composed of a group of data on the stack. To get.
[0031]
The memory management library 2 stores dump information including the acquired stack frame and the address of the reserved memory area in the management table 4 (step S5).
[0032]
The application program 1 performs predetermined information processing using the reserved memory area. When the application program 1 finishes predetermined information processing and a request for releasing the secured memory is generated (step S6), the application program 1 calls the memory management library 2.
[0033]
The memory management library 2 called by the application program 1 releases the secured memory area and deletes the dump information (step S7). That is, the memory management library 2 releases the memory area reserved by the application program 1 and deletes the corresponding dump information stored in the management table 4.
[0034]
The processes in steps S3 to S7 are sequentially repeated until the activation process of the application program 1 is completed (step S8).
[0035]
When the activation process of the application program 1 is completed, the table display control unit 5 refers to the management table 4 and determines whether dump information is recorded (step S9). That is, the table display control unit 5 determines whether or not dump information indicating the occurrence of a memory leak is stored in the management table 4.
[0036]
When the table display control unit 5 determines that the dump information is not recorded in the management table 4, the table display control unit 5 ends the memory leak detection process. At this time, it may be displayed that no memory leak has occurred.
On the other hand, when it is determined that the dump information is recorded, the table display control unit 5 displays a stack frame or the like included in the dump information (step S10). For example, as shown in FIG. 4, the table display control unit 5 displays the source code of the application program 1 together with the contents of the stack frame, and displays it on a predetermined display so that the user can grasp the cause of the memory leak. To do.
[0037]
As a result, it is possible to detect a memory area release omission and further accurately identify the cause.
[0038]
In the above embodiment, the table display control unit 5 displays only the stack frame and the like included in the dump information that has not been deleted from the management table 4, but the caller traced from the stack frame of the dump information that has not been deleted. The parent frame that is may also be displayed. In this case, the cause of the memory leak can be specified more accurately.
[0039]
In the above embodiment, when the memory area is released, the corresponding dump information is deleted from the management table 4. However, the entire memory area is secured and released without deleting the dump information from the management table 4. And a memory area that has not been released may be detected.
[0040]
It should be noted that the memory leak detection system according to the embodiment of the present invention can be realized using a normal computer system, not a dedicated system. For example, configuring a memory leak detection system that executes the above-described processing by installing the program from a medium (floppy disk, CD-ROM, etc.) that stores the program for executing any of the above-mentioned in a computer Can do.
[0041]
The medium for supplying the program to the computer may be a communication medium (a medium that temporarily and fluidly holds the program, such as a communication line, a communication network, or a communication system). For example, the program may be posted on a bulletin board (BBS) of a communication network and distributed via the network.
Then, by starting this program and executing it in the same manner as other application programs under the control of the OS, the above-described processing can be executed.
[0042]
【The invention's effect】
As described above, according to the present invention, it is possible to detect a memory area release leak and accurately specify the cause.
[Brief description of the drawings]
FIG. 1 is a schematic diagram showing an example of a configuration of a memory leak detection system according to an embodiment of the present invention.
FIG. 2A is a schematic diagram illustrating an example of a stack frame, and FIG. 2B is a schematic diagram illustrating a relationship between a parent frame and a child frame.
FIG. 3 is a flowchart for explaining memory leak detection processing according to the embodiment of the present invention;
FIG. 4 is a schematic diagram illustrating an example of a memory leak detection screen displayed on a predetermined screen by a table display control unit.
[Explanation of symbols]
1 Application program 2 Memory management library 3 Stack analysis unit 4 Management table 5 Table display control unit

Claims (6)

オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出システムであって、
起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保するメモリ領域確保手段と、
前記メモリ領域確保手段がメモリ領域を確保した時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタック情報を取得するスタック情報取得手段と、
前記スタック情報取得手段が取得したスタック情報を、前記メモリ領域確保手段が確保したメモリ領域と対応付けて記憶するスタック情報記憶手段と、
前記メモリ領域確保手段が確保したメモリ領域を、アプリケーションプログラムからの要求に従って解放するメモリ領域解放手段と、
前記メモリ領域解放手段により解放されたメモリ領域に対応するスタック情報を前記スタック情報記憶手段から削除するスタック情報削除手段と、
アプリケーションプログラムの起動が完了すると、前記スタック情報記憶手段にスタック情報が記憶されているか否かを判別するスタック情報判別手段と、
前記スタック情報判別手段によりスタック情報が前記スタック情報記憶手段に記憶されていると判別された場合に、前記スタック情報記憶手段からスタック情報を抽出し、各モジュールの実行履歴を表示するスタック情報表示手段と、
を備えることを特徴とするメモリリーク検出システム。
A memory leak detection system for detecting a release leak of a memory area in an application program whose activation is controlled by an operating system and in which a plurality of modules can be executed hierarchically ,
Memory area securing means for securing a predetermined memory area in accordance with a request from the activated application program;
Stack information obtaining means for obtaining stack information for obtaining an execution history of each module in the application program at the time when the memory area securing means secures the memory area;
Stack information storage means for storing the stack information acquired by the stack information acquisition means in association with the memory area secured by the memory area securing means;
Memory area releasing means for releasing the memory area secured by the memory area securing means in accordance with a request from an application program;
Stack information deletion means for deleting stack information corresponding to the memory area released by the memory area release means from the stack information storage means;
When the activation of the application program is completed, stack information determination means for determining whether or not stack information is stored in the stack information storage means,
Stack information display means for extracting stack information from the stack information storage means and displaying an execution history of each module when the stack information determination means determines that the stack information is stored in the stack information storage means When,
A memory leak detection system comprising:
前記スタック情報取得手段が取得するスタック情報は、少なくともスタック上の一群のデータからなるスタックフレームを含み、
前記スタック情報表示手段は、スタック情報に含まれるスタックフレームに従って、前記メモリ領域確保手段にメモリ領域の確保を要求したアプリケーションプログラムにおけるモジュール階層を表示する、
ことを特徴とする請求項1に記載のメモリリーク検出システム。
The stack information acquired by the stack information acquisition means includes at least a stack frame composed of a group of data on the stack,
The stack information display means displays a module hierarchy in an application program that requests the memory area securing means to secure a memory area according to a stack frame included in the stack information.
The memory leak detection system according to claim 1.
オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出システムであって、
起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保するメモリ領域確保手段と、
前記メモリ領域確保手段がメモリ領域を確保した時点でのスタックを解析し、メモリ領域の確保を要求したアプリケーションプログラムにおける各モジュールの実行履歴を得ることのできるスタック上の一群のデータからなるスタックフレームを特定するスタックフレーム特定手段と、
前記スタックフレーム特定手段により特定されたスタックフレーム及び、前記メモリ領域確保手段が確保したメモリ領域のアドレスからなるダンプ情報を生成するダンプ情報生成手段と、
前記ダンプ情報生成手段が生成したダンプ情報を逐次記憶するダンプ情報記憶手段と、
前記メモリ領域確保手段が確保したメモリ領域を、アプリケーションプログラムからの要求に従って解放するメモリ領域解放手段と、
前記メモリ領域解放手段により解放されたメモリ領域のアドレスに従って、前記ダンプ情報記憶手段に記憶された対応するダンプ情報を特定するダンプ情報特定手段と、
前記ダンプ情報特定手段により特定されたダンプ情報を前記ダンプ情報記憶手段から削除するダンプ情報削除手段と、
アプリケーションプログラムの起動が完了すると、前記ダンプ情報記憶手段にダンプ情報が記憶されているか否かを判別するダンプ情報判別手段と、
前記ダンプ情報判別手段によりダンプ情報が前記ダンプ情報記憶手段に記憶されていると判別された場合に、前記ダンプ情報記憶手段からダンプ情報を抽出するダンプ情報抽出手段と、
前記ダンプ情報抽出手段により抽出されたダンプ情報に含まれるスタックフレームの内容を所定の表示形式に加工し、各モジュールの実行履歴を表示するスタックフレーム表示手段と、
を備えることを特徴とするメモリリーク検出システム。
A memory leak detection system for detecting a release leak of a memory area in an application program whose activation is controlled by an operating system and in which a plurality of modules can be executed hierarchically ,
Memory area securing means for securing a predetermined memory area in accordance with a request from the activated application program;
Analyzing the stack at the time when the memory area securing means secures the memory area and obtaining a stack frame consisting of a group of data on the stack that can obtain the execution history of each module in the application program that requested the memory area securing Stack frame identification means to identify;
Dump information generating means for generating dump information consisting of the stack frame specified by the stack frame specifying means and the address of the memory area secured by the memory area securing means;
Dump information storage means for sequentially storing dump information generated by the dump information generation means;
Memory area releasing means for releasing the memory area secured by the memory area securing means in accordance with a request from an application program;
In accordance with the address of the freed memory area by the memory area release means, and dump information specifying means for specifying the corresponding dump information stored in the dump information storage means,
Dump information deleting means for deleting the dump information specified by the dump information specifying means from the dump information storage means;
When the activation of the application program is completed, dump information determination means for determining whether dump information is stored in the dump information storage means,
Dump information extracting means for extracting dump information from the dump information storage means when the dump information determination means determines that dump information is stored in the dump information storage means;
Stack frame display means for processing the contents of the stack frame included in the dump information extracted by the dump information extraction means into a predetermined display format and displaying the execution history of each module ;
A memory leak detection system comprising:
オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出システムであって、
システムにおけるスタックを解析し、スタック上の一群のデータからなるスタックフレームを特定するスタック解析部と、
起動したアプリケーションプログラムから呼び出され、所定のメモリ領域を確保すると共に、前記スタック解析部により特定されるその時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタックフレームを取得するメモリ確保ライブラリと、
前記メモリ確保ライブラリが確保したメモリ領域のアドレス及び、取得したスタックフレームからなるダンプ情報を逐次記憶する管理テーブルと、
前記メモリ確保ライブラリが確保したメモリ領域を、アプリケーションプログラムからの要求に従って解放すると共に、前記管理テーブルに記憶されたダンプ情報を削除するメモリ解放ライブラリと、
アプリケーションプログラムの起動が完了すると、前記管理テーブルに記憶されているダンプ情報の有無を判別し、ダンプ情報が記憶されていると判別した場合に、ダンプ情報に含まれるスタックフレームの内容から、各モジュールの実行履歴を表示するテーブル表示部と、
を備えることを特徴とするメモリリーク検出システム。
A memory leak detection system for detecting a release leak of a memory area in an application program whose activation is controlled by an operating system and in which a plurality of modules can be executed hierarchically ,
A stack analysis unit that analyzes a stack in the system and identifies a stack frame including a group of data on the stack;
A memory allocation library that is called from an activated application program, secures a predetermined memory area, and acquires a stack frame for obtaining an execution history of each module in the application program at that time specified by the stack analysis unit; ,
An address of a memory area secured by the memory securing library, and a management table for sequentially storing dump information including the acquired stack frame;
A memory release library that releases the memory area secured by the memory reservation library according to a request from an application program, and deletes dump information stored in the management table;
When startup of the application program is completed, the presence / absence of dump information stored in the management table is determined. When it is determined that dump information is stored , each module is determined from the contents of the stack frame included in the dump information. A table display for displaying the execution history of
A memory leak detection system comprising:
オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出方法であって、
起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保するメモリ領域確保ステップと、
前記メモリ領域確保ステップにてメモリ領域が確保された時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタック情報を取得するスタック情報取得ステップと、
前記スタック情報取得ステップにて取得されたスタック情報を、前記メモリ領域確保ステップにて確保されたメモリ領域と対応付けて所定の管理テーブルに格納するスタック情報格納ステップと、
前記メモリ領域確保ステップにて確保されたメモリ領域を、アプリケーションプログラムからの要求に従って解放するメモリ領域解放ステップと、
前記メモリ領域解放ステップにて解放されたメモリ領域に対応する管理テーブルに格納されたスタック情報を削除するスタック情報削除ステップと、
アプリケーションプログラムの起動が完了すると、前記スタック情報削除ステップにて管理テーブルから削除されずに残っているスタック情報の有無を判別するスタック情報判別ステップと、
前記スタック情報判別ステップにてスタック情報が管理テーブルに残っていると判別された場合に、管理テーブルに格納されたスタック情報を抽出し、各モジュールの実行履歴を表示するスタック情報表示ステップと、
を備えることを特徴とするメモリリーク検出方法。
A memory leak detection method for detecting a release leak of a memory area in an application program whose activation is controlled by an operating system and in which a plurality of modules can be executed hierarchically ,
A memory area securing step for securing a predetermined memory area in accordance with a request from the activated application program;
A stack information obtaining step for obtaining stack information for obtaining an execution history of each module in the application program at the time when the memory area is secured in the memory area securing step;
A stack information storage step of storing the stack information acquired in the stack information acquisition step in a predetermined management table in association with the memory area secured in the memory area securing step;
A memory area releasing step for releasing the memory area secured in the memory area securing step according to a request from an application program;
A stack information deletion step of deleting the stack information stored in the management table corresponding to the memory area released in the memory area release step;
When the activation of the application program is completed, a stack information determining step for determining whether there is stack information remaining without being deleted from the management table in the stack information deleting step;
When it is determined that the stack information remains in the management table in the stack information determination step, the stack information stored in the management table is extracted, and a stack information display step for displaying the execution history of each module ;
A memory leak detection method comprising:
オペレーティングシステムに起動制御され、複数のモジュールが階層的に実行され得るアプリケーションプログラムにおけるメモリ領域の解放漏れを検出するメモリリーク検出方法をコンピュータに実行させるためのプログラムを記録したコンピュータ読み取り可能な記録媒体であって、
起動したアプリケーションプログラムからの要求に従って、所定のメモリ領域を確保するメモリ領域確保ステップと、前記メモリ領域確保ステップにてメモリ領域が確保された時点でのアプリケーションプログラムにおける各モジュールの実行履歴を得るためのスタック情報を取得するスタック情報取得ステップと、前記スタック情報取得ステップにて取得されたスタック情報を、前記メモリ領域確保ステップにて確保されたメモリ領域と対応付けて所定の管理テーブルに格納するスタック情報格納ステップと、前記メモリ領域確保ステップにて確保されたメモリ領域を、アプリケーションプログラムからの要求に従って解放するメモリ領域解放ステップと、前記メモリ領域解放ステップにて解放されたメモリ領域に対応する管理テーブルに格納されたスタック情報を削除するスタック情報削除ステップと、アプリケーションプログラムの起動が完了すると、前記スタック情報削除ステップにて管理テーブルから削除されずに残っているスタック情報の有無を判別するスタック情報判別ステップと、前記スタック情報判別ステップにてスタック情報が管理テーブルに残っていると判別された場合に、管理テーブルに格納されたスタック情報を抽出し、各モジュールの実行履歴を表示するスタック情報表示ステップとを有するメモリリーク検出方法をコンピュータに実行させるためのプログラムを記録したコンピュータ読み取り可能な記録媒体。
A computer-readable recording medium storing a program for causing a computer to execute a memory leak detection method for detecting a memory area release leak in an application program that is controlled by an operating system and that can execute a plurality of modules hierarchically There,
In accordance with a request from the activated application program, a memory area securing step for securing a predetermined memory area, and an execution history of each module in the application program at the time when the memory area is secured in the memory area securing step Stack information acquisition step for acquiring stack information, and stack information for storing the stack information acquired in the stack information acquisition step in a predetermined management table in association with the memory area secured in the memory area securing step A storage step, a memory area releasing step for releasing the memory area secured in the memory area securing step according to a request from an application program, and a management table corresponding to the memory area released in the memory area releasing step A stack information deleting step for deleting the stored stack information, and a stack information determining step for determining whether or not there is stack information remaining without being deleted from the management table in the stack information deleting step when the application program is started. A stack information display step for extracting stack information stored in the management table and displaying an execution history of each module when it is determined in the stack information determination step that the stack information remains in the management table; A computer-readable recording medium having recorded thereon a program for causing a computer to execute the memory leak detection method.
JP10077499A 1999-04-08 1999-04-08 Memory leak detection system, memory leak detection method, and recording medium Expired - Fee Related JP3735484B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP10077499A JP3735484B2 (en) 1999-04-08 1999-04-08 Memory leak detection system, memory leak detection method, and recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP10077499A JP3735484B2 (en) 1999-04-08 1999-04-08 Memory leak detection system, memory leak detection method, and recording medium

Publications (2)

Publication Number Publication Date
JP2000293400A JP2000293400A (en) 2000-10-20
JP3735484B2 true JP3735484B2 (en) 2006-01-18

Family

ID=14282839

Family Applications (1)

Application Number Title Priority Date Filing Date
JP10077499A Expired - Fee Related JP3735484B2 (en) 1999-04-08 1999-04-08 Memory leak detection system, memory leak detection method, and recording medium

Country Status (1)

Country Link
JP (1) JP3735484B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8949518B2 (en) 2011-11-18 2015-02-03 Apple Inc. Method for tracking memory usages of a data processing system

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100389403C (en) * 2005-04-07 2008-05-21 华为技术有限公司 Memory leakage detection and prevention method
JP2006350876A (en) * 2005-06-20 2006-12-28 Hitachi Ltd Heap dump acquisition method
JP4575252B2 (en) * 2005-08-05 2010-11-04 ヤフー株式会社 Memory leak detection program, memory leak detection device, and memory leak detection method
JP5253030B2 (en) 2008-07-31 2013-07-31 キヤノン株式会社 Management apparatus, control method thereof, and control program
JP5182821B2 (en) 2009-05-29 2013-04-17 インターナショナル・ビジネス・マシーンズ・コーポレーション Method for determining the cause of memory consumption in a program, and its computer system and computer program

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8949518B2 (en) 2011-11-18 2015-02-03 Apple Inc. Method for tracking memory usages of a data processing system

Also Published As

Publication number Publication date
JP2000293400A (en) 2000-10-20

Similar Documents

Publication Publication Date Title
TWI446262B (en) Techniques for switching threads within routines
US7908521B2 (en) Process reflection
US7111307B1 (en) Method and system for monitoring and verifying software drivers using system resources including memory allocation and access
US8250543B2 (en) Software tracing
CN107957941B (en) Method and device for processing memory leakage of mobile terminal
EP0586767A1 (en) Selective data capture for software exception conditions
US8196116B2 (en) Tracing objects in object-oriented programming model
US20020133807A1 (en) Automation and isolation of software component testing
US7958402B2 (en) Generate diagnostic data for overdue thread in a data processing system
KR20060046281A (en) Method, system, and apparatus for identifying unresponsive portions of a computer program
JPH10269105A (en) Trace system, resource release omission detection system, and recording medium
CN111966603B (en) Memory leakage detection method and device, readable storage medium and electronic equipment
JP3735484B2 (en) Memory leak detection system, memory leak detection method, and recording medium
US11822419B2 (en) Error information processing method and device, and storage medium
US20240152439A1 (en) Detection Method and Electronic Device
CN113742224A (en) Test system, method, device, computer equipment and storage medium
CN110633190B (en) Application program memory monitoring method, device, equipment and storage medium
CN115599645B (en) Method and device for testing stability of linux driving module
CN114218072A (en) Test script generation method and device, storage medium and computer equipment
CN111367796B (en) Application program debugging method and device
CN114896021A (en) Malicious container detection method, system, device and host
CN107133060A (en) A kind of data processing method and terminal
US11868240B2 (en) Information processing system with intelligent program smoke testing
CN112346994B (en) Test information association method, device, computer equipment and storage medium
CN110096323B (en) Parallel android application UI automatic exploration method

Legal Events

Date Code Title Description
A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20051024

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20091028

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20091028

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20101028

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20111028

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20121028

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20131028

Year of fee payment: 8

LAPS Cancellation because of no payment of annual fees