questions about limits of memory allocation

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?

Who is Participating?
jkrConnect With a Mentor Commented:
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.
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.
See also ("RAM, Virtual Memory, Pagefile and all that stuff")
>>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 ("_set_new_handler") and the accompanying sample code.
DJ_AM_JuiceboxAuthor Commented:
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?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.