Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Mar 2013 09:57:01 -0400
From:      Eitan Adler <lists@eitanadler.com>
To:        Rod Person <rodperson@rodperson.com>
Cc:        Lowell Gilbert <freebsd-lists@be-well.ilk.org>, freebsd-hackers@freebsd.org
Subject:   Re: Help porting Linux app - getting Free Memory and Real Memory
Message-ID:  <CAF6rxgmatTZ5ptymb=qkc29gsmJPYGFYitvdu9tGhDTH_XToeg@mail.gmail.com>
In-Reply-To: <51559451.9050708@rodperson.com>
References:  <5156316F.9050202@rodperson.com> <20130329032845.GG81066@server.rulingia.com> <44li962xmp.fsf@lowell-desk.lan> <51559451.9050708@rodperson.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 29 March 2013 09:17, Rod Person <rodperson@rodperson.com> wrote:
> On 03/29/13 08:34, Lowell Gilbert wrote:
>> Peter Jeremy <peter@rulingia.com> writes:
>>
>>> 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.
>> To be more blunt, these checks may well be useless on Linux.
>> On a quick look, you seem to maintain three ports: idutils, mspdebug,
>> and jogl. I wouldn't expect a free-memory check to be appropriate on any
>> of those.
> Really?  The port in question if graphics/fotoxx. I have no involvement
> in the others. For the latter two, I'm not even sure what they are.
>
>> In any case, the definition of "free memory" is different between the VM
>> systems in Linux and BSD . Even if the checks do make sense, the FreeBSD
>> implementation would at the minimum have to include all of the pages
>> that are allocated but not mapped.
> Yes I have read this. Fotoxx uses free memory calculation when applying
> effects to images.  It looks at the image size then calculates how much
> memory it needs to apply an effect, such as image sharpening. For
> example, on a 4.5MB jpg file it seems to calculate that 40MB of free
> memory is need to apply sharpening to the image.  40MB doesn't seem like
> a lot of memory to me, but since the application way of figuring free
> memory is Linux specific the warning dialog appear, although it seem to
> have no ill effect on actually applying the sharpening effect.

This is also racy and wrong.  The application has the memory free (I
doubt it allocates 2^32 = bytes of space).  What happens if I start
1000 of this programs at the same time, the each check the free memory
at the same time, find it to be sufficient, allocate memory, and it
now becomes insufficient according to the program?

The application should trust the operating system to manage this
correctly unless it has *very* good reason not to (for instance,
database programs often perform their own swapping/paging).

My suggestion if you are to patch this program at all is to remove the
check entirely and submit this upstream.

-- 
Eitan Adler



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