Thread: Allocate more than 2GB?

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    519

    Allocate more than 2GB?

    Hi,

    I tried this code to test how much memory a process is able to allocate:

    Code:
    		size_t mem = 0;
    		while(1)
    		{
    			try
    			{
    				new(double);
    				mem += sizeof(double);
    			}
    			catch(std::bad_alloc&)
    			{
    				printf("bad_alloc\n");
    				printf("mem: %u    ram (MB) %u\n",mem, mem / (1024*1024));
    				_getch();
    				return 0;
    				
    			}
    
    			if ( !(mem % (1024*1024))) )
    			{
    				printf("mem: %u    ram (MB) %u\n",mem, mem / (1024*1024));
    
    			}
    		}
    On a standard winXP installation I get 2GB of virtual memory.

    Than I added this switch
    Code:
    /3GB /USERVA=2990
    to my boot.ini in the hope of improvement. But I still get only 2GB.

    Any ideas?

    Thank you!

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    4-Gigabyte Tuning
    Read all of it.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    Thanks, it worked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Promblem with code
    By watchdogger in forum C Programming
    Replies: 18
    Last Post: 01-31-2009, 06:36 PM
  2. Why can't you allocate a 2D array like this?
    By rudyman in forum C++ Programming
    Replies: 7
    Last Post: 07-22-2008, 01:47 PM
  3. When to Allocate or Not to Allocate
    By Eber Kain in forum C++ Programming
    Replies: 5
    Last Post: 11-13-2005, 11:32 PM
  4. when to allocate memory
    By SAMSAM in forum Windows Programming
    Replies: 3
    Last Post: 01-22-2003, 11:40 PM