2010-11-18 14:08:54     Fragmented memory

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

2010-11-18 14:08:54     Fragmented memory

Peter Gombos (HUNGARY)

Message: 95954   

 

Hi,

 

 

 

I'm a bit confused now with the memory management.

 

I have an application (written by somebody else) which allocates small peace of memories using malloc().

 

It allocates 20 bytes next 4 bytes, 100 and finally 100 bytes periodically. An other function allocates other pattern of data.

 

These functions free up the allocated data and realocate a new one with exactly the same size.

 

Is it possible to run out of the memory with this behaviour? It seems some other process (telnet, ftp or http cgi) unable to start due memory allocation failure. The free command shows at least 25M free.

 

I'm sure there is no memory leak in the application.

QuoteReplyEditDelete

 

 

2010-11-18 14:47:17     Re: Fragmented memory

Mike Frysinger (UNITED STATES)

Message: 95956   

 

the kernel allocator operates in chunks of pages ... as long as you stay below that, an alloc should never fail

 

but your memory patterns probably will fragment memory preventing modest sized allocations from failing ... such as loading apps which need larger chunks of contiguous memory

 

the OOM error message will tell you what the memory layout looks like.  a simple summation of the free chunks isnt useful in this case.

 

what toolchain/kernel version are you using ?  2009R1 and newer have improved memory allocators to help keep small allocs from fragmenting as much ... but it cant fix everything.

QuoteReplyEditDelete

 

 

2010-11-18 16:23:59     Re: Fragmented memory

Peter Gombos (HUNGARY)

Message: 95957   

 

Hi Mike,

 

I use 2010R1RC1 now. The previous version was 2009R1.1RC4.

 

As far as I remember I haven't experienced this kind of crash in the 2009 version.

 

The same application ran fine earlier and now I have problems. The system should run stable years without restart.

 

Shall I play with different allocators?

 

Additional info: this application has a special malloc and free functions to count the number of the allocated pointers and the size of the data. It seems the size of the data is approx 2M and the number of chunks is 15000.

QuoteReplyEditDelete

 

 

2010-11-18 16:39:48     Re: Fragmented memory

Mike Frysinger (UNITED STATES)

Message: 95959   

 

you can try tweaking the CONFIG_NOMMU_INITIAL_TRIM_EXCESS option in the kernel

Attachments

    Outcomes