Click or drag to resize
DigitalRuneResource Pooling

This section describes the kind of resource pooling that is used in DigitalRune Geometry.

Resource pooling

The current version of the .NET Compact Framework has some limitations compared to the full version of the .NET Framework. In particular, it does not support generational garbage collection. A run of the garbage collector on the Xbox 360 or on the Windows Phone 7 typically has a higher latency than in Windows and can lead to significant frame rate drops.

Therefore, it is crucial to reduce the amount of memory that is allocated at runtime to avoid too frequent garbage collections. A strategy to reduce memory allocations is resource pooling. When using a resource pool (see class ResourcePoolT) objects are acquired from the pool instead of being newly allocated on the managed heap. When an object is no longer used it is returned to the resource pool for later reuse.

Resource pooling in DigitalRune Physics

DigitalRune Physics extensively uses resource pools to avoid unnecessary memory allocations. In particular, objects of type ContactConstraint are now automatically recycled and reused.

Caution note Caution

You should not store direct references to objects of type ContactSet, Contact or ContactConstraint that were automatically created by the physics simulation. These objects can be recycled and reused between updates of the collision detection - so the references might become invalid.

In general it is not necessary to keep references to these types of objects.

Thread-safety

More information

Please read Resource Pooling (DigialRune Base library) for detailed information about resource pools.