A registry keyed by object identity keeps every object it has ever seen alive, so a long-running worker’s memory grows in proportion to the number of distinct objects it has processed.
$ref = WeakReference::create($order);
$order = null; // the only strong reference is gone
var_dump($ref->get()); // NULL — collected
// WeakMap arrives in 8.0; until then, keyed by spl_object_id
// with a manual sweep, or SplObjectStorage and accept the retention
A weak reference does not prevent collection, which is exactly what a metadata cache attached to objects wants. SplObjectStorage holds strong references and is therefore the wrong tool for that job despite being the obvious one. Without WeakMap the practical pattern in 7.4 is a plain array keyed by spl_object_id plus a periodic sweep — and it is worth knowing that ids are reused after collection, so a stale entry can be attributed to a different object entirely.