All Forums
 Microsoft Windows CE
 eVC Application Development
 CE memory management
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

ceuser

7 Posts

Posted - 29 May 2008 :  12:17:50  Show Profile  Email Poster
I'm trying to save a few bitmap images that are around 1Mb in size within CE4.2 , but am noticing that the code is using 1Mb of both "physical memory" and "virtual memory" when storing the bitmap. I'm not familiar with CE memory management, but why would this code be using 1Mb of both types of memory?

GlobalMemoryStatus((LPMEMORYSTATUS) &MemStats);

memdc=CreateCompatibleDC(selectedDC->m_hDC);
screenbitmap=CreateCompatibleBitmap( selectedDC->m_hDC ,WINDOW_X ,WINDOW_Y);

prevbitmap =(HBITMAP) SelectObject(memdc, screenbitmap );

BitBlt(memdc,0 ,0 ,WINDOW_X , WINDOW_Y ,selectedDC->m_hDC ,0 ,0,SRCCOPY);
SelectObject(memdc,prevbitmap);
DeleteDC(memdc);
::DeleteObject( prevbitmap);
GlobalMemoryStatus((LPMEMORYSTATUS) &MemStats);

beitman

63 Posts

Posted - 29 May 2008 :  12:43:50  Show Profile  Email Poster
Virtual addresses are a set of addresses that map to physical addresses. They are not memory locations. For that matter, physical addresses are not necessarily memory locations either; they could be register addresses on a chip.

In this case though, the app is using RAM. The app is loading a 1MB chunk of RAM with the bitmap. To do this, it must first allocate 1MB of physical RAM. But an application cannot access the physical addresses of that RAM. Instead, it must use virtual addresses that are mapped to the physical addresses in the Memory Management Unit (MMU). So both physical address to RAM and virtual addresses are allocated.

A common misunderstanding of this topic is the use of the word "memory" as in Virtual Memory. It just happens in this particular case that you are actually using memory (RAM), but in the general case that isn't always true.

Drivers usually access registers on a chip, like the UART for serial ports. In this case, the virtual addresses are used, but not the physical RAM addresses.
Go to Top of Page

ceuser

7 Posts

Posted - 29 May 2008 :  14:02:20  Show Profile  Email Poster
beitman thanks
Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.02 seconds. Snitz Forums 2000