Eclipse Plugin Central

Plugin Design - XML-Dom and Java Heap - out of memory

little_luser - Apr 13, 2008 - 11:46 AM
Post subject: XML-Dom and Java Heap - out of memory
Hi there,
I'm trying to write a plugin that should do some XML handling.
The xml-file is loaded as an IFile to the local workspace. (so far so possible)

The next thing I want to do is to create a TreeViewer and fill it with the DOM of that XML file.

The code to create the TreeViewer reads like this:
(myStream is an IputStream from the IFile and Path is the filepath to the file on my local disc.)
Code:

public void createTreeView(InputStream myStream, String Path){
      System.out.println("CreateTreeView");
      treeView = new TreeViewer(window.getShell());   
      Document dom = new XMLStuff(myStream).getParser(Path);
      treeView.add(dom, window.getWorkbench().getActiveWorkbenchWindow().getWorkbench());
   }//public void CreateTreeView


I'm trying to created parser with the following lines of code:
Code:

   public Document getParser (String myPath){
      DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
      try{
         DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
         Document myDoc = docBuilder.parse(myPath);
         return myDoc;
      }catch(ParserConfigurationException PCE){
         PCE.printStackTrace();
      }catch(IOException IOE){
         IOE.printStackTrace();
      }catch(SAXException SAXE){
         SAXE.printStackTrace();
      }//catch SAXException
      System.out.println("getParser returned null. sorry.");
      return null;
   }//public Document getParser (String myPath)   


The actuall dom I' trying to achive should be create like this:
(XMLUtil is a part of the TPTP Project.)
Code:

public Element loadXMLDom(){
   if (myStream != null){      
      System.gc();
//Hi there: The thing is that the following line causes a crash!
      Element dom = XMLUtil.loadDom(myStream, "MWEB");
      return  dom;
   }//if (myStream != null)
   else
      System.err.println("Sorry, but the Stream is null - loadXMLDom()");
   return null;
   }//public GetXMLDom


But both - the parser and the loadDom-function - do just return a Java Memory out of heap error.

Can someone please be so kind and tell me the reason for that?
Thank you in advance.
All times are GMT - 6 Hours
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits