Using XStream to write out/read in XML memory issues

Discussion in 'XML' started by k3n85, Jul 15, 2009.

  1. k3n85

    k3n85

    Joined:
    Jul 15, 2009
    Messages:
    4
    We have a larger application with a lot of static data which takes about 15-20 minutes to load up so it has the most recent values from the database. We've been able to off load this time into a seperate J2SE job which does the same thing, but then writes 20+ Map/Hashmap Objects to disk, using XStream.

    We then have the application read in these XML files, again using XStream, and repopulate the maps in the application. This saves us a lot of time in restarting the application and resolves a few other issues.

    For a basic flow:
    J2SE Loading Job --> Xstream to XML files on disk
    [XML File] --> (read) J2EE Web Application

    Our basic problem seems to be that we're getting some extra objects in memory that I'm not able to trace down a root cause.

    As for writing the Object (Map/HashMap) to XML:
    Code:
    XMLSerializationHelper.writeObjectToXMLFile(Object, "C:/data/ObjectMap.xml");
    
    Using Helper class to write XML:
    Code:
    public static boolean writeObjectToXMLFile(Object objectToWriteTo, String fileName)
        {   
        	FileWriter fileWriter = null;
            
        	try {
    fileWriter = new FileWriter(fileName);
                xstream.toXML(objectToWriteTo, fileWriter);
    ...
    
    As for reading the XML to Object (Map/HashMap):
    Code:
    someMap = (Map) XMLSerializationHelper.createObjectFromXMLFile("C:/data/ObjectMap.xml");
    
    Helper to read the XML:
    Code:
    public static Object createObjectFromXMLFile(String fileName) { 	
    
        	Object sdObject = null;
        	FileReader fileReader = null;
        	    	
        	// Create the fileReader
            try {
            	fileReader = new FileReader(fileName);
            	sdObject = xstream.fromXML(fileReader);
    ...
    
    Now this works easily, quick, without many issues. What I am see though is some issues in the HeapDump of the application, ending up with quite a few of the following:

    org/apache/xerces/dom/DeferredTextImpl
    org/apache/xerces/dom/DeferredElementImpl

    I've read about these being caused by a casting issue?

    Would anyone be able to enlighten me with any tips?

    T.I.A
    -Ken
     
    k3n85, Jul 15, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. humbleaptience
    Replies:
    0
    Views:
    5,513
    humbleaptience
    Feb 22, 2006
  2. Alain Frisch
    Replies:
    0
    Views:
    898
    Alain Frisch
    Jun 28, 2006
  3. k3n85
    Replies:
    0
    Views:
    461
    k3n85
    Jul 15, 2009
  4. Daniel Pitts

    XStream and default field values.

    Daniel Pitts, Aug 16, 2010, in forum: Java
    Replies:
    2
    Views:
    2,319
    Daniel Pitts
    Aug 16, 2010
  5. bw
    Replies:
    8
    Views:
    1,137
    Tom Anderson
    Jan 31, 2011
Loading...

Share This Page