 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| l |
In HEP we often
analyze events
|
|
|
|
|
Events can be
large and involve many objects
|
|
|
|
|
We do not care
about correlations between events
|
|
|
|
l |
at the end of
the event all of its objects can be discarded.
|
|
|
|
|
Allocating many
objects and leaving the garbage collector to
|
|
clean them up can
be expensive.
|
|
|
| l |
Instead of using
the new operator
|
|
|
|
|
Track
myTrack = new
Track();
|
|
|
| l |
Use a Factory,
e.g.
|
|
|
|
|
Track myTrack =
TrackFactory.createTrack();
|
|
|
| l |
Implementation
of factory can be initially trivial
|
|
|
|
|
Later on can be
optimized
|
|
|
|
l |
reuse tracks from
previous event
|
|
|
|
l |
Discard unused
tracks only when memory becomes tight
|
|