1
解析大小超過350 MB的XML文件時,我遇到了「java.lang.OutOfMemoryError:JAVA Heap Space」錯誤。XML解析中的內存不足錯誤
PFB代碼片段:在它正試圖評估的最後一行
File file = new File("D:\WS\data.xml");
InputSource source = new InputSource(new FileInputStream(file));
XPathFactory xPathFact = XPathFactory.newInstance();
XPath xPath = xPathFact.newXPath();
XPathExpression expr = xPath.compile("//person");
NodeList nodeList = (NodeList)expr.evaluate(source, XPathConstants.NODESET);
我得到的錯誤。
某些XML構造可能非常耗費內存。你能看到xml中的任何可疑內容嗎? – jHilscher
這個論壇帖子可能有用https://community.oracle.com/thread/967427?start=0&tstart=0 – SomeStudent
你試過重啓一切嗎? –