[Oberon] memory freeing

Christian Demmer chris at gcjd.de-web.ws
Wed Jun 30 11:28:57 MEST 2010

spir wrote:
>When I resize the array actually holding a sequence's elements, the previous array is lost. In C or Pascal, I should free it, since it is dynamically allocated (in heap, certainly); but there is no such statement (free, release) in Oberon AFAIK.

Correct. Oberon is garbage collected. If you hold some pointers to the
old array set them to NIL.

>The report speak about GC, but this is in the informative part presenting some aspects of Oberon-the-system as an example environment for Oberon-the-language.

THe Oberon language does not really work without a runtime system
providing some kind of garbage collection.

>oo2c, the compiler I presently, indeed can be built to use a GC (and I did it). So, I should be safe. But this does not solve the issue in the general case. What should I do?

Nothing. The GC is the solution to the general case. Everything else
breaks sooner or later. An Oberon runtime should ensure that there are
no dangling pointers therefore a safe implementation of Free would need
to trace the heap anyway.

Greetings, Christian

More information about the Oberon mailing list