The ServiceMixClient interface has a close() method that should be used to free memory. If you use the ServiceMixClientFacade, there's no need to call it though. If you can retrieve the ComponentContext, use it directly, or create a client facade instead of creating a new client through JNDI, as this process consumes more resources.
On Wed, Aug 13, 2008 at 3:02 PM, Ninck Blok, Jeroen <[EMAIL PROTECTED]> wrote: > Hi all, > > > > I have a question concerning the usage of a ServiceMixClient. When we > create a ServiceMixClient instance using the default JNDI lookup name > then the memory usage increases every time we send a message using the > send function. It does not matter if the ServiceMixClient is kept static > or not. See http://docs.huihoo.com/apache/servicemix/client-api.html and > our example code: > > > > ServiceMixClient client = null; > > if(client == null) > > { > > try > > { > > ClientFactory factory = (ClientFactory) new > InitialContext().lookup(ClientFactory.DEFAULT_JNDI_NAME); > > client = factory.createClient(); > > } > > catch (NamingException e) > > { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > catch (JBIException e) > > { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > //client = new ServiceMixClientFacade(context); > > } > > > > Please don't take offend at the code, it is just some test code for > debugging purposes! > > When we use the context from a MessageExchangeListener implementation > then the memory usage stays at about the same level. Again it does not > matter if the ServiceMixClient is kept static or not. See our example > below: > > > > @Resource > > protected ComponentContext context; > > > > ... > > > > ServiceMixClient client = null; > > if(client == null) > > { > > /*try > > { > > ClientFactory factory = (ClientFactory) new > InitialContext().lookup(ClientFactory.DEFAULT_JNDI_NAME); > > client = factory.createClient(); > > } > > catch (NamingException e) > > { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > catch (JBIException e) > > { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > }*/ > > client = new ServiceMixClientFacade(context);} > > } > > > > My question is are we doing something wrong? And if so how should be > create a ServiceMixClient without using the context from the > MessageExchangeListener implementation? And secondly is there any > (known) memory leak in the first method? What causes this behavior? > > > > Thanks in advance, > > > > Jeroen Ninck Blok > > > > > > > > This e-mail and any attachment is for authorised use by the intended > recipient(s) only. It may contain proprietary material, confidential > information and/or be subject to legal privilege. It should not be copied, > disclosed to, retained or used by, any other party. If you are not an > intended recipient then please promptly delete this e-mail and any attachment > and all copies and inform the sender. Thank you. > > -- Cheers, Guillaume Nodet ------------------------ Blog: http://gnodet.blogspot.com/
