Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

checking garbade collector

Thread view: 
stef - 05 Nov 2007 15:18 GMT
Hello...

With that kind of function :

 public static Date testDate(String StrDate)
 {
   SimpleDateFormat fmt;

   f = new SimpleDateFormat("MM/dd/yyyy");
   f.setLenient(false);

   try
   {
     return fmt.parse(StrDate);
   }
   catch(ParseException e)
   {
     return null;
   }
 }

I suppose fmt will be destroyed by the garbage collector when I will
get out of the function.
But, Do you know a method to "see" when the garbage do this ?

Overall, do you know How can I just really see what's free and what is
not ?
May be with finalize, but not very cool...

Thanks...
Owen Jacobson - 05 Nov 2007 17:17 GMT
> Hello...
>
[quoted text clipped - 26 lines]
>
> Thanks...

If you need to monitor the garbage collector at an object by object
level, use a heap profiler.  I use YourKit, which allows me to compare
snapshots to show only the new (or only the retained) objects between
multiple generations; other people like jmp/tijmp.

If you only need to monitor specific objects, use one of the
Reference<T> subclasses and a reference queue to monitor when those
objects get collected.
Roedy Green - 05 Nov 2007 18:38 GMT
>I suppose fmt will be destroyed by the garbage collector when I will
>get out of the function.
>But, Do you know a method to "see" when the garbage do this ?

fmt is a local variable. So when it goes out of scope there will no
more references to the SimpleDateFormatObject you created.  The leaves
it vulnerable to garbage collection.

GC does not touch the SimpleDateFormat object. It just reclaims all
the objects that DO have references to them.  See
http://mindprod.com/jgloss/garbagecollection.html

If you want to watch it die, you might be able to see it with a memory
profiler http://mindprod.com/jgloss/profiler.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.