Re: madvise(MADV_FREE) doesn't work in some cases?

From: Vitaliy Gusev <gusev.vitaliy_at_gmail.com>
Date: Mon, 12 Jul 2021 11:55:37 UTC
Thanks for response,

> On 10 Jul 2021, at 16:54, Konstantin Belousov <kostikbel@gmail.com> wrote:
> 
>> 
>> After testing it looks that backing_object is not null here, memory is not freed and mmapfork test program is still killed. Any ideas?
>> 
> I finally looked at this thing again.  You do madvise(PAGE_SIZE).  With
> my patch (updated version below) issue madvise() for the whole region
> once.

I guess madvise() should work well even with PAGE_SIZE granularity. Usually a caller doesn’t need to free the whole region. As I reported earlier madvise(PAGE_SIZE) works well in Linux and illumos. 

Current behaviour in FreeBSD can confuse programmers and brings impossibility to effectively give back unused memory. Also I have another case with madvise() but with shared memory that also doesn’t work (but works in Linux and illumos), will report it in new thread.

———
Vitaliy Gusev