[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Aliasing and Garbage Collection
> I am a bit concerned (and hoping that I've misunderstood) by the suggestion
> that the overhead of GC can also be removed by simply 'buying twice as much
> memory', and not reclaiming anything. In a program with lots of dynamic
> allocation, i.e. most programs, especially OO, memory would be leaked very
> rapidly, I would imagine most Java code could get through a megabyte in a
> matter of seconds. It might work if you buy a million times as much memory!
See other replies for a proper answer to this, but ...
An observation, in passing. Some years ago I wrote a compiler for a language
that provided GC, and left the implementation of GC to the end. After using
it in anger on a lot of programs, while still unfinished (i.e. without the
GC), I found that I NEVER ran out of memory. As a compiler it allocated a
lot of dynamic memory but still worked on the largest programs I could find
the compiler itself) in 4MB. I never did implement the GC, and it has still
never run out of memory.
Obviously I couldn't make any guarantees for other users, but it worked for
me. It is likely that I could live without a low-level GC on a lot of
programs - program termination provides a gross GC scheme. I expect I could
measure memory usage for my working patterns and find a memory size that
would be sufficient.
> CAN WE DO WITHOUT GC ALTOGETHER?
I was thinking of trying another angle on this, to see what sort of reaction
gets stirred up.
Can we do without pointers altogether?
Can we do dynamic structures without making pointers explicitly available?
If we provide lists, trees, stacks, queues, etc. then we might have everything.
(I write very little pointer code now that Java has given me Vector.)