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.

#1 11-Nov-2014 16:43:48

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

assuring the all objects are destroyed on shudown by testing value

my mediaoctopuslayer project creates many objects and images....and I haven't mapped out the destruction of all of them, although I'm pretty sure my code destroys all the objects it creates.

but just to be sure, when mainWindow closes down, is it ok to do something like this for all the objects created....

assume i know the type of each object i want to destroy...

can i test for the existence of the object, and if it is not nil, destroy it, just to be sure i've cleaned up all the objects i have created

so for example, lets say I create an AlphaBitmap somewhere in my code. i'm pretty sure i destroy it prior to closing down the app, but when mainwindow is closed down, can i write

if object !=nil //code to destroy object depending on object type// else nil;

Offline

#2 11-Nov-2014 19:04:15

Bob Le Gob
Scol language & Scol applications developer
Registered: 9-Apr-2009
Posts: 26

Re: assuring the all objects are destroyed on shudown by testing value

There are two things you should do:
- When your app starts, you should call a function which initializes all your objects to nil. (simply declaring the object does'nt always set the variable to nil)
- When you quit the app, you then can test if an object is set to nil or not. Accuracy is then 100%.

Offline

#3 11-Nov-2014 19:22:32

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

Re: assuring the all objects are destroyed on shudown by testing value

Bob Le Gob wrote:

There are two things you should do:
- When your app starts, you should call a function which initializes all your objects to nil. (simply declaring the object does'nt always set the variable to nil)
- When you quit the app, you then can test if an object is set to nil or not. Accuracy is then 100%.



thx...i think i will make it a habit to test the existence of every object created in my app and destroyed it if != nil

.....it turned out that the other processes were running from a few days ago when my app was not destroying all the objects/bitmaps/alphabitmaps/etc. i then did a  full restart.

when the vm is running in the task tray, there is one process named scol.exe
when i open my project, there are two processes
when i close my project, there is one process

so i'm not leaving any objects hanging around after app shutdown.

Offline

#4 11-Nov-2014 19:44:21

Bob Le Gob
Scol language & Scol applications developer
Registered: 9-Apr-2009
Posts: 26

Re: assuring the all objects are destroyed on shudown by testing value

Great!

Offline

#5 11-Nov-2014 20:55:20

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

Re: assuring the all objects are destroyed on shudown by testing value

for 2D content this is done automatically when you use the g2Dlib

Offline

#6 11-Nov-2014 21:31:04

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

Re: assuring the all objects are destroyed on shudown by testing value

When you destroy an object, set also the variable to nil explicitely, mostly with structures.

struct MyStruct =
    field_1 : ...,
    field_2 : ...,
    ....
    ] mkMyStruct;;

fun destroyField_1 (mystruct)=
    // destroy the object
    ...
    // then set the field to nil (not before the destroy)
    set mystruct.field_1 = nil;
    ...

Offline

#7 11-Nov-2014 22:21:32

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

Re: assuring the all objects are destroyed on shudown by testing value

iri wrote:

When you destroy an object, set also the variable to nil explicitely, mostly with structures.

struct MyStruct =
    field_1 : ...,
    field_2 : ...,
    ....
    ] mkMyStruct;;

fun destroyField_1 (mystruct)=
    // destroy the object
    ...
    // then set the field to nil (not before the destroy)
    set mystruct.field_1 = nil;
    ...

I will do that thx

Offline

Board footer

Powered by FluxBB