[gclist] why malloc/free instead of GC?
Basile STARYNKEVITCH
basile@starynkevitch.net
Mon, 17 Feb 2003 20:49:45 +0100
>>>>> "Michael" == Michael Hicks <mwh@cs.umd.edu> writes:
Michael> A number of performance studies (starting with Zorn in
Michael> `92, but perhaps before?) and anecdotal evidence now
Michael> suggests that there is little reason to use malloc/free
Michael> over GC. Zorn states that the main shot against
Michael> conservative GC is that it requires a larger memory
Michael> footprint (and actually uses much of it). Another shot
Michael> might be the unexpected latency resulting from GC,
Michael> foiling soft real-time guarantees.
I tend to believe that people prefer malloc&free to Boehm's GC without
real technical reasons, but mostly for social reasons. [The almost
only soft realtime guarantee people want -outside the embedded market-
is compatibility with graphical user interfaces time requirements]
Most people I know that are proficient C coders did not even heard of
GC techniques (in particular Boehm's GC) before I talked them about
it.
FWIW, I did coded a small (unrealistic & simplistic) C example, and
found that malloc & free (on a 1.2 Athlon or 2 GHz P4) under Linux is
significantly faster than Boehm's GC. (IIRC, a typical malloc is < 1
microsecond, while a GC_malloc is < 40 microseconds).
Apparently, simple GC techniques are no more taught in CS
classes... (this was not true 20 years ago, at least not in France - I
learnt about GC in a lecture on Lisp in License, about the equivalent
of Bachelor?).
I find funny that Java rehabilitated the whole GC idea, while Java's
GC (because of the synchrony & finalization properties of the language
specification) is necessarily complex & slow.
The perception of GC by old (even technical) managers is the GC of
Lisp machines or systems, at the time when RAM was extremely
expensive.. [so garbage collection used the disk swap, and was heard
at that time because the disk made lot of noises] This is no more the
case.
Actually, I'm surprised that today's major opensource projects (like
Apache, GNOME, KDE...) don't use GC [with the exception of Emacs,
which used to explicitly show GC periods to user - this was a wrong
decision, because it made users complain against GC].
On a related note: people usually don't believe that modern ML (eg
Ocaml) or Lisp (eg CMUCL) implementations can perform about as quickly
as C (ie less than 2 times slower than C).
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net
alias: basile<at>tunes<dot>org
8, rue de la Faïencerie, 92340 Bourg La Reine, France