Linked by Zachary Pinter on Tue 27th Apr 2004 17:09 UTC
Permalink for comment
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
News
Linked by Thom Holwerda on 05/20/13 21:50 UTC
Linked by Thom Holwerda on 05/19/13 23:15 UTC
Linked by Thom Holwerda on 05/19/13 23:11 UTC, submitted by Drumhellar
Linked by Thom Holwerda on 05/18/13 21:06 UTC
Linked by Thom Holwerda on 05/18/13 7:37 UTC
Linked by fran on 05/18/13 1:38 UTC
Linked by Thom Holwerda on 05/17/13 23:35 UTC, submitted by kragil
Linked by MOS6510 on 05/17/13 22:22 UTC
Linked by Thom Holwerda on 05/17/13 22:15 UTC, submitted by Tom
Linked by Thom Holwerda on 05/16/13 21:41 UTC
More News »
Sponsored Links



The most often overlooked form of memory management is memory pooling. It's not a universal technique, but it works in many situations, and is used in Samba and Apache at least.
Pooling is lifecycle-based memory management. When you know which parts of your application's lifecycle a structure will be in, you can create a "pool" of memory which will all be freed at the end of that part of the lifecycle.
For example, Apache has memory pools for the lifetime of the server, the lifetime of the connection, the lifetime of the request, and others. If you allocate memory that you know will not be used past the end of the request, you allocate it in the request pool. Then, all objects in the request pool are freed simultaneously at the end of the request. This is by far the fastest method of memory management, because mallocs() and frees() are constant-time and very fast. Pool allocation is about the same speed as normal malloc().
There are two reusable implementations of this I'm aware of: Apache's portable runtime and GNU's obstack library. However, it's a very powerful technique if your application fits that model.