Closed robotmrv closed 5 years ago
Again, I don't think that "make a lot of cache(MyMono).subscribe()
is a relevant pattern, and this can probably only be fixed in core, so this doesn't feel too bad. I'm opening a PR on the core issue though, as a general low-criticality enhancement.
This PR in Reactor Core fixes the memory leak problem for Duration.ofMillis(Long.MAX_VALUE)
, that is for Utils#cache
.
@simonbasle
I am happy with this solution
I'm opening a PR on the core issue though, as a general low-criticality enhancement.
but unfortunately
I don't think that "make a lot of cache(MyMono).subscribe() is a relevant pattern
this is my pattern, because we have dynamic routing key in RPC so execution is something like
So Utils.cache()
caches channel and submits to Schedulers.parallel()
invalidation task which will never be evicted, and will hold channel and all other stuff from MonoCacheTime
till application shutdown
@robotmrv The PR mentioned above will not schedule any invalidation task as soon as Duration.ofMillis(Long.MAX_VALUE)
is used, which is the case in Utils#cache
. So no task should leak. Does that address your concern?
@acogoluegnes I've just pointed out that there is a case where current behavior could lead to significant leak and it should be fixed.
I am ok and happy with solution from the PR
reactor.rabbitmq.Utils.cache()
and methods which use it could cause memory leak.For details please see https://github.com/reactor/reactor-core/issues/1916
Expected Behavior
Utils#cache()
should not submit invalidation task for "infinite" time on success, but just cache result.Actual Behavior
Utils#cache()
submits invalidation task with delayDuration.ofMillis(Long.MAX_VALUE)
i.e. "infinite" time on success, which could cause memory leakSteps to Reproduce
make a lot of
cache(myMono).subscribe()
and invalidation tasks will never be garbage collected.Possible Solution
see related reactor-core issue https://github.com/reactor/reactor-core/issues/1916
or if you do not see issue here just warn in javadocs that
Utils#cache()
orSender.rpcClient()
could cause memory leaks if they are invoked many times.Your Environment
netty
, ...):javar -version
):uname -a
):