dev@grizzly.java.net

Re: Question about setAllowContextCaching

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Fri, 11 Sep 2009 11:21:16 +0200

Hi Minoru,

> I have a question about Controller.setAllowContextCaching. It
> enables caching
> of NIOContext. NIOContext is cached by ConcurrentLinkedQueuePool
> which is
> implemented upon basically ConcurrentLinkedQueue.
>
> I was wondering if there would be possibilities of potential memory
> leak
> if Controller.setAllowContextCaching is enabled. That is because
> size of ConcurrentLinkedQueue is unlimited, so capacity of
> ConcurrentLinkedQueuePool can become bigger and bigger if server runs
> for a long time.
>
> Is this correct?
It depends on implementation. Normally, number of contexts, cached in
the pool should not be more than number of worker threads. But, if
you'll have a usecase, which postpones request processing (something
like Comet) - then size of pool can grow.
As I remember, we made some tests, trying to figure out if it makes
sense to cache Context instances, and found that for normal case - it
doesn't make sense, but if your application saves some heavy custom
data in context - then you might think about caching.
All depends on concrete scenario.

Thanks.

WBR,
Alexey.

>
>
> Minoru
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>