Is there a way to programatically determine that the system is running
short of memory?
I’m working on a non paging system that runs a number of tasks. I’d like
to get notified when the system is down to x% free memory (or x MB). At
this point I could then kill off some of my lower priority tasks to free up
memory and prevent the higher priority tasks from running out of memory.
I’ve been through the Neutrino docs and don’t see a good way to do this.
Anyone have any suggestions?
Bill Tracey, IBM Austin.
There’s no system notification, but you could run a periodic poll
of available memory.
Here’s some code that will give you the % of free memory…
#include <stdio.h>
#include <sys/neutrino.h>
#include <sys/syspage.h>
#include <sys/stat.h>
#include <unistd.h>
short get_freemem( void )
{
struct stat sbuf;
paddr_t freemem;
float percent;
stat( “/proc”, &sbuf );
freemem = (paddr_t)sbuf.st_size;
percent = (float)freemem/(float)SYSPAGE_ENTRY(system_private)->ramsize;
percent *= 100;
return (short)percent;
}
Bill Tracey <wtracey@us.ibm.com> wrote:
Is there a way to programatically determine that the system is running
short of memory?
I’m working on a non paging system that runs a number of tasks. I’d like
to get notified when the system is down to x% free memory (or x MB). At
this point I could then kill off some of my lower priority tasks to free up
memory and prevent the higher priority tasks from running out of memory.
I’ve been through the Neutrino docs and don’t see a good way to do this.
Anyone have any suggestions?
Bill Tracey, IBM Austin.
–
cburgess@qnx.com
Thanks for the reply and code for seeing how much memory is available.
Was really hoping there’d be a way to get a notification – polling in general
will not work if a process goes to grab lots of memory quickly - which is
certainly possible in the environment I’m looking at.
Bill Tracey, IBM Austin.
Bill Tracey <wtracey@us.ibm.com> wrote:
Thanks for the reply and code for seeing how much memory is available.
Was really hoping there’d be a way to get a notification – polling in general
will not work if a process goes to grab lots of memory quickly - which is
certainly possible in the environment I’m looking at.
Suggestion noted…
–
cburgess@qnx.com