We currently have the problem that cache prune stops after some time
which leads to memory leaks. It seems that the problem starts after
some idle time. I did some investigation and it seems that there is a
bug in
GarbageCollectionCachePruner.PruneCacheIfGarbageCollectorHasRun. Here
is the original source of this method:
private void PruneCacheIfGarbageCollectorHasRun(object state)
{
if (_indicator.IsAlive) return;
Cache.Prune();
_indicator.Target = new object();
_timer.Change(GetTimeoutInMilliseconds(), Timeout.Infinite);
}
If I understand it correct, the idea of the first line is to skip one
execution of cache prune if the garbage collector has not run since
the last execution. But what it actually does is stop cache prune
forever. So I think the implementation shoud rather be the following:
private void PruneCacheIfGarbageCollectorHasRun(object state)
{
try
{
if (_indicator.IsAlive) return;
Cache.Prune();
_indicator.Target = new object();
}
finally
{
_timer.Change(GetTimeoutInMilliseconds(), Timeout.Infinite);
}
}
What do you think about this? Does anyone know the idea behind this
first line of the method? Has anyone else the problem that cache prune
stops after some time too?
--
You received this message because you are subscribed to the Google Groups "ninject" group.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ninject?hl=en.
if (_indicator.IsAlive) return;
is taken.
If the GC did not run, then the timer is not reset and the cahce is
never pruned.
Cheers,
Urs
On Apr 2, 9:21 pm, Ian Davis <ida...@innovatian.com> wrote:
> If I understand correctly, your fix would handle the situation where
> Cache.Prune() throws an error. Are you seeing this behavior in your code?
>
> Thanks,
>
> -Ian
>
> > ninject+u...@googlegroups.com<ninject%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.
Keep up the good work.
Cheers,
Urs
On Apr 3, 12:25 am, Ian Davis <ida...@innovatian.com> wrote:
> I have confirmed the bug and the fix. I will push when I get a chance
> tonight. Nice find.
>
> -Ian
>
> > ninject+u...@googlegroups.com<ninject%2Bunsu...@googlegroups.com>