?
Solved

questions about limits of memory allocation

Posted on 2007-07-26
5
Medium Priority
?
174 Views
Last Modified: 2010-04-01
Hi,
I'm running on windows XP.

Say my computer has 1GB of memory. What happens if my process tries allocating more than that. Will new fail? Will the machine try using the hard drive as memory somehow? Will the machine crash? If the system starts using the hard disk as virtual memory of some sort, at what point does that get exhausted?

Thanks
0
Comment
Question by:DJ_AM_Juicebox
  • 4
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 19575773
What happens is that the request will still succeed, yet the pages that make up that memory > 1GB (minus the kernel) will be allocated from the swap file. The theoretical limit is 2GB, which is the part that Windows reserves as the application address space.
0
 
LVL 86

Expert Comment

by:jkr
ID: 19575788
See also http://support.microsoft.com/kb/555223 ("RAM, Virtual Memory, Pagefile and all that stuff")
0
 
LVL 86

Expert Comment

by:jkr
ID: 19576179
>>If the system starts using the hard disk as virtual memory of some sort, at
>>what point does that get exhausted?

That actually is irrelevant due to the maximum address space of a little less than 2GB (it actually is around 2147348479 bytes) - your swap file is certainly larger than that. BTW, to handle these situations correctly, you might want to install a handler routine, see http://msdn2.microsoft.com/en-us/library/a45x8asx(VS.80).aspx ("_set_new_handler") and the accompanying sample code.
0
 

Author Comment

by:DJ_AM_Juicebox
ID: 19576502
Hi jkr,

I still don't understand what happens if I just sit there and keep requesting memory, say something ridiculous, to like 100gb. To my application, it will just seem as the requests keep succeeding right? But to the user, it will seem as if the application is running really slowly since it will somehow be swapping my data from disk to memory, or something to that effect? How does that work in general?
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 19576545
You cannot request more than 2147348479 bytes total (a little less than 2GB) per process on a 32bit machine (on 64bit machines, that's different). Once that amount is exhausted (actually a lot earlier, since all the code your app uses has to reside within these 2GB also), all allocation requests will fail.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question