Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Mar 2013 09:07:52 -0400
From:      Rod Person <rodperson@rodperson.com>
To:        Peter Jeremy <peter@rulingia.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Help porting Linux app - getting Free Memory and Real Memory
Message-ID:  <51559228.5020302@rodperson.com>
In-Reply-To: <20130329032845.GG81066@server.rulingia.com>
References:  <5156316F.9050202@rodperson.com> <20130329032845.GG81066@server.rulingia.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 03/28/13 23:28, Peter Jeremy wrote:
> On 2013-Mar-29 20:27:27 -0400, Rod Person <rodperson@rodperson.com> wrote:
>> Everything is going we except that the program gives warnings that there
>> isn't enough free memory on the system to perform certain actions.
> That premise sounds suspiciously like the upstream author doesn't
> understand how Unix VM works.

First, thanks for you reply.  I can't speak to this and only say that he
read the Linux proc system for the Free Memory and Cache memory values.
Adds them together and that become the value used for free memory.  My
little hack does seem to stop these warning though. I just want to make
sure it correct in thinking and if possible use some standard way of
calculating these values.

>> int getSysCtl(int top_level, int next_level){
>>    int mib[2], ctlvalue;
>>    size_t len;
>>
>>    mib[0] = top_level;
>>    mib[1] = next_level;
>>    len = sizeof(ctlvalue);
>>
>>    sysctl(mib, 2, &ctlvalue, &len, NULL, 0);   
>>   
>>    return ctlvalue;
>> }
>>
>>
>> int main(void){
>>    int realmem = getSysCtl(CTL_HW, HW_REALMEM);
>>    int usermem = getSysCtl(CTL_HW, HW_USERMEM);
> HW_REALMEM and HW_USERMEM return an unsigned long, not an int.  That
> probably explains the nonsense value you are seeing in 'User Memory'.

 man 3 sysctl, list them as integer that is why I did this.


Rod



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51559228.5020302>