Closed carllin closed 10 months ago
nice idea
But I'm not fan of period of time, I prefer to have a method shrink or auto detect after a pull or release. I think implementation will be complicated (in LinearObjectPool) be cause shrink could be in // with pull.
It would be convenient to be able to periodically free the unused objects in the pool to deal with elastic workloads.
For example, let's say we periodically check if the unused objects comprise > X% of the total number of allocations for an extended period of time. If
> N
of these checks return true, it would be nice to then shrink the pool to reduce memory usage.For instance, in
LinearObjectPool
, we 1) Tracked an additional pointershrink_target
representing the node representingX%
in the list, 2) NewPage
's have a pointer to theshrink_target
at the time they were added 3) we could implement the shrink by updatinghead -> shrink_target
,shrink_target -> shrink_target's shrink_target