Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - weird malloc failure: (7 Items)
   
weird malloc failure  
I have a program ( x86 ) that will return null for  malloc of 15 meg.  Juste before the malloc I print some heap  stats,
 it's 80Meg is size  of wich 2 Meg is unused.  There is 16 Gig of ram in the machine of which 8G is free ( and the 
program is started with on -P ).

It takes a while of this to happen and before the failure there has been over 800 call to that same malloc that worked 
fine.

Why would malloc failed?  I'm suspecting memory corruption, would that explain it?  If check the rlimits, there ok.  Can
 the memory manager return null for some "undocumented" reasons?

Re: weird malloc failure  
> I have a program ( x86 ) that will return null for  malloc of 15 meg.  Juste 
> before the malloc I print some heap  stats, it's 80Meg is size  of wich 2 Meg 
> is unused.  There is 16 Gig of ram in the machine of which 8G is free ( and 
> the program is started with on -P ).
> 
> It takes a while of this to happen and before the failure there has been over 
> 800 call to that same malloc that worked fine.
> 
> Why would malloc failed?  I'm suspecting memory corruption, would that explain
>  it?  If check the rlimits, there ok.  Can the memory manager return null for 
> some "undocumented" reasons?
> 

I forgot to mention that the program has 475M of shared memory.

Probably unrelated but is it "expected" to have the code section of the program go from 1200k to 68k when attaching the 
debugger to it?

Re: weird malloc failure  
On Thu, 2011-01-27 at 20:47 -0500, Mario Charest wrote:
> 
> Probably unrelated but is it "expected" to have the code section of
> the program go from 1200k to 68k when attaching the debugger to it? 

It is probably expected. Debugger must do some remapping to allow
inserting breakpoints.
Re: weird malloc failure  
It may be that your virtual address space gets too fragmented?

I don't think that the fact that you start process with on -P matters,
our malloc will only work within first 4G of virt. address space.

---
Aleksandar


On Thu, 2011-01-27 at 18:49 -0500, Mario Charest wrote:
> I have a program ( x86 ) that will return null for  malloc of 15 meg.
> Juste before the malloc I print some heap  stats, it's 80Meg is size
> of wich 2 Meg is unused.  There is 16 Gig of ram in the machine of
> which 8G is free ( and the program is started with on -P ).
> 
> It takes a while of this to happen and before the failure there has
> been over 800 call to that same malloc that worked fine.
> 
> Why would malloc failed?  I'm suspecting memory corruption, would that
> explain it?  If check the rlimits, there ok.  Can the memory manager
> return null for some "undocumented" reasons?
> 
> 
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post82703
> 
> 
> 

RE: weird malloc failure  

> -----Message d'origine-----
> De : Aleksandar Ristovski [mailto:community-noreply@qnx.com]
> Envoyé : 28 janvier 2011 08:56
> À : ostech-core_os
> Objet : Re: weird malloc failure
> 
> It may be that your virtual address space gets too fragmented?

Yes that`s possible our code does a lot of realloc, which I`m in the process of getting rid of..  Any way I can confirm 
this?

Thanks

> 
> I don't think that the fact that you start process with on -P matters, our
> malloc will only work within first 4G of virt. address space.
> 
> ---
> Aleksandar
> 
> 
> On Thu, 2011-01-27 at 18:49 -0500, Mario Charest wrote:
> > I have a program ( x86 ) that will return null for  malloc of 15 meg.
> > Juste before the malloc I print some heap  stats, it's 80Meg is size
> > of wich 2 Meg is unused.  There is 16 Gig of ram in the machine of
> > which 8G is free ( and the program is started with on -P ).
> >
> > It takes a while of this to happen and before the failure there has
> > been over 800 call to that same malloc that worked fine.
> >
> > Why would malloc failed?  I'm suspecting memory corruption, would that
> > explain it?  If check the rlimits, there ok.  Can the memory manager
> > return null for some "undocumented" reasons?
> >
> >
> >
> >
> >
> > _______________________________________________
> >
> > OSTech
> > http://community.qnx.com/sf/go/post82703
> >
> >
> >
> 
> 
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post82712
> 
RE: weird malloc failure  
On Fri, 2011-01-28 at 09:10 -0500, Mario Charest wrote:
> Any way I can confirm this?

I would ask in the IDE forum, I would expect that IDE can give you some
convenient way (memory analysis, librcheck and stuff)

RE: weird malloc failure  
Call mmap(NULL, 15*1024*1024, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_LAZY, NOFD, 0), if it fails, it means
 that you can not get any virtual memory larger than 15M.

Jerry Sui | Software Developer | jsui@qnx.com
O:613-591-0836 x 2904 C:613-240-9239 | www.qnx.com | QNX Software Systems
Cisco Support Team email: cisco_support@qnx.com

-----Original Message-----
From: Mario Charest [mailto:community-noreply@qnx.com] 
Sent: January 28, 2011 9:10 AM
To: ostech-core_os
Subject: RE: weird malloc failure



> -----Message d'origine-----
> De : Aleksandar Ristovski [mailto:community-noreply@qnx.com]
> Envoyé : 28 janvier 2011 08:56
> À : ostech-core_os
> Objet : Re: weird malloc failure
> 
> It may be that your virtual address space gets too fragmented?

Yes that`s possible our code does a lot of realloc, which I`m in the process of getting rid of..  Any way I can confirm 
this?

Thanks

> 
> I don't think that the fact that you start process with on -P matters, our
> malloc will only work within first 4G of virt. address space.
> 
> ---
> Aleksandar
> 
> 
> On Thu, 2011-01-27 at 18:49 -0500, Mario Charest wrote:
> > I have a program ( x86 ) that will return null for  malloc of 15 meg.
> > Juste before the malloc I print some heap  stats, it's 80Meg is size
> > of wich 2 Meg is unused.  There is 16 Gig of ram in the machine of
> > which 8G is free ( and the program is started with on -P ).
> >
> > It takes a while of this to happen and before the failure there has
> > been over 800 call to that same malloc that worked fine.
> >
> > Why would malloc failed?  I'm suspecting memory corruption, would that
> > explain it?  If check the rlimits, there ok.  Can the memory manager
> > return null for some "undocumented" reasons?
> >
> >
> >
> >
> >
> > _______________________________________________
> >
> > OSTech
> > http://community.qnx.com/sf/go/post82703
> >
> >
> >
> 
> 
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post82712
> 




_______________________________________________

OSTech
http://community.qnx.com/sf/go/post82716