Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jan 2008 05:26:47 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Igor Mozolevsky <igor@hybrid-lab.co.uk>
Cc:        Dag-Erling Sm?rgrav <des@des.no>, freebsd-current@freebsd.org, Robert Watson <rwatson@freebsd.org>, Jason Evans <jasone@freebsd.org>
Subject:   Re: sbrk(2) broken
Message-ID:  <20080105032647.GA46843@kobe.laptop>
In-Reply-To: <a2b6592c0801040318s9986f10u40cf725bc96304c6@mail.gmail.com>
References:  <477C82F0.5060809@freebsd.org> <863ateemw2.fsf@ds4.des.no> <20080104002002.L30578@fledge.watson.org> <a2b6592c0801040241l598ea9b7h57ad6889a1eccd3@mail.gmail.com> <86bq81c12d.fsf@ds4.des.no> <a2b6592c0801040318s9986f10u40cf725bc96304c6@mail.gmail.com>

index | next in thread | previous in thread | raw e-mail

On 2008-01-04 11:18, Igor Mozolevsky <igor@hybrid-lab.co.uk> wrote:
> On 04/01/2008, Dag-Erling Sm?rgrav <des@des.no> wrote:
> > Of course, if you're afraid of memory overcommit and you know in advance
> > how much memory you need, you can simply allocate a sufficient amount of
> > address space at startup and touch it all.  This way, you will either be
> > killed right away, or be guaranteed to have sufficient memory for the
> > rest of your (process) lifetime.  Alternatively, do what Varnish does:
> > create a large file, mmap it, and allocate everything you need from that
> > area, so you have your own private swap space.  Just make sure to
> > actually allocate the disk space you need (by filling the file with
> > zeroes, or at the minimum writing a zero to the file every sb.st_blksize
> > bytes, preferably sequentially to avoid excessive fragmentation)
>
> Surely you can just fseek() on the file at the correct lenght?

That would create a nicely sized 'hole' in the starting blocks.  What
Dag-Erling describes is the correct(TM) way of making sure that all
blocks have been allocated from the backing store of the file.



home | help

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