Re: garbage collector
timothy ma and constance lee wrote:
...
...In Java, they always say object use up the
memory.
That would be true of any language that is OO.
(And for non-OO languages, other things beside
objects use up memory.)
..Since all java programming will have object instiantiate like
Date(), timestamp, String etc. Should we need to garbage collect them after
use?
It depends.
For example, let's look at one program, designed
two different ways. Say you have two programs that
each deal with 10,000,000 records from a DataBase.
The code of both apps. might use a common Java Object
to represent each record, but while one program retains
a single instance of the RecordObject, and simply recycles
it for use with each record, the second instantiates 10,000,000
RecordObject's.
The first app. would probably do just fine, whereas the
second would be likely to crash in the standard memory
assigned to Java apps.
The usual advice for Java applications is not to worry
about it until/unless it becomes a problem, then use
a profiler to determine the source of the problem.
If so, how to do that by batch rather than object bu object?
To my knowledge, there is no way to ensure no more
references to an object 'by batch'. Of course, you can
call GC, and any objects with no further references should
be disposed, but I suspect you are referring to something
else.
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via http://www.javakb.com