Overview
Features
Download
Documentation
Community
Add-Ons & Services

Determine free memory

A general discussion forum.

Determine free memory

Postby electic » 08 Sep 2010, 02:11

How would you use Poco to determine how much memory is free (phsyical ram) in the system?
electic
 
Posts: 48
Joined: 30 Jan 2007, 20:28

Re: Determine free memory

Postby guenter » 10 Sep 2010, 07:56

There's no feature to do that in POCO. On Linux, you could read /proc/meminfo. On Windows, you can call GlobalMemoryStatusEx(). On OS X, there's the host_statistics() call described in Mac OS X Internals, but it's only for virtual memory. For other platforms, I don't know.
guenter
 
Posts: 1105
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Determine free memory

Postby aderouineau » 12 Sep 2010, 13:55

/proc/meminfo is not accurate because of shared memory.
aderouineau
 
Posts: 163
Joined: 18 May 2009, 17:38

Re: Determine free memory

Postby guenter » 15 Sep 2010, 10:26

Well, there's generally no reliable way to find out the amount of free memory (virtual or physical) on virtual memory, multitasking operating systems. The same moment that a certain amount of free memory is reported to your process, another process might use up all that memory. Shared memory is only a small part of the problem here.
guenter
 
Posts: 1105
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Determine free memory

Postby marlowabnp » 15 Dec 2010, 00:33

I use a library called SIGAR for this. SIGAR stands for System Information Gathering and Reporting. It comes with many language bindings. I build the java one but actually use the C library that comes out of the java build. The java uses the C library which is called via JNI. There is no C++ library but the C interface is ok.

Regards,

Andrew Marlow
marlowabnp
 
Posts: 80
Joined: 08 Nov 2010, 17:29


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest