Re: check if the memory is low, from Windows to Unix



kevin.heart@xxxxxxxxx wrote:

How to implement such function for Linux/Unix?

/* sample begins*/
#include "windows.h"

No such file in standard C.

...
MEMORYSTATUS stat;

No such macro or type has been defined.

GlobalMemoryStatus(&stat);
result = ((float)stat.dwAvailPageFile / stat.dwTotalPageFile) < 0.1;

undefined struct or union 'stat'. No such fields.

...

if (result)
trigger_low_mem_info();

Undefined function.


...
/* sample ends */

You neglected to include a description of 'such function'.
Assuming you meant to include the subject line in the message, you
find the memory is low when malloc (or calloc, or realloc) returns
NULL.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>


.