Memory related functions....

J

james

Your question is related to system level. you can not find any function in
standard C/C++. you need to search MEMORY API which are OS SDK provided. for
example: if your program is running at WIN32 platform:
//
MEMORYSTATUS m_mem;
::GlobalMemoryStatus(&m_mem);
//then derived as
DWORD GetPercentMemoryInUse(){return m_mem.dwMemoryLoad;};// percent of
memory in use
DWORD GetTotalPhys(){return m_mem.dwTotalPhys;};// bytes of physical memory
DWORD GetAvailPhys(){return m_mem.dwAvailPhys;};// free physical memory
bytes
DWORD GetTotalPageFile(){return m_mem.dwTotalPageFile;}; // bytes of
paging file
DWORD GetAvailPageFile(){return m_mem.dwAvailPageFile;}; // free bytes of
paging file
DWORD GetTotalVirtual(){return m_mem.dwTotalVirtual;}; // user bytes of
address space
DWORD GetAvailVirtual(){return m_mem.dwAvailVirtual;}; //free user bytes
CMem(LPMEMORYSTATUS &mem);
 
L

Lee Garrington

Hey there,

Is there a function that returns the amount of RAM free for memory
allocation?

Is there a function that will return the amount of memory your program
currently uses through memory allocation? If not, is there any simple way
of calculating this?

Thx in advance

Lee
 
N

Nick Hounsome

Lee Garrington said:
Hey there,

Is there a function that returns the amount of RAM free for memory
allocation?

Not in standard C++ and in general it is not possible since it will usually
vary dynamically according to factors
beyond your control - i.e. other programs.
Is there a function that will return the amount of memory your program
currently uses through memory allocation?

Not in standard C++ but there often is a way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top