Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-15-2007, 06:40 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Garbage Collection

Yumm, garbage. Someone care to explain to me what all the garbage collection features GS2 has?

Also, do references exist in GS2? For example, say you do this:
PHP Code:
= new TStaticVar(); 
So, a variable n is created; a TStaticVar() is also created, in the memory of the server/client. Let's call the memory address 102 (an example). So n holds a reference to address 102. Now what if we do this:
PHP Code:
n.var1 "blah";
n
Now will x have a reference to 102? Or does it create a new TStaticVar, and then copy the vars? What if I were to do something like this?
PHP Code:
//#CLIENTSIDE
function onCreated()
{
  
= new TStaticVar();
  
x;
  
y.var1 "blah";
  echo( 
x.var1 );

What does that echo? I can't get on RC now, and I probably won't be able to for a while.

Can anyone please clear this up for me?

Then, if I go:
PHP Code:
NULL// Not destroying the object, dropping the reference
NULL// Likewise
// Now, as all references are dropped, is the TStaticVar dropped from the memory (collected by garbage collection)? 
Thanks,
Chris Zakuto
PS: Yes, I'm a Java geek.
__________________
Reply With Quote
  #2  
Old 07-15-2007, 08:03 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
References do exist, all object type vars are references. So y and x in your example would point to same object. And I really have no idea about garbage collection except that Stefan said he thought it was rather nice. For copying objects you would use new ObjectReference(); with a name being optional.
__________________
Reply With Quote
  #3  
Old 07-15-2007, 09:12 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
TStaticVar is called like that because it is not just a variant variable, which is just containing a single value of dynamic type.
When you assign a TStaticVar to a normal variable, then only a link to the TStaticVar is remembered. When there is no link to a TStaticVar anymore, then the variable will be deleted on the next run of the garabage collector.
In v4 the garbage collector has been improved to delete two (or more) TStaticVars which are only referencing each other. TStaticVars can only survive that when there is a global variable which is directly or indirectly linking to them.
Reply With Quote
  #4  
Old 07-16-2007, 02:10 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Stefan View Post
TStaticVar is called like that because it is not just a variant variable, which is just containing a single value of dynamic type.
When you assign a TStaticVar to a normal variable, then only a link to the TStaticVar is remembered. When there is no link to a TStaticVar anymore, then the variable will be deleted on the next run of the garabage collector.
In v4 the garbage collector has been improved to delete two (or more) TStaticVars which are only referencing each other. TStaticVars can only survive that when there is a global variable which is directly or indirectly linking to them.
Wait... If I just use temp.vars for my TStaticVars then they won't work now?
__________________
Do it with a DON!
Reply With Quote
  #5  
Old 07-16-2007, 02:42 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by zokemon View Post
Wait... If I just use temp.vars for my TStaticVars then they won't work now?
They would work, but after the function they would be destroyed since there are no more references, if you hadn't made any others yourself. That is, unless this has changed with v5.
__________________
Reply With Quote
  #6  
Old 07-16-2007, 07:52 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
What if the you did something like

PHP Code:
= new TStaticVar();
n.join"functions" );
n.start();
null
When the garbage collection is run, would it remove the TStaticVar since it holds no references, even if it is still running?
__________________
Reply With Quote
  #7  
Old 07-16-2007, 09:06 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
The script wouldn't continue until start() is done unless it uses a trigger for something.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.