This is the mail archive of the libc-help@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: Huge chunks of anonymous memory


Hi,

Yea I tried that and MMAP_MAX_ stuff too,
those anonymous allocations I dont think were done
through mmap or malloc coz I tried running strace and I also
did gdb debugging with breakpoints on mmap and malloc.

I could see around 25 Mb being allocated in total and all that is
part of the heap, these large chunks of 50-60Mb weren't done through
malloc or mmap.

Here's some more info - the files I add to glibc are in C++ and they use calls
to the nptl library, I mean they make use of pthread_create and
pthread_mutexes and
stuff even though I am instrumenting into the nptl library. So I am guessing
that this memory is set up during library load or something and there is
some problem in the way I am linking stuff right now, maybe there is something
special I need to do because of adding C++ files to glibc.

Instead of building the files along with glibc build, I tried building
a shared library with
my source code and then linking it to glibc during glibc build, still
the memoy trouble
persists. Any help or clue will be helpful. If any more info is needed
please ask for it.

PS: One more thing, when I use mtrace and muntrace() in my process linked
with the new glibc or add these two functions in the global constructor and
destructor in the C++ code, memory consumption is reduced from 150 Mb to 15 Mb
but the lock performance is reduced from 25000 locks/s to 4000 locks/s.

Cheers,
Vinu

On Fri, Jul 11, 2008 at 11:52 PM, Nix <nix@esperi.org.uk> wrote:
> On 9 Jul 2008, Vinu Rajashekhar told this:
>
>> Hi,
>> Sorry I forgot to give some information.
>>
>> Basically this anonymous memory is not part of the heap or stack
>> coz I used valgrind to check memory and its causing my RSS (resident set
>> size to go beyond 100 MB). Here is the output from pmap
>
> Big allocations with glibc malloc are normally satisfied via mmap().
>
> You could try turning mmap() allocation off by setting the
> MALLOC_MMAP_THRESHOLD_ environment variable to 0 before starting your
> program, and looking at the maps again: if those anonymous blocks are
> gone and the heap is bigger, the memory usage is attributable to
> malloc(). (libstdc++'s default operator new satisfies allocation
> requests through malloc().)
>
> It's probably just an ordinary memory leak.
>


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