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






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 Sorin Mustaca, All rights Reserved. Written For: Sorin Mustaca on Cybersecurity

Check www.endpoint-cybersecurity.com for seeing the consulting services we offer.

Visit www.itsecuritynews.info for latest security news in English
Besuchen Sie 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 over 20 years 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 CEO and owner of Endpoint Cybersecurity GmbH 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.

%d bloggers like this: