使用 Rome 解析大型 RSS 提要,内存不足
更具体地说,大型 XML 网页(RSS 源)。我正在使用优秀的 Rome 库来解析它们,但是我当前尝试获取的页面非常大,并且 Java 在获取整个文档之前就耗尽了内存。
如何分割网页以便将其传递给 XMLReader?我是否应该自己做,并在添加自己的 XML 来开始和完成提要后分部分传递提要?
More specifically large XML webpages (RSS Feeds). I am using the excellent Rome library to parse them, but the page I am currently trying to get is really large and Java runs out of memory before getting the whole document.
How can I split up the webpage so that I can pass it to XMLReader? Should I just do it myself and pass the feeds in parts after adding my own XML to start and finish them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先学习将 Xms 和 Xmx 的 java 命令行选项设置为适当的值,所有基于 DOM 的解析器都会占用大量内存。其次看看使用 Pull Parser,它不必在处理之前将整个 XML 加载到文档中。
First off learn to set the java command line options for Xms and Xmx to appropriate values, all the DOM based parsers each crap loads of memory. Second look at using a Pull Parser, it will not have to load the entire XML into a document before processing it.