류짱:Beyond MySelf

Windows server 2008 x86 / 커널 메모리 단편화 / Dynamic Kernel Addressing 본문

Microsoft/Windows Platform

Windows server 2008 x86 / 커널 메모리 단편화 / Dynamic Kernel Addressing

リュちゃん 2011. 4. 25. 16:49

Windows Server 2003 운영체제까지는 NonPagedPool 그리고 PagedPool, System PTE 커널 리소스가 부족하여 장애가 발생하는 경우가 있어, Windows Server 2008 에서 Limit 제거하고 동적으로 메모리 공간을 조절할 있도록 하였습니다.

그러나 큰 메모리를 사용하는 어플리케이션들이 실행되는 환경이라면 동적 메모리 할당 기능으로 인해 커널 메모리 단편화가 발생 되어 시스템에 hang 증상이나 메모리 부족 오류가 발생 할 수 있습니다.

[환 경
]
Windows Server 2008 x86 + SP2
Physical Memory: 64G

[증 상]
1. Windows Failover Cluster 환경에서 실행 중인 특정 클러스터 리소스의 온라인 실패
2. 프로세스 실행 시 메모리 부족 오류 발생

[원 인]
PagedPool, NonPagedPool Limit 값이 운영체제로부터 2GB (자동) 설정되어 있어서 메모리 할당 해제가 반복되면서 kernel address space 단편화 되었음

커널 메모리 공간의 단편화는 디스크 공간의 단편화와 동일 한 것으로 파일이 디스크에 쓰여지는 크기가 제각기 다르듯이 시스템 리소스 공간에서 드라이버에서 요구하는 Tag별 할당되는 Pool 의 크기도 서로 다르며, 작은 고정된 전체 공간이 아닌 동적 주소 범위의 경우 Allocation/Free 가 빈번하게 발생하면서 발생할 수 있습니다.

[조치 사항]
1. 64bit 운영체제를 사용합니다.
2. 아래와 같은 방법으로 단편화 방지를 위해 Kernel 메모리 할당을 static하게 변경 합니다.

Dynamic Addressing 기능이 사용 되지 않게 고정으로 Kernel 메모리가 할당 되게 한 상황에서도 메모리 블록의 할당과 해제가 지속적으로 반복 되면 메모리 단편화는 발생 할 수 있지만 전체 사이즈가 고정 되어 있기 때문에 단편화가 발생하여도 문제가 되지 않으며 다만 전체 2G의 커널 메모리 중 Pool Memory(Nonpaged pool & paged pool) 1.25G가 할당 됨으로써 커널 메모리를 사용하는 다른 영역(System PTE, 시스템 맵 뷰, 페이지 테이블 등)의 크기가 줄어 들어 또 다른 성능 이슈가 발생 할 수 있습니다.

이러 부분을 해결 하기 위해서는 64bit 운영 체제를 사용 하시는 것이 권장 됩니다^^

Memory Management Registry Keys
http://msdn.microsoft.com/en-us/library/bb870880(VS.85).aspx


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
   NonPagedPoolLimit = (REG_DWORD) 300 (decimal)
   PagedPoolLimit = (REG_DWORD) 900 (decimal)}


[참고자료]

WS2008: Memory Management, Dynamic Kernel Addressing, Memory Priorities and I/O Handling

http://blogs.technet.com/b/askperf/archive/2008/02/07/ws2008-memory-management-dynamic-kernel-addressing-memory-priorities-and-i-o-handling.aspx


We've done several posts on the memory address space on 32-bit systems.  There is a total of 4GB of virtual address space available (2^32 = 4GB) of which 2GB is allocated to the kernel by default, with the other 2GB being allocated to user-mode memory.
 Internal components, device drivers, the file system cache, kernel stacks, per-session code data structures as well as paged and nonpaged pool memory are all mapped by the kernel.
 
Prior to Windows Vista and Windows Server 2008, the Memory Manager determined at boot time how much of this address space would be allocated to these different needs. 

However, this led to situations whereby one area would become depleted, while another area had plenty of free space. 
Exhaustion of one of these areas led to application and sometimes system failures. 

To address this, the Dynamic Kernel Address Space feature, in 32-bit versions of Windows Server 2008, the Memory Manager dynamically manages the kernel's address space, allocating and deallocating space to various uses to meet the needs of the system. 

As a result, the amount of virtual memory being used for paged and nonpaged pool, system PTE's and session space will grow and shrink based on system activity.  Thus, the need for manual tuning is reduced given the scaling improvements built into the operating system.


 



감사합니다.^^