Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Freeing objects that contain arrays
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Incred




PostPosted: 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
Turing:

var up : int := 2

class c
    import up
    var arr : array 1 .. up of real
end c

loop
    var p : pointer to c
    new p
    free p
end loop

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
Turing:

const up : int := 2


Please specify what version of Turing you are using
OpenTuring 4.1.2
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: