I did some google'ing on garbage collector (GC) in java and found that it is
a big and complicated topic.
Java programmer has no permission to invoke it directly, beside juggling its
settings to adjust its frequency of running and the type of collector to
run. Even then how the GC is invoked stilll lies beyond programmer's
control.
It gets me thinking.
Why bother with it (people in the finance trade especially) ? Are the
advantages so great over c/c++ ? If the answer is yes, I can only think that
the reason is portability. Otherwise forget about tweaking GC; go for C/C++;
programmer has full control over memory management, and it is faster than
java.
I hope my opinion does not ignite the ire of java people.
[ SNIP ]
No ire on my part. I back up what Peter said (particularly with respect
to maintenance and reliability), and I'll add a few remarks of my own.
Think about why you'd want to invoke the Java GC yourself, and what that
would entail. You'd want to know *when* to do it - if you wrote the code
yourself to make that decision, and you were really good and really
experienced, it would probably look a lot like _existing_ code for some
GC or another. If you weren't that good then your code just wouldn't cut it.
By "code" I mean both the actual source and the GC parameters that you
can tune.
At first glance it might seem like this indirection - setting parameters
- removes a lot of control. That's not the case.
I'm not saying this is you - you already said it's not - but people who
assert that they can do better decision-making as to when to invoke a GC
run than the code that represents years of experience of GC specialists
strike me in the same vein as people who assert they can get better gas
mileage using manual stick than people who drive modern automatic
transmission cars. A very few people *can* do that - the majority (huge
majority) can't.
AHS