WC3Jass.com Forum Index WC3Jass.com
"The Jass Vault"
 
 FAQ   Search   Memberlist   Usergroups   Register 
 Profile   Log in to check your private messages   Log in  
 Forum   Scripts   Files   Chat   Pastebin   Function finder  
Affiliates
The HIVE Workshop Games Modding
The Hubb Wc3Campaigns
WC3-Mapping.net

Cleaning up leaks
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    WC3Jass.com Forum Index -> Tutorials
View previous script :: View next script  

Author
JadedOnslaught


Joined: 07 Sep 2005
Posts: 101
Back to top
Message
PostPosted: Sun Apr 30, 2006 8:20 am    Post subject: Reply with quote

If you don't assign stuff to variables, it doesn't need to be nulled.

Code:
function func takes nothing returns nothing
call DisplayTextToForce( GetForceOfPlayer(GetOwningPlaye (GetManipulatingUnit())), "This function leaks a lot")
endfunction


The only thing leaking in that is a force. To fix it

Code:
function func takes nothing returns nothing
local force f = GetForceOfPlayer(GetOwningPlayer(GetManipulatingUnit() ))
call DisplayTextToForce( f, "This function isnt leaking")
call DestroyForce(f)
set f = null
endfunction


is sufficient.
View user's profile Send private message

Author
phyrex1an


Joined: 28 Jun 2005
Posts: 68
Back to top
Message
PostPosted: Sun Apr 30, 2006 11:43 am    Post subject: Reply with quote

But creating a force just to display a text to one player isn't needed.

Code:
native DisplayTextToPlayer takes player toPlayer,real x,real y,string message returns nothing
native DisplayTimedTextToPlayer takes player toPlayer,real x,real y,real duration,string message returns nothing


Actualy DisplayerTextToForce uses these natives to.
View user's profile Send private message

Author
StealthOfKing
Guest



Back to top
Message
PostPosted: Thu Jun 08, 2006 7:38 pm    Post subject: Reply with quote

Do boolean expressions have to be assigned to temp vars then destroyed?

Author
Blade.dk


Joined: 20 Apr 2005
Posts: 608
Back to top
Message
PostPosted: Thu Jun 08, 2006 8:55 pm    Post subject: Reply with quote

Yes, you destroy boolexpr objects.
_________________
#wc3dev
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

Author
LordZsar1
Guest



Back to top
Message
PostPosted: Thu Jun 22, 2006 2:49 pm    Post subject: Reply with quote

As far as I know, variables are not treated as "object" (of course, they still are a kind of "object", at least physically - with a size of four bits each, if I am not wrong), so if the object is destroyed, what is it, that leaks there!?
And as much interesting:
What is a variable, that before referenced an object, I destroy, referencing after that - if not "null"?

I asked in another place and there I was told, the variable itself is leaking...
But are not locals defined as to be deleted, when their creating function ends!?
And by setting a variable to "null", I do not destroy it, so that should not be the problem...

Author
PipeDream


Joined: 20 Nov 2005
Posts: 294
Back to top
Message
PostPosted: Fri Jun 23, 2006 2:47 pm    Post subject: Reply with quote

Try writing an interpreter.. things will become agonizingly clear awfully quick =)

Our current understand is that there's a heap of reference counted handles. The ref count itself doesn't suicide until it drops to zero and the destructor is called. For some reason when local variables fall out of scope the ref count doesn't deincrement. Maybe there's something circular going on.
_________________
jass.vim
View user's profile Send private message

Author
LordZsar1
Guest



Back to top
Message
PostPosted: Mon Jun 26, 2006 4:11 pm    Post subject: Reply with quote

Mmh...
In which way did you find out that?
It seems hard to recover something like this, if one is not seeking for it...

Author
Jass n00blet
Guest



Back to top
Message
PostPosted: Sat Aug 12, 2006 9:37 pm    Post subject: Reply with quote

What about local destructables?

Author
Alevice


Joined: 18 Jun 2006
Posts: 43
Back to top
Message
PostPosted: Sat Aug 12, 2006 11:02 pm    Post subject: Reply with quote

Jass n00blet wrote:
What about local destructables?


The same than any handle-derived (unit/item/destructible/doodad?/location/etc) type. You must destroy them and set the var to null.
_________________
_-|-_
View user's profile Send private message MSN Messenger

Author
Silvenon


Joined: 07 Mar 2007
Posts: 162
Back to top
Message
PostPosted: Sat May 05, 2007 12:53 pm    Post subject: Reply with quote

So when I have a function that returns a value, if I don't nullify it, it will leak? And I don't get this with H2I, how do you get your location (because it is converted to integer)

I have a strange problem with replying to posts that are 2 years old......
_________________
To much JASS for me........
View user's profile Send private message MSN Messenger

Author
demonpants


Joined: 11 Nov 2007
Posts: 35
Back to top
Message
PostPosted: Mon Nov 19, 2007 9:08 am    Post subject: Reply with quote

Out of curiosity -

If you use only the GUI and steer clear of JASS, how leaky will your map be? I made one that wasn't too complicated and started to get monster lag. I'm curious whether I made some redundant loop somewhere or if the GUI is just terrible about leaks.
_________________
~Demon
View user's profile Send private message

Author
Bob666


Joined: 29 Jun 2007
Posts: 192
Back to top
Message
PostPosted: Mon Nov 19, 2007 2:29 pm    Post subject: Reply with quote

if you clean leaks in GUI correctly, using custom script, thw hole thing can be called Jass Very Happy if you remove every leak then your script is more jass than gui... and if your map is too laggy, remove some triggers, or learn jass
_________________
Projects:
SupCom | WC3 FlightSim | JASS Benchmark
View user's profile Send private message Visit poster's website

Author
KaTTaNa
Site Admin

Joined: 04 Apr 2005
Posts: 655
Back to top
Message
PostPosted: Mon Nov 19, 2007 4:28 pm    Post subject: Reply with quote

demonpants wrote:
Out of curiosity -

If you use only the GUI and steer clear of JASS, how leaky will your map be? I made one that wasn't too complicated and started to get monster lag. I'm curious whether I made some redundant loop somewhere or if the GUI is just terrible about leaks.

If you are doing a campaign map, where most of the triggers are simple one-shot triggers, leaks should generally not be a concern. Especially when doing cinematic cutscenes, cleaning up leaks is not worth the trouble. But if you are doing an AOS or Tower Defense or anything with triggered spells, for example, you should definitely clean up your leaks.
View user's profile Send private message Send e-mail Visit poster's website

Author
demonpants


Joined: 11 Nov 2007
Posts: 35
Back to top
Message
PostPosted: Thu Dec 20, 2007 5:16 pm    Post subject: Reply with quote

Bob666 wrote:
if you clean leaks in GUI correctly, using custom script, thw hole thing can be called Jass Very Happy if you remove every leak then your script is more jass than gui... and if your map is too laggy, remove some triggers, or learn jass

Yeah, I've since learned Jass, I was just debating on rewriting all the triggers in that map or not.

And Kattana – yeah, the map had a whole lot of periodic triggers and also managed the AI of up to 500 units, so I'm sure there were tons of leaks. That would probably he hard to get efficient even with JASS.
_________________
~Demon
View user's profile Send private message

Author
Hans_Maulwurf
Guest



Back to top
Message
PostPosted: Mon Nov 17, 2008 1:40 am    Post subject: Reply with quote

JadedOnslaught wrote:
Code:
function func takes nothing returns nothing
call DisplayTextToForce( GetForceOfPlayer(GetOwningPlaye (GetManipulatingUnit())), "This function leaks a lot")
endfunction


Code:
function func takes nothing returns nothing
    local force f = GetForceOfPlayer(GetOwningPlayer(GetManipulatingUnit() ))
    call DisplayTextToForce( f, "This function isnt leaking")
    call DestroyForce(f)
    set f = null
endfunction



This confuses me. I looked up GetForceOfPlayer() in this sites (btw awesome) Function finder and it says:

Code:
function GetForceOfPlayer takes player whichPlayer returns force
    local force f = CreateForce()
    call ForceAddPlayer(f, whichPlayer)
    return f
endfunction


Shouldn´t this leak? It sets a handlechild variable and doesnt null it - because it has to return it.
So you can´t use this blizzard´s BJ like function leakfree at all. The only way would be to "rebuild" it with the native ForceAddPlayer() in your own function. Like this:

Code:
function func takes nothing returns nothing
    local force f = CreateForce()
    call ForceAddPlayer(f, GetOwningPlayer(GetManipulatingUnit()) )
    call DisplayTextToForce( f, "This function isnt leaking")
    call DestroyForce(f)
    set f = null
endfunction

Display posts from previous:   
Post new topic   Reply to topic    WC3Jass.com Forum Index -> Tutorials All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


FSDark by SkaidonDesigns
Powered by phpBB © 2001, 2002 phpBB Group