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