Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#26 26-Nov-2015 20:07:28

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: Persistence of objects or(?) freeing memory

hebdemnobad wrote:

my goal is dynamically creating and destroying objects in a global list while minimizing the amount of memory taken up by them. so if the list is full, no more objects can be created, the objects are periodically 'dying' which means emptying the of value, and when time comes to create a new object, if there is an object with empty values in the list (or array, perhaps an table as you made it is a better solution), then that object is filled with new values


With an array, the isze is initially fixed and it is entirely allocated when it is created. But the access time is faster and constant (first cases or last cases).
With a list, the size changes dynamically and the allocated memory is dynamic too. But the access time is slower and depends on the position in the list.

Offline

#27 26-Nov-2015 20:56:44

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,477
Website

Re: Persistence of objects or(?) freeing memory

iri wrote:

I don't remerber precisely.


(hd list) :: removeItemInList tl list item;

This line removes nothing. Instead of that, it adds (so, it keeps) the current item.
In fact, once the function finishes, the returned list is the truncated list.
Thus, it is after the line below that a GC could free the deleted item.

set lCylinder = removeItemInList lCylinder sCylinder;

I'm clear ?

Oops I quoted the wrong line....yes its clear now.

Offline

#28 27-Nov-2015 00:37:20

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 4,815
Website

Re: Persistence of objects or(?) freeing memory

GC comes only when a new allocation is needed or periodically.
so while the scol program do not allocate something bigger than the current memory taken there is no GC.
otherwise when you call a function that return a string for example the buffer will allocate the needed memory in VM and if the current allocation is not enough will perform a GC to clean up and then allocate.

Offline

#29 27-Nov-2015 02:06:20

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,477
Website

Re: Persistence of objects or(?) freeing memory

Thx Arkeon  and iri....my brother just confirmed this (and explained it more to me...he teaches computer science at the university level).

Offline

#30 5-Dec-2015 16:37:20

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: Persistence of objects or(?) freeing memory

To complete what we have already said, a Scol developer should NOT have to take care of the memory. It is dangerous and this goes against to the language spirit.
When a developer creates an object, Scol allocates the needed memory itself. When an object is destroyed, Scol frees the memory itself. If the memory is incorrectly freed, then this is a bug.

On the other hand, the developer can (must ?!) design his application to use the less memory.
smile

Offline

Board footer

Powered by FluxBB