• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Streaming XML Reader fills up memory?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After encountering a memory leak I stripped down my code to the following minimal fragment that reproduces the problem:



The file "import2.xml" has a size of approximately 15Mb. When running this code, the following output (and stack trace) is written:



Using a heap dump analyzer, I found out that some char[] internal to that weblogic parser was filled with the contents of the whole file. There are 2 strange things in this situation:

1. Why is the javax.xml.stream.XMLEventReader instance using the weblogic.xml.stax.* package internally? Is this configured somewhere? Even stranger, I couldn't find any of the weblogic.xml.stax.* classes on my classpath.
2. Why is the whole file loaded in memory while the code iterates through it event by event? Do I need to configure anything to reduce some internal buffer size, and hence the overall memory footprint?

Many thanks,

Jonatan
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. I suspect that somewhere there must be a system property that specifies the weblogic.xml ... package for the default parser.

A normal SAX parser would not be so wasteful.

Bill

 
Jonatan Samoocha
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem seems to be classpath-related: when the above code is moved to an empty project with just the JAXB jars on the classpath, everything runs ok. I'll report about the offending classes if able to find them.
reply
    Bookmark Topic Watch Topic
  • New Topic