성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] The Windows Registry Adventure #1: ...
[정성태] systemd for Developers I ; https:/...
[정성태] 엄밀히 object 타입의 인스턴스가 다른 타입으로 형변환 가능...
[정성태] 아래의 글에서 나오는 "Windows Application Pa...
[정성태] The history of calling conventions,...
[정성태] Secure and Deploy .NET Windows Form...
[정성태] Get Started with Milvus Vector DB i...
[정성태] cyberark/PipeViewer - A tool that...
[정성태] WinForms in a 64-Bit world – our st...
[정성태] 예제에서 SELECT_SQL도 내부적으로는 SqlCommand/...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>Commit 메모리가 낮은 상황에서도 메모리 부족(Out-of-memory) 예외 발생</h1> <p> 사실, 이번 글은 다음 글에 대한 또 다른 버전입니다. ^^<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 작업 관리자에서의 "Commit size"가 가리키는 메모리의 의미 ; <a target='tab' href='http://www.sysnet.pe.kr/2/0/1850'>http://www.sysnet.pe.kr/2/0/1850</a> </pre> <br /> 응용 프로그램 실행 중에, 작업 관리자에서 확인한 Working Set, Private Bytes 등의 수치는 물론이고 Commit size 조차도 충분히 여유가 있는데도 불구하고 OOM(Out-of-Memory) 예외(OutOfMemoryException)가 발생할 수 있습니다. (각각의 메모리에 대한 의미는 "<a target='tab' href='http://www.sysnet.pe.kr/2/0/1850'>작업 관리자에서의 "Commit size"가 가리키는 메모리의 의미</a>" 글을 참고하세요.)<br /> <br /> 쉬운 예로, 32비트 응용 프로그램에서 스레드를 생성해 보면 됩니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System.Collections.Generic; using System.Threading; class Program { static void Main(string[] args) { List<Thread> list = new List<Thread>(); for (int i = 0; i < 4500; i++) { list.Add(new Thread(threadFunc)); list[i].Start(); } } private static void threadFunc() { Thread.Sleep(1000 * 120); } } </pre> <br /> 위의 프로그램을 실행하면 OOM 예외가 발생하고, 이때의 메모리 상황을 작업 관리자로 확인해 보면 다음 그림과 유사하게 나옵니다.<br /> <br /> <img onclick='toggle_img(this)' class='imgView' alt='virtual_mem_oom_1.png' src='/SysWebRes/bbs/virtual_mem_oom_1.png' /><br /> <br /> 보는 바와 같이,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Workig set: 132,584K Memory (private): 118,120K Commit size: 267,856K </pre> <br /> 2GB/<a target='tab' href='http://www.sysnet.pe.kr/2/0/1441'>4GB 근처</a>에도 가지 않았지만 OOM 예외가 발생합니다. 왜냐하면, '가상 주소 공간' 예약을 2GB/4GB를 넘도록 요구했기 때문입니다.<br /> <br /> 다행히, 64비트 시대로 오면서 가용한 가상 주소 공간이 8TB가 되어 이런 식의 예외가 발생하는 경우는 많이 없어졌지만 아직도 32비트 응용 프로그램을 만드는 분들이라면 알아두시면 도움이 되실 것입니다. ^^<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
3243
(왼쪽의 숫자를 입력해야 합니다.)