for example i get this memory:
int* p=new[100000];
i want to see the available memory befor and after it.
I want a function in c++ that returns available memory.?
For 32 bit Windows:
DWORD ramsize;
DWORD freesize;
MEMORYSTATUS lpBuffer;
lpBuffer.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(%26amp;lpBuffer);
ramsize = lpBuffer.dwTotalPhys;
freesize = lpBuffer.dwAvailPhys;
Reply:There is no such native function in c++; it depends on the OS. You need to look in the Linux or Windows documentation for a suitable function. BTW, even if such a function were available, you *might* not get the result you're looking for. Typically an OS might maintain a memory pool on a per-process basis to speed memory allocation. So you might find that the available memory is unchanged after your new[] call.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment