Open
Description
The current mechanism for tracking memory usage in an ObjectPool is rather simplistic, simply adding Object::memoryUsage() to the total when adding an object and subtracting it when removing an object.
In reality, many objects share the same child objects, so we are overcounting our memory usage, and therefore removing objects from the pool in unnecessary attempt to keep below memory limits. We should fix this.
Note that when counting the memory for an individual object with Object::memoryUsage, we already have an awareness of when the same child object is referenced twice, and don't overcount there, using the Object::MemoryAccumulator class - I suspect we could use a persistent version of something like this class inside the ObjectPool.