2010-05-19 09:52:50     malloc fails with enough memory available

Document created by Aaronwu Employee on Aug 21, 2013
Version 1Show Document
  • View in full screen mode

2010-05-19 09:52:50     malloc fails with enough memory available

Ruud Althuizen (NETHERLANDS)

Message: 89546   

 

Hello,

 

I'm doing some testing with pocketsphinx_continuous which keeps failing on a realloc/malloc. Though calling malloc manually will cause the same error to occur. I'm on a BF561-0.5 using uClinux-2009R1.1-RC4.

 

When I should have enough memory free according to top:

 

Top output:

Mem: 27476K used, 32500K free, 0K shrd, 0K buff, 128K cached

 

Still a malloc of 2MB (2 * 1024 * 1024) from within gdb will fail causing this kernel trace (or similar) to be printed and malloc returns NULL. I'm fairly sure the answer to this question is obvious to most of you, but I've got no idea what I'm missing.

 

--

 

Ruud

QuoteReplyEditDelete

 

 

2010-05-19 10:46:43     Re: malloc fails with enough memory available

Robin Getz (UNITED STATES)

Message: 89549   

 

Rudd:

 

Add more memory.

 

See:

 

https://docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:difference_from_linux&s[]=fragmentation#virtual_memory

 

-Robin

QuoteReplyEditDelete

 

 

2010-05-20 03:32:48     Re: malloc fails with enough memory available

Ruud Althuizen (NETHERLANDS)

Message: 89587   

 

I've read that part (and that page in general) before, that's the part that confuses me with this problem. The article states

 

"you may have 25Meg of free memory - but allocations for 7Meg may fail, unless you have a 8Meg continuous page available)."

 

But according to the kernel trace I still have one 4MB page left: "DMA: 126*4kB 75*8kB 75*16kB 54*32kB 47*64kB 31*128kB 24*256kB 10*512kB 4*1024kB 1*2048kB 1*4096kB 0*8192kB 0*16384kB 0*32768kB = 32512kB"

 

So why isn't that page used to give me my 2MB allocation?

QuoteReplyEditDelete

 

 

2010-05-20 10:07:10     Re: malloc fails with enough memory available

Robin Getz (UNITED STATES)

Message: 89592   

 

Ruud:

 

According to your trace - Order 10 - is not 2Meg. that's 2^10 4k pages, or 4Meg - the kernel needs a little extra at the end, to manage it's linked list - so - in realitity it needs a continugous 8 Meg page to split apart. You don't have that so it fails.

 

Add more memory.

 

reduce the malloc.

 

-Robin

Attachments

    Outcomes