Scheduler + Garbage Collection question

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
Pippoflash
Posts: 135
Joined: 30 Jan 2006, 17:16
Contact:

Scheduler + Garbage Collection question

Post by Pippoflash »

Hi,
I have centralized all scheduling in a single class (will post it soon may be useful to others).

I have one question,
when I schedule tasks for game rooms that get destroyed when no users are there, even though the room is destroyed, the scheduler can still run and access all room variables, and room extension (even if in the admin tool room has been destroyed).

It is not a problem to stop the task if the room is inactive, but I am concerned about memory.

Since room is destroyed but still all properties get traced, when does a room/extension get completely garbage collected?

namaste
Pippo
-----------------------
www.pippoflash.com
-----------------------
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

1. Where are you running the scheduler task for game rooms that get destroyed?

2. Where are you tracing the game room's properties to determine if it has been cleared/destroyed?
Smartfox's forum is my daily newspaper.
Pippoflash
Posts: 135
Joined: 30 Jan 2006, 17:16
Contact:

Post by Pippoflash »

There is a centralized zone extension which has a single scheduler to which I subscribe tasks to be utilized by various room extensions.

The task holds a reference to the room, the extension, and a function to be called.

If I let the task run, even after the room has been destroyed, the task handler still traces the room, and the extension function still gets called.

Now when room is bound to be destroyed the task is removed, and all references set to null, but how can I be sure a room and its extension are really destroyed?

thanks
-----------------------
www.pippoflash.com
-----------------------
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Now when room is bound to be destroyed the task is removed, and all references set to null, but how can I be sure a room and its extension are really destroyed?
What is not clear is how do you access the Room after you have set to null all of you references. Can you explain?
Lapo
--
gotoAndPlay()
...addicted to flash games
Pippoflash
Posts: 135
Joined: 30 Jan 2006, 17:16
Contact:

Post by Pippoflash »

Yes that's before nullifying everything. As an experiment I just let the task run, and everything continues to live and run although in the admin tool the room has been correctly deleted.

So removing references is a safe way to garbage collect?
-----------------------
www.pippoflash.com
-----------------------
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

It's the one and only :)
The GC will never remove things that are referenced by your code.
Lapo
--
gotoAndPlay()
...addicted to flash games
Pippoflash
Posts: 135
Joined: 30 Jan 2006, 17:16
Contact:

Post by Pippoflash »

OK thanks,
I will try to sleep cool that unreferencing will garbage collect rooms and extensions :)
-----------------------
www.pippoflash.com
-----------------------
Post Reply