Re: BASIC OS for the PC

From: Michał Pleban <>
Date: Wed, 21 Dec 2016 19:41:32 +0100
Message-ID: <>

smf wrote:

> Garbage Collection is the correct term though.
> It's very similar to the C# and Java concept of Garbage collection as well.

I am still not sure that garbage collection is the corect term here. At
the top of the Wikipedia article, it says:

"The garbage collector attempts to reclaim memory occupied by objects
that are no longer in use by the program."

That's not really what the BASIC does. In Java, Perl etc. you have
reference counts for objects. If the object is no longer referenced
(i.e. there is no code left that uses the object), garbage collector
removes the object and frees the allocated memory. This is in contrast
to languages like C++ where you are responsible to remove all unused
object yourself.

Nothing like this happend in BASIC. When you define a variable, the
variable lives forever (at least in the simple versions like Commodore
BASIC - I am not speaking about Visual Basic etc). Therefore, the memory
allocated for the variable is never reclaimed automatically when the
variable is not used, for the simple reason that the variable never
becomes "unused" (unless you clear all variabled with CLR command). SO
there is really no garbage collection.

What happens, however, is that the variable can change its length so it
may leave some space after it (if it shrinks) or be moved away to a
different location in memory (if it grows) again leaving a chunk of free
space. This is a natural process and again has nothing to do with
garbage collection. The process then needs to be run which compacts the
variables so that these small unused chunks are joined together to form
one large chunk. It involves moving the variables to new memory
locations but it does not free any "unused" space - the space is free
already, it is just moved around in memory.


       Message was sent through the cbm-hackers mailing list
Received on 2016-12-21 19:02:28

Archive generated by hypermail 2.2.0.