류짱:Beyond MySelf

Windows Memory / VMMap 본문

Microsoft/Windows Platform

Windows Memory / VMMap

リュちゃん 2009. 12. 23. 08:51

Fundamentals of Memory Management
Windows 물리적 메모리와 가상메모리를 사용
메모리는 페이지로 관리되며 페이지는 기본 4KB로 구성

 - 32bit 아키텍처에서 토털 사용가능한 메모리 주소는 4G(2의 32승) 이며 사용자 모드와 커널 모드로 나뉘어 진다.
 - Page in System space는 커널 모드에서만 접근 가능, 사용자 모드 어플리케이션은 User mode 영역만 접근 할 수 있다.
 - 64bit 아키텍처에서는 토털 사용 가능한 메모리 주소가 16EB(2의 64승)이나 여러가지 이유로 16TB(2의 44승)만 사용
 
Virtual Memory
하나의 프로세스에서 가상 메모리는 3개의 카테고리로 나눌 수 있다.

(i) private virtual memory – that which is not shared – e.g. the process heap;
(ii) shareable – memory mapped files or space that you’ve explicitly chosen to share;
(iii) free – memory with an as yet undefined use.

Private and shareable memory can also be flagged in two ways: reserved (a thread has plans to use this range but it isn’t available yet), and committed (available to use).
Why should you reserve memory? It allows an application to lazily commit contiguous memory. For example, a stack: the system only needs to commit a small amount in advance, and can grow as appropriate by committing previously-reserved memory.

Process Explorer나 VMMap 같은 툴을 이용해서 프로세스의 가상 메모리 사용 상태를 확인 할 수 있다.
그 중 VMMap의 경우 매우 상세하게 특정 프로세스의  가상 메모리 사용 현황을 확인 할 수 있게 해준다.


커멘드를 이용해서 VMMap을 사용하는 방법
usage: vmmap [-64] [-p <pid or process name> [outputfile]] [-o inputfile]

-64
Use the 64-bit version to analyze a 32-bit process instead of the 32-bit version.
-p
Process ID or process name. If you specify a name, VMMap will match it against the first process that has a name that begins with the specified text. 
output file
If you specify an output file, VMMap will scan the target process and then terminate. If you don't include an extension, VMMap will add .mmp and save in its native format. Add a .csv extension to save as CSV format; any other extension will save as .txt.
inputfile
Has VMMap open the specified .mmp file on startup.

[참고 자료]
VMMap v3.1
http://technet.microsoft.com/en-us/sysinternals/dd535533.aspx

PDC10: Mysteries of Windows Memory Management Revealed: Part One
http://blogs.msdn.com/b/tims/archive/2010/10/28/pdc10-mysteries-of-windows-memory-management-revealed-part-one.aspx