Memory Analysis
-
I am not sure if there is a single function call that can give an answer to your question. This would have been a simple question before the advent of virtual memory, but that is no longer the case. If you want to know the physical memory available then you may have to experitment, but that limits you to the machine you are on. Write your programm in such a way that it can compensate for the lack of phisycal memory, or can inform the user if it can not. I am just saying that we no longer know the amount of memery available and you have to make sure that if it is not, your progam catches that problem before it crashes some bodies machine. INTP Every thing is relative...
-
I am not sure if there is a single function call that can give an answer to your question. This would have been a simple question before the advent of virtual memory, but that is no longer the case. If you want to know the physical memory available then you may have to experitment, but that limits you to the machine you are on. Write your programm in such a way that it can compensate for the lack of phisycal memory, or can inform the user if it can not. I am just saying that we no longer know the amount of memery available and you have to make sure that if it is not, your progam catches that problem before it crashes some bodies machine. INTP Every thing is relative...
Thanks John, it´s clear that new returns 0 if allocation failed. I´m just looking for a way of checking available memory before and after such operations. Due to the dynamic memory model in windows it may be impossible to get exact required data. Purpose is not implemeting it in a commercial application but memory usage demonstration to students. In DOS times ( a century ago ) ;) we had a similar function.
-
Have a look at the
GlobalMemoryStatus()
function.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
I doubt it, since freed memory does not automatically go right back to the pool of available memory. Windows' memory manager is a very complex beast.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb