users@glassfish.java.net

glassfish v3.01 CDI with jersey - memory leak ?

From: <glassfish_at_javadesktop.org>
Date: Fri, 23 Jul 2010 13:08:33 PDT

I am running a really simple piece of REST code with CDI and seeing a memory leak. Not sure if I am doing something incorrect or if there really is an issue. Here is the simple code.

@Path("/hello")
@RequestScoped
public class HelloWorldResource {

    @Inject @RequestScoped
    HelloService helloService;
    public String helloWorldTest(){
        helloService.toString();
        return "xyz"
    }
}


HelloService is an empty implementation . So all I have is a rest resource with a pojo injected with @inject.

If I just access this continuously using /rest/hello/ , after a few hours I can see the jvm memory increasing continuously and eventually running out of memory. If I use a servlet instead of the resource, or if I don't inject using @inject, I don't see the memory leak.

This is a really simple scenario and I am not sure if I am doing something wrong here. Are others using jersey with CDI and not seeing any memory issues with load ?

Please let me know if any other info can help. Heap analysis points to weld related classes as potential leak suspects. I can provide more information , but this seems like a fairly common usage scenario (rest with CDI). So I am somewhat puzzled that there could be a memory leak here.

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
[Message sent by forum member 'gsattu']

http://forums.java.net/jive/thread.jspa?messageID=478446