> -----Original Message-----
> From: Joe Sunday [mailto:[EMAIL PROTECTED]
> Sent: 2007?9?5? 12:11
> To: [email protected]
> Subject: Re: Memory leak in client?
>
>
> I changed it so I only create the service object once and then each
> time I need a new client use getMyPort and set it up.. The docs
> aren't exactly clear, but it looks like I get distinct proxies back
> on each call, so I'm assuming that's safe? If I then call
> service.getMyPort() across multiple threads?
>
As you already noticed, getMyPort(which calls
org.apache.cxf.jaxws.ServiceImpl.createPort(QName, EndpointReferenceType,
Class<T>) indeed creates a new proxy object every time, thus a new
ServiceFactoryBean, a new service model etc for every new proxy. If what you
are trying to do is invoking a same web service several times, you should try
to use the same proxy instead.
> It still leaks about 6 megs each time I call getMyPort() and make a
> few remote requests. After any references I have to the new port
> object are gone and I've forced a few GCs,it looks like a bunch of
> data being left in a ThreadLocal. I'm still trying to unwind what
> happens behind the scenes when I setup a client fully, but I see a
> couple ThreadLocals in JaxWsClientProxy that might not be getting
> cleared?
>
If you are sure all references to the proxy object have gone, and there are
still some objects not cleaned by GC, then it might be a memory leak on the
client side. Would you be able to reproduce same symptoms using a very simple
WSDL, for example, the hello_world sample in CXF distribution?
For example, following code snippet is modified based on hello_world sample to
show a memory leak :
................
SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
try (int =0; i <1000; i++ ) {
Greeter port = ss.getSoapPort();
String resp;
System.out.println("Invoking sayHi...");
resp = port.sayHi();
System.out.println("Server responded with: " + resp);
System.out.println();
}
If you run this, and you see the memory usage increased steadily after 1000
loops, then its definitely a memory leak.
Jervis
> --Joe
>
> On Sep 4, 2007, at 10:10 PM, Liu, Jervis wrote:
>
> > Hi Joe, based on the information you supplied, I wont necessarily
> > say there is a memory leak. Internally CXF runtime maintains a
> > service model which is built either from WSDL or from POJO,
> both on
> > the client side and server side. And this service model will keep
> > alive until the server or client gets shut down. It can
> happen that
> > a service model takes about 20MB for a WSDL of 1 MB. Having this
> > said, we did fix several memory leaks before, for example, if you
> > start a CXF client and invoke an operation several times then you
> > find the memory usage increases steadily, then it is likely that
> > you run into a memory leak problem.
> >
> > Cheers,
> > Jervis
> >
> >
> >> -----Original Message-----
> >> From: Joe Sunday [mailto:[EMAIL PROTECTED]
> >> Sent: 2007?9?5? 2:06
> >> To: [email protected]
> >> Subject: Memory leak in client?
> >>
> >>
> >> Using 2.0.1, creating a client from a large wsdl (~1 MB) in my
> >> classpath using generated stubs increases memory usage by about 20
> >> MB, which never gets garbage collected. Later clients created from
> >> the same WSDL url cause similar increases until I get an out of
> >> memory condition.
> >>
> >> static {
> >> WSDL_URL = MyService.class.getClassLoader().getResource
> >> ("myService.wsdl");
> >> SERVICE_QNAME = new QName("urn:myService", "MyService");
> >> }
> >>
> >> MyService service = new MyService(WSDL_URL, SERVICE_QNAME);
> >> MyPort client = service.getMyPort();
> >> BindingProvider provider = (BindingProvider)client;
> >> provider.getRequestContext().put
> >> (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint.getURL());
> >> Client c = ClientProxy.getClient(client);
> >> HTTPConduit conduit = (HTTPConduit)c.getConduit();
> >> conduit.getClient().setAllowChunking(false);
> >> // ... SSL setup too ...
> >>
> >> Working through a heap dump now, but does this look familiar
> >> to anyone?
> >>
> >> --Joe
> >>
> >>
> >
> > ----------------------------
> > IONA Technologies PLC (registered in Ireland)
> > Registered Number: 171387
> > Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
> > Ireland
>
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland