반응형
출처 : http://www.codeproject.com/Articles/31382/Memory-Leak-Detection-Using-Windbg


Detecting memory leaks using Windbg.

Introduction

Memory leak is a time consuming bug often created by C++ developers. Detection of memory leaks is often tedious. Things get worst if the code is not written by you, or if the code base is quite huge.

Though there are tools available in the market that will help you in memory leak detection, most of these tools are not free. I found Windbg as a freeware powerful tool to solve memory leak bugs. At least, we get an idea about the code location which might be suspected to cause memory leaks. COM Interface leaks are out of the scope of this article.

Windbg is a powerful user/kernel space debugger from Microsoft, which can be downloaded and installed from here.

Using Windbg

To start working with Windbg:

  1. Configure the symbol file path to the Microsoft symbol server “SRV*d:\symbols*http://msdl.microsoft.com/download/symbols”.
  2. Add your program EXE/DLL PDB (program database) path to the symbol file path.
  3. You also need to to configure the Operating System's flag to enable user stack trace for the process which has memory leaks. This is simple, and can be done with gflags.exe. Gflags.exe is installed during Windbg's installation. This can also be done through command line, using the command “gflags.exe /i MemoryLeak.exe +ust”. My program name is Test2.exe; hence, for the demo, I will be using Test2.exe rather than MemoryLeak.exe. The snapshot below shows the setting of OS flags for the application Test2.exe.

cmd.JPG

Once we have configured Windbg for the symbol file path, start the process which is leaking memory, and attach Windbg to it. The Attach option in Windbg is available under the File menu, or can be launched using the F6 shortcut. The snapshot below shows the same:

attach.JPG

The !heap command of Windbg is used to display heaps. !heap is well documented in the Windbg help.

I have developed a small program which leaks memory, and will demonstrate further using the same.

int _tmain(int argc, _TCHAR* argv[])
{   while(1) 
     { 
        AllocateMemory(); 
     } 
     return 0; 
} 
void AllocateMemory() 
{ 
     int* a = new int[2000]; 
     ZeroMemory(a, 8000); 
     Sleep(1); 
}

The above program leaks an integer array of size 2000*4 bytes.

After attaching Windbg to the process, execute the !heap –s command. -s stands for summary. Below is the output of the !heap -s for the leaking process:

0:001> !heap -s
NtGlobalFlag enables following debugging aids for new heaps:
    validate parameters
    stack back traces
  Heap     Flags   Reserv  Commit  Virt   Free  List   UCR  Virt  Lock  Fast 
                    (k)     (k)    (k)     (k) length      blocks cont. heap 
-----------------------------------------------------------------------------
   00150000 58000062    1024     12     12      1     1     1    0      0   L  
   00250000 58001062      64     24     24     15     1     1    0      0   L  
   00260000 58008060      64     12     12     10     1     1    0      0      
   00330000 58001062   64576  47404  47404     13     4     1    0      0  
-----------------------------------------------------------------------------

Let the process execute for some time, and then re-break in to the process, and execute !heap -s again. Shown below is the output of the command:

0:001> !heap -s
NtGlobalFlag enables following debugging aids for new heaps:
   validate parameters
   stack back traces
   Heap     Flags   Reserv  Commit  Virt   Free  List   UCR  Virt  Lock  Fast 
                     (k)     (k)    (k)     (k) length      blocks cont. heap 
   -----------------------------------------------------------------------------
    00150000 58000062    1024     12     12      1     1     1    0      0   L  
    00250000 58001062      64     24     24     15     1     1    0      0   L  
    00260000 58008060      64     12     12     10     1     1    0      0      
    00330000 58001062  261184 239484 239484     14     4     1    0      0      
   -----------------------------------------------------------------------------

Lines marked in bold show the growing heap. The above snapshot shows a heap with the handle 00330000 growing.

Execute “!heap -stat –h 00330000” for the growing heap. This command shows the heap statistics for the growing heap. Shown below is the command's output.

0:001> !heap -stat -h 00330000
heap @ 00330000
group-by: TOTSIZE max-display: 20
    size     #blocks     total     ( %) (percent of total busy bytes)
    1f64 76c6 - e905f58  (99.99)
    1800 1 - 1800  (0.00)
    824 2 - 1048  (0.00)
    238 2 - 470  (0.00)
    244 1 - 244  (0.00)
    4c 5 - 17c  (0.00)
    b0 2 - 160  (0.00)
    86 2 - 10c  (0.00)
    50 3 - f0  (0.00)
    74 2 - e8  (0.00)
    38 4 - e0  (0.00)
    48 3 - d8  (0.00)
    c4 1 - c4  (0.00)
    62 2 - c4  (0.00)
    be 1 - be  (0.00)
    b8 1 - b8  (0.00)
    ae 1 - ae  (0.00)
    ac 1 - ac  (0.00)
    55 2 - aa  (0.00)
    a4 1 - a4  (0.00)

The above snapshot shows 0x76c6 blocks of size 1f64 being allocated (marked in bold). Such a huge number of blocks of the same size makes us suspect that these can be leaked blocks. Rest of the block allocations do not have growing block numbers.

The next step is to get the address of these blocks. Use the command !heap -flt s 1f64. This command filters all other blocks of heap and displays the details of blocks having size 1f64.

Shown below is the output for the command:

0:001> !heap -flt s 1f64
    _HEAP @ 150000
    _HEAP @ 250000
    _HEAP @ 260000
    _HEAP @ 330000
      HEAP_ENTRY Size Prev Flags    UserPtr UserSize - state
        003360e0 03f0 0000  [07]   003360e8    01f64 - (busy)
        00338060 03f0 03f0  [07]   00338068    01f64 - (busy)
        00339fe0 03f0 03f0  [07]   00339fe8    01f64 - (busy)
        0033bf60 03f0 03f0  [07]   0033bf68    01f64 - (busy)
        0033dee0 03f0 03f0  [07]   0033dee8    01f64 - (busy)
        01420040 03f0 03f0  [07]   01420048    01f64 - (busy)
        01421fc0 03f0 03f0  [07]   01421fc8    01f64 - (busy)
        01423f40 03f0 03f0  [07]   01423f48    01f64 - (busy)
        01425ec0 03f0 03f0  [07]   01425ec8    01f64 - (busy)
        01427e40 03f0 03f0  [07]   01427e48    01f64 - (busy)
        01429dc0 03f0 03f0  [07]   01429dc8    01f64 - (busy)
        0142bd40 03f0 03f0  [07]   0142bd48    01f64 - (busy)
        0142dcc0 03f0 03f0  [07]   0142dcc8    01f64 - (busy)
        0142fc40 03f0 03f0  [07]   0142fc48    01f64 - (busy)
        01431bc0 03f0 03f0  [07]   01431bc8    01f64 - (busy)
        01433b40 03f0 03f0  [07]   01433b48    01f64 - (busy)
        01435ac0 03f0 03f0  [07]   01435ac8    01f64 - (busy)
        01437a40 03f0 03f0  [07]   01437a48    01f64 - (busy)
        014399c0 03f0 03f0  [07]   014399c8    01f64 - (busy)
        0143b940 03f0 03f0  [07]   0143b948    01f64 - (busy)
        0143d8c0 03f0 03f0  [07]   0143d8c8    01f64 - (busy)
        0143f840 03f0 03f0  [07]   0143f848    01f64 - (busy)
        014417c0 03f0 03f0  [07]   014417c8    01f64 - (busy)
        01443740 03f0 03f0  [07]   01443748    01f64 - (busy)
        014456c0 03f0 03f0  [07]   014456c8    01f64 - (busy)
        01447640 03f0 03f0  [07]   01447648    01f64 - (busy)
        014495c0 03f0 03f0  [07]   014495c8    01f64 - (busy)
        0144b540 03f0 03f0  [07]   0144b548    01f64 - (busy)
        0144d4c0 03f0 03f0  [07]   0144d4c8    01f64 - (busy)
        0144f440 03f0 03f0  [07]   0144f448    01f64 - (busy)
        014513c0 03f0 03f0  [07]   014513c8    01f64 - (busy)
        01453340 03f0 03f0  [07]   01453348    01f64 - (busy)
        014552c0 03f0 03f0  [07]   014552c8    01f64 - (busy)
        01457240 03f0 03f0  [07]   01457248    01f64 - (busy)
        014591c0 03f0 03f0  [07]   014591c8    01f64 - (busy)
        0145b140 03f0 03f0  [07]   0145b148    01f64 - (busy)
        0145d0c0 03f0 03f0  [07]   0145d0c8    01f64 - (busy)
        0145f040 03f0 03f0  [07]   0145f048    01f64 - (busy)
        01460fc0 03f0 03f0  [07]   01460fc8    01f64 - (busy)
        01462f40 03f0 03f0  [07]   01462f48    01f64 - (busy)
        01464ec0 03f0 03f0  [07]   01464ec8    01f64 - (busy)
        01466e40 03f0 03f0  [07]   01466e48    01f64 - (busy)
        01468dc0 03f0 03f0  [07]   01468dc8    01f64 - (busy)

Use any UsrPtr column value from the listed output, and then use the the command !heap -p -a UsrPtr to display the call stack for UsrPtr. I have selected 0143d8c8 marked in bold.

Upon execution of !heap -p -a 0143d8c8, we get the call stack shown below:

0:001> !heap -p -a 0143d8c8 
    address 0143d8c8 found in
    _HEAP @ 330000
      HEAP_ENTRY Size Prev Flags    UserPtr UserSize - state
        0143d8c0 03f0 0000  [07]   0143d8c8    01f64 - (busy)
        Trace: 0025
        7c96d6dc ntdll!RtlDebugAllocateHeap+0x000000e1
        7c949d18 ntdll!RtlAllocateHeapSlowly+0x00000044
        7c91b298 ntdll!RtlAllocateHeap+0x00000e64
        102c103e MSVCR90D!_heap_alloc_base+0x0000005e
        102cfd76 MSVCR90D!_heap_alloc_dbg_impl+0x000001f6
        102cfb2f MSVCR90D!_nh_malloc_dbg_impl+0x0000001f
        102cfadc MSVCR90D!_nh_malloc_dbg+0x0000002c
        102db25b MSVCR90D!malloc+0x0000001b
        102bd691 MSVCR90D!operator new+0x00000011
        102bd71f MSVCR90D!operator new[]+0x0000000f
        4113d8 Test2!AllocateMemory+0x00000028
        41145c Test2!wmain+0x0000002c
        411a08 Test2!__tmainCRTStartup+0x000001a8
        41184f Test2!wmainCRTStartup+0x0000000f
        7c816fd7 kernel32!BaseProcessStart+0x00000023

The lines marked in bold shows the functions from our code.

Note: Sometimes, it might happen that the “!heap -s” command does not show a growing heap. In that case, use the “!heap -stat -h” command to list all the heaps with their sizes and number of blocks. Spot the growing number of blocks, and then use the “!heap –flt s SIZE” (SIZE = the size of the suspected block) command.


반응형

'UTIL > Debugging' 카테고리의 다른 글

Windows Wingdb를 이용한 MEMORY LEAK 대처법  (0) 2014.12.26
windbg 사용법 (WinDebug)  (0) 2014.05.26
gdb 사용법 안내  (0) 2012.08.01
dbx와 core 파일 분석 및 사용법  (0) 2012.08.01
반응형

출처 : http://darpangs.tistory.com/19

----------------------------------------------------------------------------------

참조 : http://www.codeproject.com/KB/cpp/MemoryLeak.aspx


1. gflags.exe 를 이용하여 메모리 할당 트레이싱 대상 프로그램을 세팅한다.
- gflags.exe /i MLeakTarget.exe +ust

: 프로세스 이름을 기준으로 트레이싱을 시작하는 듯.

2. WinDbg 를 이용해서 대상 프로세스에 attach 한다.
3. !heap -s  명령어를 입력한다.현재 사용 중인 heap 의 사용 내역이 보인다.

4. !heap -stat -h 00330000 명령어를 입력한다.
: 각 힙에 대한 핸들값을 마지막에 인자로 넣는다. ( 00330000 )
: 그러면 해당 힙의 사용 내역이 자세히 나온다.
: 위의 참조 글을 보면, 여기서 크기를 기준으로 필터링해서 다시 목록을 뽑고, 뽑아진 목록에서 해당 힙을 가리키는 유저모드 포인터 값이 나온다.
: 이 포인트 값을 이용해서 어떻게 할당된 메모리 인지 콜스택을 볼 수 있다. ( 이건 gflags.exe 에 의해 세팅되었기 때문에 가능하다. )

5. !heap -p -a 0x143fa303
: 이 명령을 입력하면, 인자로 넣어진 주소가 어떻게 allocation 되었는지 그 때의 콜 스택이 나오게된다.
: 적당한 디버깅 심벌들이 갖추어져 있다면, 어디서 할당된 놈인지 파악할 수 있을것이다.

6.. 원하는 주소값이 나온다면, ln 주소값  명령을 이용해서 해당되는 소스라인을 확보한다.
: ln 명령어 찾는다고 좀 헤멨음. ;;
----------------------------------------------------------------------------------------------
위의 참조 사이트에서 나오는 방법은 실제 필드에서는 저렇게 큰 메모리가 leak 되는 상황은 거의 없고, 실제로는 항상 작은 용량의 메모리 들이 leak 되기 때문에 별로 쓸모가 없다고 얘기가 나오고 있다.

뭐... 그럴수도 있을거 같고, 나의 경우엔...

현재 작업 중인 프로그램 코드내부에 메모리를 할당하고 해제하는 함수를 모조리 래핑해 놓은게 있다.

그래서 프로그램 종료 시에 할당되고 해제되지 않은 메모리의 주소값을 친절하게도 알려준다.

뭐 그 정도면 게임끝~ 위의 단계에서 바로 5번 단계의 명령어를 쓰면 필요한 콜 스택을 구할 수 있다.



--------------------------------------------------------------------------------------------

출처 : http://blog.daum.net/_blog/BlogTypeView.do?blogid=03gwy&articleno=15700730


상용툴을 사용하지 않고 WinDBG를 활용한 힙영역 메모리 누수 탐지에 관한 내용이 코드프로젝트 사이트에 있어서 복습할 겸 글을 써보기로 했습니다.

 

1. WinDBG 실행후 PDB와 실행이미지 경로 세팅

   (실행파일은 계속적으로 메모리 누수가 일어나는 형태의 파일이어야 함. 간단한 소스를 만들면 됩니다)

2. 적당히 WinDbg로 실행하다가 브레이크를 건뒤 커맨드를 넣는다.

3. !heap -s 힙의 상태를 표시해줌

4. 다시 실행하고 적당히 시간이 지났을 때 브레이크 걸고 3번을 반복

5. 힙 핸들 중 이전에 비해 메모리 차지하는 비중이 큰 핸들 값을 조사

6 !heap -stat -h 12345678  12345678 핸들의 힙 상태를 보겠다는 의미

7. 이중에서 블럭 할당 값이 지나치게 많은 값이 메모리 누수 부분이라고 할 수 있겠습니다.

   블럭 사이즈가 많이 있으므로 의심되는 블럭 크기의 값만 보기 위해

8. !heap -flt s 1fd4   블럭 크기가 1fd4인 값만 필터링해서 보여달라는 의미

9. 그러면 1f4d 크기로 할당된 리스트들이 가득 나옵니다. 각 항목중에 usrptr 값이 있습니다. 이 항목을 사용하면 이 값이 힙에 할당되기 까지의 스택 트레이스를 보여 줍니다.

10. !heap -p -a usrptr 


--------------------------------------------------------------------------------------------

출처 : http://www.duck.pe.kr/m/post/173


00400000 00413000 image00400000 C (no symbols)
71710000 71794000 comctl32 (deferred)
77980000 77a1b000 oleaut32 (deferred)
77de0000 77e49000 user32 (deferred)
77e50000 77f32000 kernel32 (deferred)
77f40000 77f7c000 GDI32 (deferred)
77f80000 77ffc000 ntdll (pdb symbols) c:\websymbols\ntdll.pdb\41AFDCD61\ntdll.pdb
786f0000 7875f000 RPCRT4 (deferred)
796d0000 79735000 ADVAPI32 (deferred)
7cf00000 7cfef000 ole32 (deferred)

- .help : 메타명령어 (.명령) 도움말

- .hh : DEBUGGER.CHM 명령 띄우기.

- ~ Thread 관련 명령

Threads can only be specified in user mode. In kernel mode, the tilde (~) refers to a processor.

Also note that many commands can be preceded by a thread symbol. For an explanation of a tilde (~) followed by a command, see the entry for the command itself.

Here are examples of the use of this command. The following command will display all threads:

0:001> ~

The following command will also display all threads:

0:001> ~*

The following command will display the currently active thread:

0:001> ~.

The following command will display the thread that originally caused the exception (or that was active when the debugger attached to the process):

0:001> ~#

The following command will display thread number 2:

0:001> ~2

Here is an example of the output of this command:

0:001> ~
0 id: 4dc.470 Suspend: 0 Teb 7ffde000 Unfrozen
. 1 id: 4dc.534 Suspend: 0 Teb 7ffdd000 Unfrozen
# 2 id: 4dc.5a8 Suspend: 0 Teb 7ffdc000 Unfrozen

On the first line of this example, 0 is the decimal thread number; 4DC is the hexadecimal process ID, 470 is the hexadecimal thread ID, 0x7FFDE000 is the address of the TEB, and Unfrozen is the thread status. The period (.) before thread 1 means this is the current thread. The number sign (#) before thread 2 means this thread was the one that originally caused the exception or it was ctive when the debugger attached to the rocess.

- LD : (load Symbols)

0:000> ld ole32
Symbols loaded for ole32
0:000> lm
start end module name
00400000 00413000 image00400000 C (no symbols)
71710000 71794000 comctl32 (deferred)
77980000 77a1b000 oleaut32 (deferred)
77de0000 77e49000 user32 (deferred)
77e50000 77f32000 kernel32 (deferred)
77f40000 77f7c000 GDI32 (deferred)
77f80000 77ffc000 ntdll (pdb symbols) c:\websymbols\ntdll.pdb\41AFDCD61\ntdll.pdb
786f0000 7875f000 RPCRT4 (deferred)
796d0000 79735000 ADVAPI32 (deferred)
7cf00000 7cfef000 ole32 (pdb symbols) c:\websymbols\ole32.pdb\42CABEE01\ole32.pdb
0:000> ld kernel32
Symbols loaded for kernel32
0:000> lm
start end module name
00400000 00413000 image00400000 C (no symbols)
71710000 71794000 comctl32 (deferred)
77980000 77a1b000 oleaut32 (deferred)
77de0000 77e49000 user32 (deferred)
77e50000 77f32000 kernel32 (pdb symbols) c:\websymbols\kernel32.pdb\4498D8981\kernel32.pdb
77f40000 77f7c000 GDI32 (deferred)
77f80000 77ffc000 ntdll (pdb symbols) c:\websymbols\ntdll.pdb\41AFDCD61\ntdll.pdb
786f0000 7875f000 RPCRT4 (deferred)
796d0000 79735000 ADVAPI32 (deferred)
7cf00000 7cfef000 ole32 (pdb symbols) c:\websymbols\ole32.pdb\42CABEE01\ole32.pdb
0:000> ld *
Symbols already loaded for image00400000
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINNT\system32\comctl32.dll -
Symbols loaded for comctl32
Symbols loaded for oleaut32
Symbols loaded for user32
Symbols already loaded for kernel32
Symbols loaded for GDI32
Symbols already loaded for ntdll
Symbols loaded for RPCRT4
Symbols loaded for ADVAPI32
Symbols already loaded for ole32
0:000> lm
start end module name
00400000 00413000 image00400000 C (no symbols)
71710000 71794000 comctl32 (export symbols) C:\WINNT\system32\comctl32.dll
77980000 77a1b000 oleaut32 (pdb symbols) c:\websymbols\oleaut32.pdb\3DF8FF78\oleaut32.pdb
77de0000 77e49000 user32 (pdb symbols) c:\websymbols\user32.pdb\4211D1FD1\user32.pdb
77e50000 77f32000 kernel32 (pdb symbols) c:\websymbols\kernel32.pdb\4498D8981\kernel32.pdb
77f40000 77f7c000 GDI32 (pdb symbols) c:\websymbols\gdi32.pdb\43B3D6741\gdi32.pdb
77f80000 77ffc000 ntdll (pdb symbols) c:\websymbols\ntdll.pdb\41AFDCD61\ntdll.pdb
786f0000 7875f000 RPCRT4 (pdb symbols) c:\websymbols\rpcrt4.pdb\41E6468F7\rpcrt4.pdb
796d0000 79735000 ADVAPI32 (pdb symbols) c:\websymbols\advapi32.pdb\4253BAFE1\advapi32.pdb
7cf00000 7cfef000 ole32 (pdb symbols) c:\websymbols\ole32.pdb\42CABEE01\ole32.pdb


심볼에 대한 자세한 정보를 얻고자 하는 경우
0:000> lm v m gdi32
start end module name
77f40000 77f7c000 GDI32 (pdb symbols) c:\websymbols\gdi32.pdb\43B3D6741\gdi32.pdb
Loaded symbol image file: c:\websymbols\gdi32.dbg\43B3E1B73c000\gdi32.dbg
Image path: C:\WINNT\system32\GDI32.dll
Image name: GDI32.dll
Timestamp: Thu Dec 29 22:16:39 2005 (43B3E1B7)
CheckSum: 0003E315
ImageSize: 0003C000
File version: 5.0.2195.7073
Product version: 5.0.2195.7073
File flags: 0 (Mask 3F)
File OS: 40004 NT Win32
File type: 2.0 Dll
File date: 00000000.00000000
Translations: 0409.04b0
CompanyName: Microsoft Corporation
ProductName: Microsoft(R) Windows (R) 2000 Operating System
InternalName: gdi32
OriginalFilename: gdi32
ProductVersion: 5.00.2195.7073
FileVersion: 5.00.2195.7073
FileDescription: GDI Client DLL
LegalCopyright: Copyright (C) Microsoft Corp. 1981-1999


심볼서버

To use the Microsoft Symbol Server

1. Make sure you have installed the latest version of Debugging Tools for Windows.

2. Start a debugging session.

3. Decide where to store the downloaded symbols (the "downstream store"). This can be a local drive or a UNC path.

4. Set the debugger symbol path as follows, substituting your downstream store path for DownstreamStore.

SRV*DownstreamStore*http://msdl.microsoft.com/download/symbols

) SRV*c:\websymbols*http://msdl.microsoft.com/download/symbols

장애의종류

Crash: Heap Corrupt, AV(Access Violation)

Hang: Deal lock, Orphaned thread, contention..

Leak: Memory Leak

장애 종류에 따른 대처

Crash:

Access Violation

- adplus.vbs > CDB 사용

- Tlist process id확인 (id)

- Adplus.vbs –crash –p pid : Crash 발생하면 메모리 덤프를 생성

Heap Corrupt

- page heap: heap영역에 할당된 메모리의 영역을 체크함. 범위를 초과하는 경우 프로세스를 종료시킴.

- gflags.exe 성능을 떨어뜨릴 있으면 덤프를 뜨고나면 disable 시켜야 한다.

http://support.microsoft.com/kb/286470/ : 마이크로 소프트의 페이지

시스템 범위 페이지 힙에 GFlags 사용

GFlags 도구는 시스템 범위 페이지 힙을 설정하는 사용됩니다. GFlags 명령을 적용하려면 명령을 실행한 컴퓨터를 다시 시작해야 합니다.

시스템 범위 일반 페이지 힙을 설정하려면 다음과 같이 하십시오. 1. 명령줄에 다음을 입력합니다.

gflags -r +hpa

2. 컴퓨터를 다시 시작합니다.

시스템 범위 일반 페이지 힙을 해제하려면 다음과 같이 하십시오. 1. 명령줄에 다음을 입력합니다.

gflags -r -hpa

2. 컴퓨터를 다시 시작합니다.

단일 프로세스 페이지 힙에 GFlags 사용

특정 프로세스를 모니터링하기 위해 페이지 힙을 사용할 있도록 설정할 있습니다. 이렇게 하려면 다음 단계를 수행하십시오.

1. 명령 프롬프트에서 디버그 도구를 설치한 디렉터리로 변경합니다.

2. 명령 프롬프트에서 다음을 입력한 Enter 키를 누릅니다.

Gflags.exe –p /enable lsass.exe

참고 lsass.exe Pageheap 도구로 모니터링할 프로세스의 이름을 나타냅니다.

3. 페이지 모니터링이 이상 필요하지 않으면 모니터링을 해제합니다. 수신 대기 포트의 목록을 얻으려면 프롬프트에서 다음 명령을 입력하고 Enter 키를 누릅니다.

Gflags.exe -p /disable lsass.exe

참고 lsass.exe Pageheap 도구로 모니터링할 프로세스의 이름을 나타냅니다.

4. 현재 Pageheap 확인을 사용하는 모든 프로그램을 표시하려면 명령 프롬프트에서 다음을 입력한 다음 Enter 키를 누릅니다.

Gflags.exe –p

* Hang 장애

Deadlock, 무한 루프(while(true){ … } )등의 로직 관련 문제.

- Hang dump 받는다. Hang dump 이상 받아서 체크하도록 한다.

Adplus.vbs –hang –p pid(process id)

- Deallock이나 lock 문제가 되는 경우에는 Windbg !lock 통해서 현재 lock 가장 많이 잡고 있는 Thread등을 조사하여 본다.

* 메모리 누수

Windows 2000/XP, 2003 이상의 경우

- DebugDiag라는 메모리 누수 감지 공개소프트웨어를 사용하고, perfmon(성능 모니터)에서 process private bytes, virtual Bytes 살펴보아서 private bytes 지속적인 증가, virtual Bytes 계단식 증가를 살펴보도록 한다.

반응형

'UTIL > Debugging' 카테고리의 다른 글

Windbg를 이용한 메모리 릭 검사(영문)  (0) 2014.12.26
windbg 사용법 (WinDebug)  (0) 2014.05.26
gdb 사용법 안내  (0) 2012.08.01
dbx와 core 파일 분석 및 사용법  (0) 2012.08.01

+ Recent posts