i noticed that Pool is currently providing two things, which i think it is confusing to combine (at least in the way they're currently combined):
- "permits": acting as a
Semaphore to limit the maximum number of objects in use at a time
- "store": providing a collection of objects available for re-use
But note that the limit is on the "permits" (the number of objects in use), not on the "store" (the number of object available for re-use), on which there is no limit, e.g.
julia> pool = Pool{Int}(2);
julia> for i in 1:100
x = acquire(() -> i, pool; forcenew=true)
release(pool, x)
end;
julia> length(pool.values)
100
I worry this could lead to a potential memory leak for users who do not realise that the "store" can grow arbitrarily in size and never be cleaned up.
I wonder if the size of the "store" should also be limited (for example, forcenew could force an eviction either always or if the collection is at capacity)
i noticed that
Poolis currently providing two things, which i think it is confusing to combine (at least in the way they're currently combined):Semaphoreto limit the maximum number of objects in use at a timeBut note that the limit is on the "permits" (the number of objects in use), not on the "store" (the number of object available for re-use), on which there is no limit, e.g.
I worry this could lead to a potential memory leak for users who do not realise that the "store" can grow arbitrarily in size and never be cleaned up.
I wonder if the size of the "store" should also be limited (for example,
forcenewcould force an eviction either always or if the collection is at capacity)