users@jaxb.java.net

Re: About releasing resources using Jaxb

From: Ed Mooney <Ed.Mooney_at_Sun.COM>
Date: Wed, 17 Sep 2003 08:09:51 -0400

Hi Patrizio,

JAXBContext.newInstance() can be memory-intensive, depending upon the
number of classes generated from your schema. I don't know why
increasing the heap size would cure your UnknownHostException, but that
would seem to be the right solution. There are no close/destroy methods
on the JAXB-generated classes.

Regards,
-- 
Ed Mooney         |Sun Microsystems, Inc.|Time flies like
Java Web Services |UBUR02-201            |an arrow, but
Ed.Mooney_at_Sun.COM |1 Network Drive       |fruit flies like
781-442-0459      |Burlington, MA  01803 |a banana. Groucho
Patrizio.Ferlito_at_bosslab.ch wrote:
> Dear JAxbTeam,
>  
> I've just downloaded Jaxb and the user guide. I'm using it for extracting
> information from  an XML document to allocate other helper data structure.
> Reading the Java API documentation, the user guide and the FAQ I've found no
> information about how releasing resources using Jaxb so I'm asking to myself
> if I'm using correctly Jaxb.
>  
> My question is very simple.
> In the next lines I reported a bit of my example code:
>  
>  	private void readXMLServicesRepository(String xmlFile)
>  	{
>  		InputStream configpStream =
> this.getClass().getResourceAsStream(xmlFile);
>  		Repository repository = null;
>  		try
>  		{
>  			if (configpStream == null)
>  			{
>  				BEBException ex = new BEBException("Unable
> to load " + xmlFile + " file !");
>  				...
>  			}
>  			JAXBContext ctx =
> JAXBContext.newInstance("com.bosslab.abs.beb.sa.xml.services");
>  			Unmarshaller u = ctx.createUnmarshaller();
>  			repository = (Repository)
> u.unmarshal(configpStream);
>  		}
>  		catch (Exception e)
>  		{
>  			....
>  		}
>  		// now I'm extracting information navigating the repository
> object ...
>  		...
>  		List servicesList = repository.getService();
>  		int size = servicesList.size();
>  		for (int i = 0; i < size; i++)
>  		{
>  			// Store specific extracted information into some
> private member objects of the class
>  			...
>  		}
>  
>  		// At the end, have I to call some close/destroy methods on
> Jaxb objects ?
>  	}
>  
> So, after having worked with Jaxb objects,  have I to call some
> close/destroy methods on Jaxb objects ?
> In my example, I used only local Jaxb objects, so garbage collector should
> free memory when the JVM memory goes short.
> Do you suggest to set the local Jaxb objects to null at the end ?
>  
> I write you this question, because I noted the following behaviour using
> Jaxb & Weblogic 8 under Solaris 8 machine.
> We got an error like the following:
>  
>  
> 
>>>>>>Process.isValidIP() -> 02
>>>>>>Process.isValidIP() -> 06
> 
>  
> Failed to find host: java.net.UnknownHostException: labo0420: labo0420
>  
> We use JAXB objects in an our startup class, if we start Weblogic 8 without
> this startup class, the problem didn't arise.
> We tried also to increase the "initial Java heap size" (the -Xms<size>
> option) and the problem was solved.
>  
> I thank you, in any case, for any your feedback.
> Kind regards
> Patrizio Ferlito
> 
> 
> 
> 
> IMPORTANT: 
> This e-mail transmission is intended for the named addressee(s) only. 
> Its contents are private, confidential and protected from disclosure and
> should not be read, copied or disclosed by any other person. 
> If you are not the intended recipient, we kindly ask you to notify the
> sender immediately by telephone (+41-91-612 26 11), 
> to redirect the message to the account "info_at_bosslab.ch" and to delete this
> e-mail. 
> E-mail transmissions may be intercepted, altered or read by unauthorized
> persons and may contain viruses. Therefore, it is recommended that you use
> regular mail or courier services for any information intended to be
> confidential. However, by sending us messages through e-mail, you authorize
> and instruct us to correspond by e-mail in the relevant matter. 
> Thank you. 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net