Click here to Skip to main content
15,891,864 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: insert/add a GIF image in VC++ 6.0 Pin
tanvon malik12-Aug-06 21:16
tanvon malik12-Aug-06 21:16 
AnswerRe: insert/add a GIF image in VC++ 6.0 Pin
Hamid_RT13-Aug-06 9:45
Hamid_RT13-Aug-06 9:45 
GeneralRe: insert/add a GIF image in VC++ 6.0 Pin
Dhananjayak0214-Aug-06 4:51
Dhananjayak0214-Aug-06 4:51 
GeneralRe: insert/add a GIF image in VC++ 6.0 Pin
Hamid_RT14-Aug-06 7:38
Hamid_RT14-Aug-06 7:38 
QuestionVirtual memory allocation Pin
RomTibi12-Aug-06 6:02
RomTibi12-Aug-06 6:02 
AnswerRe: Virtual memory allocation Pin
tanvon malik12-Aug-06 6:31
tanvon malik12-Aug-06 6:31 
GeneralRe: Virtual memory allocation Pin
RomTibi12-Aug-06 9:04
RomTibi12-Aug-06 9:04 
AnswerRe: Virtual memory allocation Pin
Mike Dimmick13-Aug-06 5:43
Mike Dimmick13-Aug-06 5:43 
You probably don't want to do what you think you want to.

The operating system will use the page file to back any virtual memory allocation that doesn't come from a memory-mapped file. This is completely automatic - as demand for memory increases, and on a periodic basis to ensure that a reserve of physical memory is available, the operating system removes pages from your process's 'working set' - a process called 'trimming' - to return them to the available physical memory pool. If the page has been modified since last written to disk, the new contents will be written to the appropriate place in the page file.

The 'working set' is the set of pages that the OS thinks are most appropriate to be in memory for the process at the current time. When trimming, it removes the pages that have been used least recently. A phenomenon known as 'locality of reference' normally means that the pages used most recently are the most likely to be referenced next; a program that has poor locality of reference can lead to thrashing as the OS removes the least recently used page, the program then references it and the OS has to read it back in - page it in - from the page file.

To ensure that it can always write any given page without running out of space in the page file, the operating system reserves space in the page file for each virtual memory page allocated, at the time of the allocation. You don't need to do anything for this to happen.

The VirtualAlloc function only allows you to make page-sized allocations (4KB on x86), and then only from 64KB-sized address space reservations. Using VirtualAlloc badly will waste your virtual address space. Only use it if you really know what you're doing. For most normal programming, you should use a heap, allocating with new, malloc, LocalAlloc or HeapAlloc. A heap is simply a data structure that manages a block of virtual memory, and the Heap Manager has the ability to deal with virtually any size block quite well. This flexibility does mean that it can be slower than a specialised implementation handling allocation for specific data structures, but in general it's a good choice.

Stability. What an interesting concept. -- Chris Maunder

GeneralRe: Virtual memory allocation Pin
RomTibi13-Aug-06 8:01
RomTibi13-Aug-06 8:01 
Questionlinked list Pin
jon-8012-Aug-06 5:29
professionaljon-8012-Aug-06 5:29 
AnswerRe: linked list Pin
Chris Losinger12-Aug-06 5:42
professionalChris Losinger12-Aug-06 5:42 
QuestionHow to control the behaviour of a toolbar button? Pin
Vinod Sankaranarayanan12-Aug-06 1:52
Vinod Sankaranarayanan12-Aug-06 1:52 
AnswerRe: How to control the behaviour of a toolbar button? Pin
Monty212-Aug-06 2:20
Monty212-Aug-06 2:20 
GeneralRe: How to control the behaviour of a toolbar button? Pin
Vinod Sankaranarayanan12-Aug-06 3:55
Vinod Sankaranarayanan12-Aug-06 3:55 
AnswerRe: How to control the behaviour of a toolbar button? Pin
ovidiucucu12-Aug-06 4:23
ovidiucucu12-Aug-06 4:23 
GeneralRe: How to control the behaviour of a toolbar button? Pin
Vinod Sankaranarayanan12-Aug-06 5:44
Vinod Sankaranarayanan12-Aug-06 5:44 
GeneralRe: How to control the behaviour of a toolbar button? [modified] Pin
ovidiucucu13-Aug-06 1:54
ovidiucucu13-Aug-06 1:54 
AnswerRe: How to control the behaviour of a toolbar button? Pin
Hamid_RT14-Aug-06 7:09
Hamid_RT14-Aug-06 7:09 
QuestionHost ActiveX control and draw to memory context? Pin
Andrew Altham12-Aug-06 0:22
Andrew Altham12-Aug-06 0:22 
AnswerRe: Host ActiveX control and draw to memory context? Pin
bob1697212-Aug-06 6:45
bob1697212-Aug-06 6:45 
QuestionRe: Host ActiveX control and draw to memory context? Pin
Andrew Altham12-Aug-06 23:08
Andrew Altham12-Aug-06 23:08 
AnswerRe: Host ActiveX control and draw to memory context? Pin
bob1697213-Aug-06 11:51
bob1697213-Aug-06 11:51 
Questionhooks work only for own application Pin
_tasleem11-Aug-06 23:58
_tasleem11-Aug-06 23:58 
AnswerRe: hooks work only for own application Pin
Naveen12-Aug-06 0:43
Naveen12-Aug-06 0:43 
GeneralRe: hooks work only for own application Pin
_tasleem12-Aug-06 2:15
_tasleem12-Aug-06 2:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.