Re: Garbage collection in C++
On Nov 21, 12:37 am, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
George Kettleborough <g.kettleboro...@member.fsf.org> writes:
I suppose what I don't get is why you would ever want to
create objects on the stack. It's something you can't do in
Java,
I just read this in =BBcomp.lang.java.programmer=AB:
John B. Matthews wrote in <nospam-20B427.16262820112...@news.motzarella.o=
rg>:
|I was pleasantly surprised by the speed of the JScience
|library, possibly due to stack-based allocation afforded
|by Javolution, on which Jscience is based. (...)
|<http://jscience.org/>
|<http://javolution.org/>
(End of quotation from =BBcomp.lang.java.programmer=AB.)
=BBObjects can be allocated on the "stack" and transparently
recycled. With Javolution , your application is busy doing
the real work not memory management (e.g. Javolution
RealtimeParser is 3-5x faster than conventional XML
parsers only because it does not waste 2/3 of the CPU
doing memory allocation/garbage collection).=AB
I'm not sure that this is quite relevant to the original
question. The poster said that he didn't get "why *you* would
ever want to create objects on the stack". In Java, you can't
create objects on the stack. The compiler, of course, works
under more or less the same "as if" rule as a C++ compiler; it
can do more or less anything it wants, as long as the output of
your program doesn't change. Including allocating variables on
the stack, even if you've written "new" in your code. (Note
that a C++ could theoretically do this as well. But trying to
identify cases where it would be applicable is probably wasted
effort on the part of the compiler, because if the object could
have been on the stack, the programmer wouldn't have used
"new".)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34