Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Bug Report (https://forums.graalonline.com/forums/forumdisplay.php?f=193)
-   -   Temporary TStaticVars & Classes (https://forums.graalonline.com/forums/showthread.php?t=134260783)

Tigairius 10-11-2010 06:25 AM

Temporary TStaticVars & Classes
 
Serverside temporary TStaticVars are not being cleared from memory apparently.

Example:
PHP Code:

function myFunc() {
  
temp.= new TStaticVar();
  
temp.v.join("myclass");
  
sleep(0.1);
  return 
temp.v;


After this function is called, the temp.v stays in memory and doesn't appear to get destroyed. This is a big problem for me.

This also shows an example of my other issue. After you join something to a class, you have to sleep to wait for it to load. It would be very very nice if it would stop the stream to let the class load, since I'm sure it loads faster than 0.1 seconds.

Skyld 10-11-2010 12:26 PM

Quote:

Originally Posted by Tigairius (Post 1605519)
Serverside temporary TStaticVars are not being cleared from memory apparently.

Example:
PHP Code:

function myFunc() {
  
temp.= new TStaticVar();
  
temp.v.join("myclass");
  
sleep(0.1);
  return 
temp.v;


After this function is called, the temp.v stays in memory and doesn't appear to get destroyed. This is a big problem for me.

In your example why would you want it cleared from memory? It seems like you are trying to return a reference to be used elsewhere.

I'm guessing this is expected behaviour; TStaticVars will probably be allocated on the heap and not the stack, and sending a reference to it by return is probably instructing the garbage collector to preserve it in memory because it's expected lifetime is no longer clear (i.e. now the object is expected to outlive the function execution). In scenarios like this, you are normally expected to destroy an object yourself when you are finished with it since it is difficult for the garbage collector to determine whether you still want it or not.

Admins 10-11-2010 06:10 PM

The TStaticVar will be destroyed once no one else is referencing the object anymore. A reference in a temp.var is still a reference. It's automatically detecting 'circle references'.

Tigairius 10-11-2010 07:17 PM

Quote:

Originally Posted by Skyld (Post 1605534)
In your example why would you want it cleared from memory? It seems like you are trying to return a reference to be used elsewhere.

I'm guessing this is expected behaviour; TStaticVars will probably be allocated on the heap and not the stack, and sending a reference to it by return is probably instructing the garbage collector to preserve it in memory because it's expected lifetime is no longer clear (i.e. now the object is expected to outlive the function execution). In scenarios like this, you are normally expected to destroy an object yourself when you are finished with it since it is difficult for the garbage collector to determine whether you still want it or not.

Quote:

Originally Posted by Stefan (Post 1605579)
The TStaticVar will be destroyed once no one else is referencing the object anymore. A reference in a temp.var is still a reference. It's automatically detecting 'circle references'.

Hmm, I think I see what you are saying. I'll have to destroy it elsewhere. But what about the issue with joining classes? Is there any way this could be addressed?

xXziroXx 10-12-2010 12:22 PM

Quote:

Originally Posted by Tigairius (Post 1605597)
Hmm, I think I see what you are saying. I'll have to destroy it elsewhere. But what about the issue with joining classes? Is there any way this could be addressed?

This really does need to be addressed. When joining objects to classes they should really know about it instantly instead of having to use a sleep.


All times are GMT +2. The time now is 10:23 AM.

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