File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Garbage Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Garbage Collection" Watch "Garbage Collection" New topic
Author

Garbage Collection

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944


Hi Guys & Gals,
My manager the other day said to me that Java as a language
is more suited for small to mid size applications when taking
into concern Javas approach towards garbage collection.
He noted that Java basically holds a heap of objects used and
when that heap has reached its max size the thread starts to
inspect each individual object w/i the heap to see if it
should be discarded. Being this, he says that due to the time
it would take to scan through larger sized heaps, itsbetter
for smaller or mid-sized apps.

I knew I couldnt reply by askin him to forcefully start the
garbage collection thread n times, since this is unreliable.
So, what are some other alternatives. Ive heard mumblings of
"finalize", and others have mentioned something called
"weak reference". Could someone possibly help me here. I have
done a good amount of research and Id like to be able to
reply him constructively ya know?

Thanks
Apu Nahasapeemapetilon
Ranch Hand

Joined: Sep 06, 2000
Posts: 51

He noted that Java basically holds a heap of objects used and
when that heap has reached its max size the thread starts to
inspect each individual object w/i the heap to see if it
should be discarded. Being this, he says that due to the time
it would take to scan through larger sized heaps, itsbetter
for smaller or mid-sized apps.

One question, how does the interpreter know what size to set the heap? If a larger app has a bigger heap, how does this happen without explicitly setting this value on the interpreter command line?
Additionally, the garbage collector is supposedly a low priority thread, thus if other threads need something they will supercede the gc thread. Therefore the contention that my program will slow down whilst waiting for the GC to search thru the heap, seems a little silly.
I don't claim to fully understand Garbage Collection as I have seen very inconsistent results. I do know that coding style can have a profound effect on GC.
Ask your manager a simple question. Would they prefer a large program with memory leaks (because someone forgot to clean up) or a large program with automatic garbage collection? Garbage collection will eventually occur, memory leaks require outside assistance to reclaim that memory. Java is slow due to its interpreted nature, not because of GC.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage Collection