504 Accelerating MATLAB
®
Performance
Reusing class objects prevent reallocations, deallocations, and object initialization (in the
constructor), which may signicantly help performance. We shall revisit this idea below,
when we discuss object pools.
As an alternative to using constant properties, we might consider using the singleton
design pattern.
1515
The basic idea is to have only a single class object available for use, and
have all the class functionality be available via that singleton object. The pattern ensures
that no more than a single instance of the class is ever created, preventing unnecessary
memory allocations.
Singletons have several possible implementations. All implementations share the com-
mon aspect of making the object con ...