Windows 7 What's wrong with PAGE_NOCACHE in VirtualAlloc/VirtualFree

Discussion in 'Virtualization' started by erwin, Nov 23, 2009.

  1. erwin

    erwin Well-Known Member

    Joined:
    Nov 23, 2009
    Messages:
    2
    Likes Received:
    0
    Hi, I have this code:

    Code:
    // AllocTest.cpp : Defines the entry point for the console application.
    //
    #include <windows.h>
    #include <stdio.h>
    
    int main(int argc, char * argv[])
    {    
      if ( ! SetProcessWorkingSetSize( GetCurrentProcess(), 1024 * 1024 * 1024 * 1.2,  1024 * 1024 * 1024 * 1.2 ) ) {
        return -1;
      }
    
      void * buffer = VirtualAlloc( NULL,  1024 * 1024 * 1024, MEM_COMMIT, PAGE_READWRITE | [COLOR=Red]PAGE_NOCACHE[/COLOR] );
      memset( buffer, 1,  1024 * 1024 * 1024 );
    
      getchar();
    
      VirtualFree( buffer, 0, MEM_RELEASE );
    
      return 0;
    }
    
    On VirtualFree() there is - with the PAGE_NOCACHE option in VirtualAlloc - a heavy cpu-load over more than 10 sec.
    Without this option there is only a short peak in the performance graph. But under XP there is no such behaviour.
     

Share This Page

Loading...