I was working on a application which gets a XML file as input which i am going to parse using SAX parser. In my code i have defined lot of variables (around 60 to 70 String objects) in the fashion shown below
as you can see all these objects are final which i am going to use it for String equality check condition. I am getting worried about the amount of memory these String objects consume. Is there a better way of doing the same thing?
Why? Are you seeing performance issues with your applications? Do you have a very constrained deployment environment?
Yes, it takes some time to finish parsing the XML file. To be more clear i am generating my application GUI based on the XML file and after parsing through the file then only i am able to get the GUI which requires some time.
I'm guessing these variables match the elements you need to parse? If this is the case, no. You need the have the element name in order to match it.
Yes i am using those variables for that purpose while parsing.
Parsing XML files can be slow. Its unlikely it is your use of these String variables that is the cause is though. It is also unlikely that memory is the constraint. If it were, you might start to see OutOfMemoryErrors. My guess is the bottleneck is the CPU.
There is a general rule for Swing applications, do not do lengthy non-GUI work on the event-dispatch thread. Do you need to use or show your entire XML model when you start your application, or can you use SwingUtilities to improve the responsiveness of the GUI?
Not sure I follow. My assumption is Balasubramanian Chandrasekaran is using these values to work out what to do with an element when the Handler's startElement method is fired. What SAX API methods do you mean?
Paul you are correct, I use those String object for equality check.
My scenario is: 1. I will check whether i got my application starting tag by checking the parsed value to my STARTING_TAG object if that matches i will be doing relevant operations like constructing a new JFrame which will get all the components. 2. Then i will again check the equality condition on parsed value with my ELEMENT_START_TAG and then i will check what is that type of element and construct the relevant component onto the JFrame which i created previously.
....... Likewise it goes.
And can you please explain in detail.What you mean by
Do you need to use or show your entire XML model when you start your application, or can you use SwingUtilities to improve the responsiveness of the GUI?
Regarding Mintoo Kumar reply,
rather using these elements use the methods and all the facility avliable in SAX parser API.
I don't get what you are trying to convey?
After Displaying my JFrame i am calling
Whether this will guarantee Garbage Collection on my String objects?? [ May 13, 2008: Message edited by: Balasubramanian Chandrasekaran ]