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: Very confused about malloc in Linux, Help!!!


I have used valgrind to test my module ( including some .so files), no memory leak found. And all the memeoy allocated by malloc are in heap area.
 
But when I integrated my module to a big program. The memory allocated in my module are in higher area. I am confused. And envn though I requested 64 bytes, the return address will be in higher area (higher than 0x4000000). As we know, If we request memory bigger than 128K, malloc will call mmap.
 
My program will create 20 more threads and run with many CPUs.

 
I don't think this the program writting problem. I want to know what did malloc do in my scenario. 

----------------------------------------
> Date: Sat, 9 Oct 2010 16:30:21 +0200
> From: pasky@suse.cz
> To: zanshigang@hotmail.com
> CC: libc-help@sourceware.org
> Subject: Re: Very confused about malloc in Linux, Help!!!
>
> Hi!
>
> On Sat, Oct 09, 2010 at 01:10:20PM +0000, Shigang Zan wrote:
>> Now I have met a problem about my software in Linux. The memory usage kept increasing until no memory to use.
>>
>> I found that malloc will return many addresses higher than 0x40000000 when I requested memory using malloc, the addresses were not in heap area (below 0x40000000). I don't know why this scenario happened.
>
> Larger allocations are not allocated in heap but using mmap().
>
>> And it seemed many blocks (1020K 1024K ...) were created and until memory was exhausted by them.
>> What can I do to found the root cause of this problem. I found many blocks had no content, but why system crote more and more blocks.
>
> Are you freeing up your memory properly? Are you sure about that?
> Check with valgrind that you have no leaks.
>
> If you want to receive programming advice, it would be wise to:
>
> * ask about it on some more general programming forum (comp.lang.c?
> stackoverflow.com?); this does not appear to be a glibc-specific
> question
>
> * create a short standalone testcase demonstrating your problem
>
> Kind regards,
>
> --
> Petr "Pasky" Baudis
> The true meaning of life is to plant a tree under whose shade
> you will never sit. 		 	   		  


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