Re: JDOM output buffering question
Rolf Lear <[email protected]>
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Message-ID | <[email protected]> |
Yes, GC really happens each time .... As for your un-released memory, make sure you close and de-reference all Streams and Readers/Writers, as well as all set all referenced JDom objects to null. Rolf Gamble, Wesley (WG10) wrote: > FYI, I'm on JRE 1.3.1_09. > > After reviewing the verbose:gc output on my running process, I see that > tiny amounts of memory are being reclaimed multiple times/sec., but when > I complete generating my JDOM document and writing it out, I do not see > the big drop in heap size that I would expect. There must be something > I'm holding onto that I don't realize. > > One question - is GC really happening once for each "[GC.." output line > in the verbose output? It looks like it's happening many times/second. > > Wes > > -----Original Message----- > From: Rolf Lear [mailto:[email protected]] > Sent: Monday, January 21, 2008 1:14 PM > To: Gamble, Wesley (WG10) > Cc: [email protected] > Subject: Re: [jdom-interest] JDOM output buffering question > > JVM's are typically reluctant to release memory back to the OS. A better > > way to monitor the actual memory usage (in your case) is to turn on the > -verbose:gc commandline-option (or better, the -verbose:gc > -XX:PrintGCTimeStamps) to your Java process. This will track your memory > > usage better, and tell you how much memory gets cleaned up from > no-longer-referenced Java classes (Garbage Collected). > > May I suggest the following reading material: > http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepap > er.pdf > > Once Java requests memory from the OS, it is very unlikely to give it > back. Whether it gets used (again) or not. Tracking memory from the OS > perspective gives you no indication as to whether objects are GC's or > not. > > Another Alternative is to generate a Full heap dump from your JVM (Press > > Ctrl-ScrollLock in Windows, and Ctrl-\ on Unix (or kill-3 <pid>). > > Rolf > > Gamble, Wesley (WG10) wrote: > >> I'm watching the memory for the Java process in the Windows task >> manager. >> >> -----Original Message----- >> From: Rolf Lear [mailto:[email protected]] >> Sent: Tuesday, January 15, 2008 6:41 PM >> To: Gamble, Wesley (WG10) >> Cc: [email protected] >> Subject: Re: [jdom-interest] JDOM output buffering question >> >> Gamble, Wesley (WG10) wrote: >> >> >>> I put a finalize method on the object that holds the SAXBuilder as an >>> > > >>> instance variable, and set the SAXBuilder to null, and no memory is >>> released. >>> >>> The descendant of the JDOM Document gets garbage collected, and I'm >>> assuming the SAXBuilder will get garbage collected, but my memory is >>> still way high. >>> >>> Can anyone think of any ways that resources could still be held on to >>> > > >>> in this scenario. Perhaps my leak is not in JDOM. >>> >>> Thanks, >>> >>> Wes >>> >>> >>> >>> > ------------------------------------------------------------------------ > >> >> >>> _______________________________________________ >>> To control your jdom-interest membership: >>> >>> >>> > http://www.jdom.org/mailman/options/jdom-interest/[email protected] > >> How are you measuring your memory usage? >> >> Rolf >> >> >> > > > _______________________________________________ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/[email protected]