Re: C++ Speed Vs. Java
Mirek Fidler wrote:
On Feb 4, 12:58 am, "James Kanze" <james.ka...@gmail.com> wrote:
stork wrote:
Stork replied to:
And without garbage collection, you still have added overhead
(especially in a multithreaded environment) to ensure that the
object eventually gets deleted. It's not accidental that people
trying to show off the performance advantages of garbage
collection tend to use multithreaded programs with lots of
strings and substrings:-).
Wait a second though. Multithreading is the ultimate downfall of
garbage collection, because most garbage collectors have to ultimately
be locked from time to time. In C++, at least, you can set up your
own thread local memory managers, so that, most of your allocations
within a thread won't bump into allocations on another thread,
affording genuinely maximum performance. You simply can't do that in
a high level language like Java or C#.
Do you have any concrete measurements to back up that
assertion? The first thing you do when you want to write a
benchmark showing garbage collection in a favorable light is
make the benchmark multithreaded.
Second thing you are going to do is to reduce number of active memory
blocks and/or collections.
I'm not sure what you mean. What you are definitly going to
do is use a lot of small, short-lived objects. Execution
times for manual management depends very heavily on the
actual number of allocations and frees. Execution times for
garbage collection is generally conditionned by the amount
of memory in actual use when the garbage collector is
triggered. (Generational collectors are able to exclude
"long lived" memory from this.)
Third is to never post memory consumption.
Obviously:-). That's not what you're benchmarking. (Of
course, if this were to become an issue, there are ways of
manipulating it as well. Especially for moving collectors,
which automatically reduce fragmentation.)
Of course, if there are no collection phases, GC is faster.
Na. There's no point in being that obvious. Just make sure
it runs when it won't have much to do.
--
James Kanze (Gabi Software) email: james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]