template < class C >

class AutoReleasePool

Library: Foundation
Package: Core
Header: Poco/AutoReleasePool.h


An AutoReleasePool implements simple garbage collection for reference-counted objects. It temporarily takes ownwership of reference-counted objects that nobody else wants to take ownership of and releases them at a later, appropriate point in time.

Note: The correct way to add an object hold by an AutoPtr<> to an AutoReleasePool is by invoking the AutoPtr's duplicate() method. Example:

AutoReleasePool<C> arp;
AutoPtr<C> ptr = new C;

Member Summary

Member Functions: add, release


AutoReleasePool inline


Creates the AutoReleasePool.


~AutoReleasePool inline


Destroys the AutoReleasePool and releases all objects it currently holds.

Member Functions

add inline

void add(
    C * pObject

Adds the given object to the AutoReleasePool. The object's reference count is not modified

release inline

void release();

Releases all objects the AutoReleasePool currently holds by calling each object's release() method.