| Posted: Thu Mar 15, 2018 8:39 pm Post subject: Freeing objects that contain arrays
|What is it you are trying to achieve?
To deallocate objects, each containing an array, created with the same class completely from memory
What is the problem you are having?
Is there a way to completely free an object that contains an array with a variable as its upper range?
While reading the memory used by Turing through task manager, running a loop that repeatedly creates new objects (of the same class) that contain an array causes the memory used to continually increase, despite a free statement within the loop (see below)
Describe what you have tried to solve this problem
Writing in the classID after the free statement (as in free classID, pointer)
Making the array non-flexible (I was using a flexible array before, but found that this would be much easier to explain using just a normal array)
Creating the array with a constant as its upper range DID allow the entire object to be freed from memory, but what I'm trying to achieve requires objects containing arrays of varying ranges.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Running the following will cause the memory use of Turing to pile up very quickly
var up : int := 2
var arr : array 1 .. up of real
var p : pointer to c
By changing the first line to the following, Turing successfully frees the entire object, but I wish to know the way to free the object without making its upper range a constant
const up : int := 2
Please specify what version of Turing you are using