This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] do not place remainders into fastbins
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Michal Schmidt <mschmidt at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 11 Jun 2013 07:19:28 +0200
- Subject: Re: [PATCH] do not place remainders into fastbins
- References: <1370534060-19946-1-git-send-email-mschmidt at redhat dot com>
On Thu, Jun 06, 2013 at 05:54:20PM +0200, Michal Schmidt wrote:
> While working with a program that reads many short strings using
> sscanf(..., "%ms", &s), I noticed it used more memory than I had
> expected. sscanf starts by allocating 100 bytes, and later
> reallocs to the exact size. It resulted in a heap layout like this:
> +-------+------------------+-------+------------------+-------+---
> |string1| free |string2| free |string3| ...
> +-------+------------------+-------+------------------+-------+---
>
> When testing with fastbins disabled (by setting M_MXFAST to 0),
> the resulting heap was nicely condensed instead (and obviously smaller).
>
What program is it? Is it deterministic? If so could you LD_PRELOAD
following library (or use libc with your fix)
__attribute__((constructor)) nofastbin(){
mallopt(M_MXFAST,0);
}
and use /usr/bin/time to see how much it decreased maximal and average
memory usage?