bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xalloc.h (x2nrealloc): Don't always double the buffer size.


From: Andi Kleen
Subject: Re: xalloc.h (x2nrealloc): Don't always double the buffer size.
Date: Fri, 2 Feb 2007 08:21:04 +0100
User-agent: KMail/1.9.5

On Friday 02 February 2007 00:52, Jim Meyering wrote:

> The length of the string being searched matters.  More precisely,
> it's the offsets (into the buffer being searched) of the beginning
> and end of the match.

I see.

> I've just changed xalloc's x2nrealloc to do n = 3n/2, rather than n *= 2,
> and with that change, the above invocation of "nl" completed:

For allocating memory that big it would be far better to just use mmap()
with the full range and let the kernel serve you freshly zeroed memory 
on demand as you touch it.

If there are a lot of such allocations there might be an issue with 
the available virtual space on 32bit hosts, but on anything 64bit
it should work fine.

-Andi




reply via email to

[Prev in Thread] Current Thread [Next in Thread]