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.
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
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
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
Thx Arkeon and iri....my brother just confirmed this (and explained it more to me...he teaches computer science at the university level).
Offline
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.
Offline