성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Roll A Lisp In C - Reading ; https...
[정성태] Java - How to use the Foreign Funct...
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
글쓰기
제목
이름
암호
전자우편
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'>프로세스 풀 덤프 시간을 줄여 주는 Process Reflection</h1> <p> Windows Internals 책을 통해 Windows 7 이후 지원된다는 "Process Reflection"에 대해 처음 알게 되었습니다. ^^ (470 페이지에 자세하게 설명되어 있습니다.)<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Windows Internals 제6판 Vol. 1: 마이크로소프트 윈도우 커널 공식 가이드 6판 ; <a target='tab' href='http://www.yes24.com/24/goods/7877539'>http://www.yes24.com/24/goods/7877539</a> </pre> <br /> 간단하게 설명해 보면!<br /> <br /> 프로세스 Full Dump 등을 남기려면 해당 EXE 프로세스의 동작을 중지시켜 사용 중인 메모리를 모두 디스크에 써야 하는데 이 소비 시간은 프로세스가 사용 중인 메모리의 크기에 영향을 받게 됩니다. 64비트 프로세스의 경우 대용량을 쓸 수 있다는 점을 감안하면 향후 미래를 생각해 봤을 때 분명히 문제가 아닐 수 없습니다.<br /> <br /> 마이크로소프트는 이에 대한 해법으로 "Process Reflection"을 구현했는데, 대상 프로세스의 현재 상태를 반영하는 임시 자식 프로세스를 생성하는 것입니다. 따라서, 덤프를 떠야 할 프로세스는 "미니 덤프를 생성할 시간"과 해당 프로세스에 대한 정지된 "클론"을 만드는 데 드는 시간 만큼만 중지하게 되어 실 서비스 운영 중에도 큰 부담없이 사용할 수 있다는 장점이 있습니다.<br /> <br /> 현재 이 정책을 반영한 프로그램이 <a target='tab' href='https://docs.microsoft.com/en-us/sysinternals/downloads/procdump'>sysinternals 도구에 포함된 procdump.exe</a>입니다. procdump.exe로 full dump를 받는 방법은 다음과 같이 실행하게 되는데요.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C:\Windows\system32><span style='color: blue; font-weight: bold'>procdump -ma reportingservicesservice.exe D:\temp\procdump.dmp</span> ProcDump v4.0 - Writes process dump files Copyright (C) 2009-2011 Mark Russinovich Sysinternals - www.sysinternals.com Writing dump file D:\temp\procdump.dmp ... Dump written. </pre> <br /> 대상 exe가 사용하는 모든 메모리를 디스크에 복사하기 때문에 이때 <a target='tab' href='https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer'>Process Explorer</a> 등을 통해 살펴보면 reportingservicesservice.exe가 SUSPEND 상태로 머물러 있음을 확인할 수 있습니다.<br /> <br /> 하지만 윈도우 7부터 지원되는 '-r' 옵션을 이용해,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > -r Dump using a clone. Concurrent limit is optional (default 1, max 5). CAUTION: a high concurrency value may impact system performance. - Windows 7 : Uses Reflection. OS doesn't support -e. - Windows 8.0 : Uses Reflection. OS doesn't support -e. - Windows 8.1+: Uses PSS. All trigger types are supported. </pre> <br /> 덤프를 남겨보면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C:\Windows\system32>procdump <span style='color: blue; font-weight: bold'>-r</span> -ma reportingservicesservice.exe D:\temp\procdump.dmp ProcDump v4.0 - Writes process dump files Copyright (C) 2009-2011 Mark Russinovich Sysinternals - www.sysinternals.com <span style='color: blue; font-weight: bold'>Writing dump file D:\temp\procdump-1.dmp ...</span> Dump written. <span style='color: blue; font-weight: bold'>Writing dump file D:\temp\procdump-reflected.dmp ...</span> Dump written. Finished writing reflected dump. Open D:\temp\procdump.ini in the debugger to view the combined reflected dump. </pre> <br /> 보는 바와 같이 단계별로 2개의 .dmp 파일을 생성하고 그 파일들을 엮어주는 ini 파일이 다음의 내용으로 함께 생성됩니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > [UserModeDump] default=procdump-1.dmp memory=procdump-reflected.dmp module=procdump-1.dmp </pre> <br /> 여기서 procdump-1.dmp 파일은 minidump 유형의 덤프 파일로 이것을 남길 때만 대상 프로세스(본문에서는 reportingservicesservice.exe)가 SUSPEND 상태로 머물고 그 이후 메모리 덤프가 남겨지는 procdump-reflected.dmp 파일을 생성하는 동안에는 다시 정상적으로 서비스를 하게 됩니다.<br /> <br /> 실제로 windbg에서 procdump-1.dmp파일만 로드해서 .NET sos 확장 DLL을 로드하려고 하면 다음과 같이 경고 문구가 나옵니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 0:000> <span style='color: blue; font-weight: bold'>.load C:\Windows\Microsoft.NET\Framework64\v2.0.50727\sos.dll</span> ------------------------------------------------------------ <span style='color: blue; font-weight: bold'>sos.dll needs a full memory dump for complete functionality.</span> You can create one with .dump /ma <filename> ------------------------------------------------------------ </pre> <br /> 당연하지만, 미니 덤프이기때문에 그에 포함되지 않은 영역의 메모리에 대한 내용은 보여지지 않는 경우가 많습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 0:041> <span style='color: blue; font-weight: bold'>!printexception</span> Exception object: 000000008067dec0 Exception type: System.ArgumentException Message: The source '...' is not registered in log '...'. (It is registered in log '...'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property. InnerException: <none> StackTrace (generated): SP IP Function <span style='color: blue; font-weight: bold'>00000000152BCEC0</span> 00007FFADD466353 System!System.Diagnostics.EventLog.VerifyAndCreateSource(System.String, System.String)+0x313 00000000152BCF30 00007FFADD465BC1 System!System.Diagnostics.EventLog.WriteEntry(System.String, System.Diagnostics.EventLogEntryType, Int32, Int16, Byte[])+0x191 00000000152BCFD0 00007FFADDA75D3C System!System.Diagnostics.EventLog.WriteEntry(System.String, System.Diagnostics.EventLogEntryType, Int32)+0x1c 00000000152BD010 00007FFADDA75C42 TestLib!TestLib.Logger.LogEvent(System.Diagnostics.EventLogEntryType, TestLib.WindowEventLogId, System.String)+0x322 StackTraceString: <none> HResult: 80070057 0:041> <span style='color: blue; font-weight: bold'>dd 00000000152BCEC0</span> 00000000`152bcec0 ???????? ???????? ???????? ???????? 00000000`152bced0 ???????? ???????? ???????? ???????? 00000000`152bcee0 ???????? ???????? ???????? ???????? 00000000`152bcef0 ???????? ???????? ???????? ???????? 00000000`152bcf00 ???????? ???????? ???????? ???????? 00000000`152bcf10 ???????? ???????? ???????? ???????? 00000000`152bcf20 ???????? ???????? ???????? ???????? 00000000`152bcf30 ???????? ???????? ???????? ???????? </pre> <br /> 반면, INI 파일을 windbg에서 열면 ini 내부에 지정된 덤프를 자동으로 모두 열고,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > <span style='color: blue; font-weight: bold'>Loading Dump File [D:\temp\procdump.ini]</span> Loading User-mode Dump Configuration File [D:\temp\procdump.ini,D:,\temp\] default dump: [procdump-1.dmp] memory dump: [procdump-reflected.dmp] module list dump: [procdump-1.dmp] <span style='color: blue; font-weight: bold'>Loading Dump File [D:\temp\procdump-1.dmp]</span> Comment: ' *** procdump -r -ma reportingservicesservice.exe D:\temp\procdump.dmp *** Timed dump' User Mini Dump File: Only registers, stack and portions of memory are available <span style='color: blue; font-weight: bold'>Loading Dump File [D:\temp\procdump-reflected.dmp]</span> User Mini Dump File with Full Memory: Only application data is available Comment: ' *** procdump -r -ma reportingservicesservice.exe D:\temp\procdump.dmp *** Timed dump' </pre> <br /> .NET SOS 확장 dll 로드 및 여타 메모리 조사도 정상적으로 잘 동작합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 0:000> .load C:\Windows\Microsoft.NET\Framework64\v2.0.50727\sos.dll 0:041> !printexception Exception object: 000000008067dec0 Exception type: System.ArgumentException Message: The source '...' is not registered in log '...'. (It is registered in log '...'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property. InnerException: <none> StackTrace (generated): SP IP Function <span style='color: blue; font-weight: bold'>00000000152BCEC0</span> 00007FFADD466353 System!System.Diagnostics.EventLog.VerifyAndCreateSource(System.String, System.String)+0x313 00000000152BCF30 00007FFADD465BC1 System!System.Diagnostics.EventLog.WriteEntry(System.String, System.Diagnostics.EventLogEntryType, Int32, Int16, Byte[])+0x191 00000000152BCFD0 00007FFADDA75D3C System!System.Diagnostics.EventLog.WriteEntry(System.String, System.Diagnostics.EventLogEntryType, Int32)+0x1c 00000000152BD010 00007FFADDA75C42 TestLib!TestLib.Logger.LogEvent(System.Diagnostics.EventLogEntryType, TestLib.WindowEventLogId, System.String)+0x322 StackTraceString: <none> HResult: 80070057 0:041> <span style='color: blue; font-weight: bold'>dd 00000000152BCEC0</span> 00000000`152bcec0 1a5b61a0 00000000 007f0628 00000000 00000000`152bced0 fffffffe ffffffff 757fe648 00001871 00000000`152bcee0 00989680 00000000 000000c6 00000000 00000000`152bcef0 757fe648 00001871 152bcf48 00000000 00000000`152bcf00 80c90c30 00000000 dcc46a99 00007ffa 00000000`152bcf10 80c90b78 00000000 3c186d89 00007ffb 00000000`152bcf20 00000001 00000000 00000001 00000000" 00000000`152bcf30 00000000 00000000 3c18a092 00007ffb </pre> <br /> 이로써, 운영 서버에도 풀 덤프를 남겨달라고 부탁해도 크게 부담이 없게 되었습니다. (그래도, 부담스러워하는 고객이 있겠지만. ^^)<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1378
(왼쪽의 숫자를 입력해야 합니다.)