This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] do not place remainders into fastbins


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]