Re: BASIC OS for the PC

From: smf <smf_at_null.net>
Date: Thu, 22 Dec 2016 00:47:31 +0000
Message-ID: <b67ead9e-ecfd-c5d2-b2c9-15538bdf7b7e@null.net>
On 21/12/2016 18:41, Michał Pleban wrote:
> 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.

In terms of growing, StringBuilder in c# does essentially the same thing 
internally.

When you allocate one then it creates a char[] of a default length, and 
as you append text and exceed that length then it will allocate a new 
char[] copy the text into it and leave the original char[] to be garbage 
collected.

c# doesn't have the concept of shrinking a char[], so reducing the 
buffer would require you to allocate a new char[]. So BASIC creates 
garbage that is the difference between the old and new size, while c# 
creates garbage that is the old size.



       Message was sent through the cbm-hackers mailing list
Received on 2016-12-22 01:00:02

Archive generated by hypermail 2.2.0.