Subj : Re: OO compilers and efficiency To : comp.programming From : Chris Dollin Date : Thu Jul 21 2005 03:26 pm Rob Thorpe wrote: > Objects in Java are heap allocated, no matter what they are. There are > no stack allocated objects as there are in C++. This means that the > heap must take on the roll filled by both the stack and heap in other > languages. This means the garbage-collector must waste time cleaning > up stuff that's gone out of scope that in other languages would be > dealt with by just moving the stack pointer. There's an overhead, but it need not be "cleaning up stuff that's gone out of scope" (depending on what you eman by "cleaning up"). EG in a generational collector, it's the non-dead recent stuff that gets copied; the recent dead stuff is left untouched (of course it leaves a trail, such as forcing more minor collections and leaving dirty footprints in the cache). [And of course this isn't a property of Java particularly; isn't the same true in Lisp, Smalltalk, Pop11, SML, OCaml, etc?] > This means that compared to other languages with GC Java relies more on > it's garbage collector, and of course it has the extra overhead of GC > unlike C++ and C. And it *loses* the overhead of the manual management of both C and C++; malloc/free or new/delete are not free. -- Chris "electric hedgehog" Dollin .