On Jul 24, 2010, at 3:10 PM, satish gopalakrishnan wrote:
> Thanks for the response. I did annotate my resource with @Singleton
> (javax.inject) and after about 6 hours or so, memory usage does seem
> to be stable. With the @Request scope, I would have already seen
> the memory usage go up by now.
>
> With @Request scope, almost after every full GC the tenured pool
> usage keeps increasing and in a couple or days I would run out of
> 512 MB of heap space with an OOM error.
>
> So to summarize, these are the observations so far
>
> 1. With @Request scope and using @inject, there is a memory leak.
> 2. Using just a servlet while using @inject, there is no memory
> leak ( basically not using REST Resource )
>
> 3. With @Singleton scope, there doesn't seem to be any leak based on
> early results.
>
> I am seeing that the same instance of the HelloService is being
> used on every method invocation - which I guess is expected since
> the Resource is Singleton scope , the injected HelloService has the
> same scope.
>
The HelloService does not have a scope (i cannot recall the exact CDI
term for this, like "prototype" in Spring, or the default scoping
rules in Guice) so basically a new instance is instantiated whenever a
reference is requested.
Paul.
> So based on these observations, any ideas on what may be going on ?
> A few days back, I did do a heap dump analysis with ecipse mat , and
> just the basic "leak suspects" gives me the following
>
> One instance of "org.jboss.weld.manager.BeanManagerImpl" loaded by
> "org.apache.felix.framework.ModuleImpl$ModuleClassLoader @
> 0x93fd5ad8" occupies 233,469,192 (79.61%) bytes. The memory is
> accumulated in one instance of
> "com.google.common.collect.CustomConcurrentHashMap$Impl$Segment[]"
> loaded by "org.apache.felix.framework.ModuleImpl$ModuleClassLoader @
> 0x93fd5ad8
>
> I know this points to something in WELD, but when I use @inject in
> other applications without using jersey, I haven't come across
> issue, so I am thinking maybe something involving jersey is going
> on. Quite possible that this is weld related too.
>
> Thanks again !
>
>
>
>
>
>
> > To get the simple stuff out of the way - until a GC actually runs,
> you should see the amount of memory in use increase - your JAX-RS
> resources (explicitly, or in general by default) are created on each
> call, and only used for that one call. So > you would expect memory
> use to increase, until GC cleans up.
>
> > You could annotate your resource to be a singleton, instead, to
> see if memory use remains stable ...
>
> > Moises
>
> On Jul 23, 2010, at 10:45 PM, satish gopalakrishnan wrote:
>
> > Hi,
> > I am using glassfish v 3.01. I have the simplest of applications -
> a hello world resource and a helloService which is empty. When I
> access it repeatedly using just wget, after a while I see that the
> memory usage keeps increasing - basically a memory leak. Here is the
> code
> >
> >
> > @Path("/hello")
> > @RequestScoped
> > public class HelloWorldResource {
> >
> > @Inject
> > HelloService helloService;
> > public String helloWorldTest(){
> > helloService.toString();
> > return "xyz"
> > }
> > }
> >
> > Am I doing something wrong here ? This is the simplest possible
> application with CDI and jersey - so somewhat surprised that this
> can have a memory leak. I tried @managedBean as well. Same result.
> >
> > My web.xml looks like this
> >
> > <servlet-
> class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-
> class>
> > <init-param>
> > <param-name>javax.ws.rs.Application</param-name>
> > <param-value>mtest.HelloApplication</param-value>
> > </init-param>
> > </servlet>
> >
> >
> > Any help / insights would be greatly appreciated
> >
> > thanks
>