"Dima" <di**@inotech.r u> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
How can I know size of avaible memory in heap?
For example :
...
...
// size = N
cout << "Size of Heap = " << SizeOfHeap() << endl;
int* i = new int;
// size = N - sizeof(int)
cout << "Size of Heap = " << SizeOfHeap() << endl;
...
...
SizeOfHeap() == ???
One solution to this problem I saw, but I didn't like, just
did malloc with huge amounts and determined when it
failed.
Basically you probably really want to determine if you have
enough heap to do something. If you think you'll need 10
megs of heap you could try allocating 10 megs of memory
in a malloc (remembering to release it if successful) and
check to see if it allowed it.
There is probably a better solution, but I believe it's OS
dependant.