Possible Duplicate:
maximum memory which malloc can allocate!
How can I know the maximum size of the heap I can occupy by malloc().
I use MS Visual Studio 2010.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are operating system-dependent ways of finding out how much virtual memory is available for your process, but I do not know how to do this on windows. You can, however, find it out by doing a hunt+halving search, caling malloc with ever larger arguments until it fails, and then homing in on the value it balks at. Something like
By this point you know that i/2 bytes is ok, while i bytes is not ok. Now do a bisection search for the actual maximum:
At this point,
ais the largest amount you can successfully allocate.