About the APR’s Memory pools which seem to cause memory leaks

Resources:

http://en.wikipedia.org/wiki/Apache_Portable_Runtime


http://en.wikipedia.org/wiki/Memory_pool

http://dev.ariel-networks.com/apr/apr-tutorial/html/apr-tutorial-3.html

http://svnbook.red-bean.com/en/1.1/ch08s05.html

The APR pools are some big tables which contain references to consecutive
memory areas which are used by the application. Once the application releases
such an area, the pool marks the memory area as available, but it doesn’t give
it back to the OS.

Let’s take an example which better illustrates this situation:
We have 100 memory areas in the pool, each of 10 K RAM . Some of them are used,
some of them not.
10 consecutive objects are released, so we have a block of 100K of continuous
memory (in the pool and in the RAM).
If there comes a request to reserve 80K of RAM, a big part of this block will
be used (8 out of 10 areas). This is reutilization of the pool and from the
outside, there will be no memory increase seen.

But, if there comes a request to allocate 200K of RAM, the pool doesn’t have
enough consecutive areas to allocate 20 blocks of 10K RAM so, it has to
allocate 20 new blocks of 10 K. This means from outside, that the pool has been
enlarged and this amount of RAM will NOT be released until the end of the
program or until the application decides to flush the pool.

Some time later, if the application requests 80K of RAM, the old 10 Blocks will
be used, but at this moment, the pool has been enlarged.
AFAIK, there is no limit until which size can such a pool grow.
I’ll check this…


© Copyright 2009 Sorin Mustaca, All rights Reserved. Written For: Sorin Mustaca on Cybersecurity

Check www.mustaca.com for the IT Consulting services I offer.
Visit www.itsecuritynews.info for latest security news in English
Besuchen Sie http://de.itsecuritynews.info für IT Sicherheits News auf Deutsch

About the Author

Sorin Mustaca

Sorin Mustaca, (ISC)2 CSSLP, CompTIA Security+ and Project+, is working since year 2000 in the IT Security industry and worked between 2003-2014 for Avira as Product Manager for the known products used by over 100 million users world-wide. Today he is an independent IT Security Consultant focusing on Cybersecurity, secure software development and security for IoT and Automotive. He is also running his personal blog Sorin Mustaca on Cybersecurity and is the author of the free eBook Improve your security .

1 Comment on "About the APR’s Memory pools which seem to cause memory leaks"

Comments are closed.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close