File/Close and Remove From Memory...

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

File/Close and Remove From Memory...

Post by bjb007 » Mon May 26, 2008 6:07 am

I'm mystified by the menu item
"Close and Remove From Memory".

It implies that closing a stack doesn't
release the (global?) variables which
seems to be a failure in the "garbage
collection" department.

Does this item have a particular use?

When should and shouldn't it be used?
Life is just a bowl of cherries.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon May 26, 2008 8:19 am

Dear bjb,

Closing a stack means that the window is closed. If the destroyStack of the stack is false, the window will be closed but the stack will stay in memory. You can still use the go command in combination with the short name of the stack to make the window re-appear.

If you remove the stack from memory, Revolution completely forgets about it and you can no longer use the short name of the stack to show the window again. If you want to open the stack, you need to use the file path to refer to it.

I don't think that global variables are released simply by removing a stack from memory.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Mon May 26, 2008 12:03 pm

Just to add to that, 'global' variables are never released during the time the IDE or your standalone application is opened. It doesn't matter if the global variable is only declared inside one stack, it si effectively global for the entire runtime environment.

So if you're sure your global variable isn't used by other stacks, you may want to clean up the memory in your 'closeStack' event handler.

Code: Select all

on closeStack
  global gMySettings
  delete global gMySettings
end closeStack
If you want your 'variables' to be linked to the stack you're using them in, you could use custom properties but that's food for another post.

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply