-
March 11th, 2010, 02:28 AM
#1
How to find the free memory on windows
Hi all,
I am using new operator to allocate the memory
and I want to use maximum free memory for my
program without deleting previously allocated memory.
After allocating some memory new throws
bad_alloc exception for insufficient memory
now I want to avoid this exception.
So before allocating memory I have to check amount
of free memory. I am using GlobalMemoryStatus to get
the current free memory.
new is throwing exception still GlobalMemoryStatus shows
sufficient free memory which is more than I am trying to allocate.
I am using Visual Studio 2005 for development .
Is there any other way to check correct free memory..?
Please help me..
-
March 11th, 2010, 01:00 PM
#2
Re: How to find the free memory on windows
Originally Posted by iamvish
Is there any other way to check correct free memory..?
Yes, and you are doing it - just use "new" to get what you want; if it fails - adjust your logic.
What's wrong with getting bad_alloc?
You need to know if you can allocate N bytes of memory, NOT if there is that much free memory (it can be fragmented).
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
March 12th, 2010, 04:43 PM
#3
Re: How to find the free memory on windows
Besides, though it seems off the topic, I'd recommend to review your memory allocation/deallocation design. Only once I ran into the memory insufficiency, for all these years.
Best regards,
Igor
-
March 15th, 2010, 09:48 AM
#4
Re: How to find the free memory on windows
There is a difference between the amount of free memory for the whole computer, and the amount of free memory for a process.
Are you using a 32-bit version of Windows and do you want to allocate more than 2GB of memory?
See "Memory Limits for Windows Releases" at http://msdn.microsoft.com/en-us/libr...78(VS.85).aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|