Windows Mobile 6.5 프로세스 및 메모리 관리 최적화<br />WEEG Manager <br />andro78@naver.com<br />
URL : http://cafe.naver.com/wincepro<br />Since : 2006. 4. 23<br />Members : about 20,000<br />Staff : about 15<br />Manag...
Windows CE 5.0 Memory Model<br /><ul><li>Virtual Memory Map
 2GB 커널영역
 2GB의 모든 Processes들의 영역
각 Slot당 32MB
32개 Process 제한
 유저 영역의 상위 절반 (1GB)
 Process에 의해 읽기/쓰기
공유 메모리(Shared memory)
 유저 영역의 상위 절반 (1GB)
 Process에 의해 읽기/쓰기
가상메모리 관리 단위
 64KB alignment</li></li></ul><li>Windows CE 5.0 Memory Model<br />Kernel<br />2 GBKernelSpace<br />Shared Memory<br />Sin...
Application Memory Map<br />5<br />COREDLL.DLL<br />03FF FFFF<br />DLL Space (Constant for all applications)<br />: 프로세스의 ...
문제점과 원인<br /><ul><li>증상
 RAM에 있는 DLL, Driver는 load/unload하면서 실패
시스템은 RAM이 비어 있다고 reporting
그러나! 메모리 할당 불가
원인
 가상 메모리 쪼개짐
가상 메모리 영역을 벗어남</li></li></ul><li>VM Exhaustion<br /><ul><li> App1 DLL A 로드
App2 실행
 App1 DLL B 로드 + more Heap
 App2 DLL Z 로드
 App2 DLL X 로드
Upcoming SlideShare
Loading in …5
×

Windows Mobile 6.5 메모리관리

3,899 views

Published on

Windows Mobile 6.5 메모리 관리

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,899
On SlideShare
0
From Embeds
0
Number of Embeds
762
Actions
Shares
0
Downloads
25
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Windows Mobile 6.5 메모리관리

  1. 1. Windows Mobile 6.5 프로세스 및 메모리 관리 최적화<br />WEEG Manager <br />andro78@naver.com<br />
  2. 2. URL : http://cafe.naver.com/wincepro<br />Since : 2006. 4. 23<br />Members : about 20,000<br />Staff : about 15<br />Manager : andro78@naver.com<br />Contents : <br />- Windows Embedded CE<br />- Windows Mobile<br />
  3. 3. Windows CE 5.0 Memory Model<br /><ul><li>Virtual Memory Map
  4. 4. 2GB 커널영역
  5. 5. 2GB의 모든 Processes들의 영역
  6. 6. 각 Slot당 32MB
  7. 7. 32개 Process 제한
  8. 8. 유저 영역의 상위 절반 (1GB)
  9. 9. Process에 의해 읽기/쓰기
  10. 10. 공유 메모리(Shared memory)
  11. 11. 유저 영역의 상위 절반 (1GB)
  12. 12. Process에 의해 읽기/쓰기
  13. 13. 가상메모리 관리 단위
  14. 14. 64KB alignment</li></li></ul><li>Windows CE 5.0 Memory Model<br />Kernel<br />2 GBKernelSpace<br />Shared Memory<br />Single2 GB VMfor allProcesses<br />Slot 32<br />Slot 31<br />::<br />32 Slots for Processes<br />Slot 7<br />Slot 7 – Services.exe<br />Slot 5 – GWES.exe<br />Slot 4 – Device.exe<br />Execution Slot and Shared DLL Slot<br />Slot 3 – Filesys.exe<br />Slot 2 – NK.exe<br />Slot 1 – ROM DLLs<br />Slot 0 – Execution<br />
  15. 15. Application Memory Map<br />5<br />COREDLL.DLL<br />03FF FFFF<br />DLL Space (Constant for all applications)<br />: 프로세스의 보관 영역<br />Other ROM DLLs<br />ROM DLL space<br />0200 0000<br />RAM based DLLs<br />Application Specific Space<br />: 프로세스의 실행 영역<br />Free virtual space<br />Stack (reserved space) <br />Heap (reserved space)<br />Resources<br />Read write data<br />Read only data<br />Code<br />0001 0000<br />0000 0000<br />reserved<br />
  16. 16. 문제점과 원인<br /><ul><li>증상
  17. 17. RAM에 있는 DLL, Driver는 load/unload하면서 실패
  18. 18. 시스템은 RAM이 비어 있다고 reporting
  19. 19. 그러나! 메모리 할당 불가
  20. 20. 원인
  21. 21. 가상 메모리 쪼개짐
  22. 22. 가상 메모리 영역을 벗어남</li></li></ul><li>VM Exhaustion<br /><ul><li> App1 DLL A 로드
  23. 23. App2 실행
  24. 24. App1 DLL B 로드 + more Heap
  25. 25. App2 DLL Z 로드
  26. 26. App2 DLL X 로드
  27. 27. App1 DLL C 로드 실패!</li></ul>Slot 0 <br />System DLLs<br />Slot 0 <br />System DLLs<br />DLL A<br />DLL A<br />DLL B<br />DLL B<br />DLL Z<br />DLL Z<br />DLL X<br />DLL X<br />2nd Heap<br />DLL C<br />Thread 2<br />Process Heap<br />Process Heap<br />Main Thread<br />Main Thread<br />APP 2<br />APP 1<br />Reserved<br />Reserved<br />
  28. 28. 효과적인 방법<br /><ul><li> DLL을 FILES SECTION 또는 STORAGE에 위치
  29. 29. 클라이언트/플러그인 드라이버
  30. 30. PCMCIA
  31. 31. USB
  32. 32. SDIO
  33. 33. Bluetooth
  34. 34. etc…
  35. 35. 어플리케이션이 DLL실행</li></li></ul><li>효과적인 방법<br /><ul><li> DLL을 FILES SECTION 또는 STORAGE에 위치
  36. 36. 클라이언트/플러그인 드라이버
  37. 37. PCMCIA
  38. 38. USB
  39. 39. SDIO
  40. 40. Bluetooth
  41. 41. etc…
  42. 42. 어플리케이션이 DLL실행</li></li></ul><li>Windows Mobile 6<br />10<br />FILE DLLs are loaded into every slot which decreases VM space to all slots<br />2 GB :: User Space<br />Slot 63 :: Resource-Only DLLs<br />MODULE DLLs are 4K page-aligned instead of 64K due to ARM architecture saving 9MB of VM<br />Slot 62 :: Shared Heaps<br />Slots 33-61<br />1 GB Large Memory Area<br />Memory-Mapped Files<br />Slots 2-32 :: Application Processes<br />Slot 1 :: ROM FILE DLLs + MODULE DLLs<br />DLL Overflow Causes Instability<br />Slot 0 :: Alias of Active Process from Other Slots<br />Overflow DLLs Reduce VM Space for All Processes<br />
  43. 43. Windows Mobile 6.1 <br />11<br />2 GB :: User Space<br />Slot 63 :: Resource-Only DLLs<br />DLLs used exclusively by one process don’t take space from other processes<br />Extra 64 MB of VM<br />Slot 62 :: Shared Heap Area<br />Slot 61 :: Read-Only FILE DLLs<br />Slot 60 :: Read-Only FILE DLLs<br />Slot 59 :: Device.exe Thread Stacks<br />Slots 33-58 :: Large Memory Area<br />Memory-Mapped Files<br />Extra 8 MB of VM for Device Drivers<br />Slots 2-32 :: Application Processes<br />Slot 1 :: ROM FILE DLLs + MODULE DLLs<br />Convert mshtml.dll to FILE DLL to free 6 MB of VM<br />Slot 0 :: Alias of Active Process from Other Slots<br />Overflow DLLs Reduce VM Space for All Processes<br />
  44. 44. Windows Mobile 6.5<br />2 GB :: User Space<br />Slot 63 :: Resource-Only DLLs<br />Slot 62 :: Shared Heaps<br />Faster MODULE DLLs whose VM is allocated at build time instead of runtime can go everywhere!<br />Slot 61 :: FILE + MODULE DLLs<br />Slot 60 :: FILE + MODULE DLLs<br />Slot 59 :: Device.exe Thread Stacks<br />Slots 33-58 :: Large Memory Area<br />Memory-Mapped Files<br />Process Threshold of 28<br />Slots 2-32 :: Application Processes<br />Slot 1 :: ROM FILE DLLs + MODULE DLLs<br />Slot 0 :: Alias of Active Process from Other Slots<br />Overflow DLLs Reduce VM Space for All Processes<br />
  45. 45. Windows Mobile 6.5Faster Performance<br />JPEG images decode faster by aligning buffer size to 128-byte boundary needed by hardware<br />Glyph Cache jumps from 8KB to 72KB for English and 128KB for Asian builds to boost font rendering speed<br />GDI used to draw text one character at a time; now draws the entire string in one shot<br />Switching Today screens and backgrounds repeatedly does not degrade device performance<br />Paging Pool is set to a minimum of 15 MB to boost application load performance<br />Minimum devices specs include a 400 MHz processor, 128 MB of RAM and 256 MB of ROM<br />
  46. 46. Application Verifier<br />응용프로그램의 안정성 평가 Tool<br />개발 중 실수 할 수 있는 Leak을 감지<br />Memory Leaks<br />Handle Leaks<br />GDI Leaks<br />응용프로그램은 물론 드라이버도 가능<br /><ul><li>http://www.microsoft.com/downloads/details.aspx?FamilyId=D275348A-D937-4D88-AE25-28702C78748D&displaylang=en</li></ul>14<br />
  47. 47. Application Leak(1)<br />AppVerifer실행<br />15<br />
  48. 48. Application Leak(2)<br />AppVerifer 클릭 “Connect…”<br />Device Connection Windows 클릭 “Settings…”<br />16<br />
  49. 49. Application Leak(3)<br />CE Platform Manager <br />클릭 “Add Device”<br />이름을 변경<br />Properties<br />17<br />
  50. 50. Application Leak(4)<br />Device Properties에서<br />CESH Server… <br />“OK”<br />18<br />
  51. 51. Application Leak(5)<br />Device Connection에서<br />클릭 “Connect…”<br />KITL을 선택 “OK”<br />19<br />
  52. 52. Application Leak(6)<br />AppVerifer “Add…”<br />Add Application  LeakApp.exe  “Open”<br />20<br />
  53. 53. Application Leak(7)<br />AppVerifer에서<br />“LeakApp.exe” <br />“Heap Verifier” 체크<br />“Run”<br />21<br />
  54. 54. Application Leak(8)<br />LeakApp에서<br />Leak  Memory<br />“Exit”<br />22<br />
  55. 55. Application Leak(9)<br />AppVerifer<br />“Get Logs…”<br />“View Exported Log…”<br />“Open”<br />23<br />
  56. 56. Application Leak(10)<br />Exported Log<br />“Potention Leak: 3 items (3072 bytes)…”<br />메모리 누수가 생긴 부분의 API나 함수 노출<br />24<br />
  57. 57. Application Leak(11)<br />Source Code<br />25<br />void Create_MemoryLeak( HWND hWnd )<br />{<br />MessageBox(hWnd, <br /> _T(&quot;Create 1 KB (1024 bytes) memory leak&quot;), <br /> _T(&quot;Leak App&quot;),<br /> MB_OK);<br /> // <br /> LPBYTE p = (LPBYTE)LocalAlloc(LPTR, 1024);<br /> //<br />//LocalFree((HLOCAL)p);<br />}<br />
  58. 58. 26<br />Question?<br />

×