Cracking DES with C++ is faster than Java?

G

George Neuner

Most everyone says GC is or should be slower, with no given reason- it's
assumed but never discussed. Some computer language researchers say
otherwise.

And they are wrong.

Explicit memory management is provably optimal - it performs the
minimum number of operations required to achieve the result.

In operation, systemic GC wastes effort processing memory which the
programmer knows is in use and would therefore not be touched if
explicitly managed.

With loads of help from the compiler, automatic management can be
tailored to the needs of the individual application. Such tailored
systems can sometimes closely approximate explicit management -
however, they are still largely experimental and the best they could
hope to do would be to equal explicit management.

This is not a criticism of GC ... it's just a statement of fact. I
believe automatic memory management is a Good Thing (TM) - but the
safety and convenience it offers comes with a price.

Consider what happens when you do a new/malloc: a) the allocator wanders
through some lists looking for a slot of the right size, then returns you a
pointer. b) This pointer is pointing to some pretty random place.

This is only true of the most naive implementations. The simple
stuff you see in introductory algorithm books is almost never used in
practice - even the most heavily criticized real implementations have
long been case optimized for typical usage patterns and are far more
complex than the books would have you believe.

There are many excellent heap management algorithms available which
minimize processing time and fragmentation. Take a look at allocators
designed for real time use.

With GC, a) the allocator doesn't need to look for memory, it knows where it
is, b) the memory it returns is adjacent to the last bit of memory you
requested.

This is only true of moving (ie. copying and/or compacting)
collectors. Non moving collectors have exactly the same allocation
search problems as do explicitly managed heaps.

Of late, copying collectors have fallen out of favor for all but the
first generation nursery, where objects tends to die quickly. Modern
generational systems have tended toward non moving collectors for
tenured storage.

The wandering around part happens not all the time but only at
garbage collection. And then of course (and depending on the GC algorithm)
things get moved of course as well.

I suggest you spend some quality time reading about how memory
management really works. A good technology overview can be found in
"Garbage Collection: Algorithms for Dynamic Memory Management",
Richard Jones & Rafael Lins, 1997, Wiley & Sons, Ltd., ISBN
0-471-94148-4. Beyond that there are many papers available on the
current state of the art.

George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top