Memory allocation in Linux

Posted by Goofy on Stack Overflow See other posts from Stack Overflow or by Goofy
Published on 2011-01-14T19:47:45Z Indexed on 2011/01/14 19:54 UTC
Read the original article Hit count: 172

Filed under:
|

Hello!

I have a multi threaded application where I allocate buffers with data, which then wait in queues to be send via sockets. All buffers are reproducible because I use only buffers of fixed size in whole program (1024, 2048, 2080 and 5248 bytes). I noticed, that my program usually use up to 10 buffers of each length type at the same moment.

So far I always manually allocate new buffer and then free it (using malloc() and free ()) where it's not needed any more. I started wondering if Linux is enough smart to cache this memory for me, so next time I allocate new buffer system only quickly receive a buffer I have already used before and not perform heavy operation of allocating new memory block?

© Stack Overflow or respective owner

Related posts about linux

Related posts about memory-allocation