|
|
#1 |
|
User
Join Date: Jul 2008
Posts: 180
|
Correct me if I am wrong, every function that defines a handle (player, unit, unit group,…) will leak if they aren’t assigned to a variable (local or global) and removed later.
__________________Reassigning a value to a certain variable (handle type) will not overwrite the previous value and the previous value will leak and thus you have to destroy/Remove the old value before you assign a new one to the variable. What is the code to destroy unit variables? It isn’t removeunit because that will remove the unit and not just the value stored in the variable. Do I need to remove a unit that is killed? I have a unit group stored in a hashtabel and I have the following action in one of my triggers: Trigger: Trigger: Unit Group - Pick every unit in (Load VisualEffectgroup of (Key (Picked unit)) in HashtableJ) and do (Unit - Kill (Picked unit))Thanks in advance. |
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#2 |
|
User
|
Trigger: Unit Group - Pick every unit in (Load VisualEffectgroup of (Key (Picked unit)) in HashtableJ) and do (Unit - Kill (Picked unit))Perfectly valid. The reason we tell GUI users to store variables are for locations and groups - the two most prominent leaks for GUI users. There is no reason to store a unit-variable if you only plan to reference it once, in fact, that's quite wasteful. That's like: JASS:function foo takes nothing returns returns unit local unit u = GetTriggerUnit() return u endfunction Not only is that pointless, but it brings up another concern: handle leaks. Those are different from the ones like location/group leaks, and I won't delve into that realm because I don't think that's addressing your question. You do not need to remove a unit when it dies. After the 60-second corpse decay period (if it's not a hero), the unit will cease to exist. If the unit is a hero-unit and you don't need it any more, yeah, remove it from the game so that it won't consume a hero-icon. Last edited by Bribe : 07-07-2010 at 02:31 AM. |
|
|
|
|
|
#3 | ||
|
User
Join Date: Mar 2009
Posts: 195
![]()
|
Quote:
Well it's not so much a "handle leak" as a pointer reference problem. The handle indexes of objects in the game are not recycled (though, some are, such as images) until all the references to that object have been cleared. This means that if you forget to set a unit variable to null then the handle index that the unit occupies will not be recycled (at least this is to the best of my knowledge). Quote:
Actually it's about 88 seconds; the values are changeable in the game-play constants. It depends on the type of decay (for example, buildings have a different decay-time than units). |
||
|
|
|
|
|
#4 | |
|
Procrastination Incarnate
Development Director
|
Quote:
Since you can't use local variables in GUI to begin with, this shouldn't really affect you; the problem is that several BJ functions (functions written by Blizzard for GUI) have this leak. |
|
|
|
|
|
|
#5 |
|
User
Join Date: Jul 2008
Posts: 180
|
So what do I do when I want to point to a unit in GUI?
__________________I use GUI pointers (Summoned unit, triggering unit, dying unit,…) without fear of memory leaks? I assign them to a global variable and set that variable to null once I am done with it? I stop using GUI and start using Jass? (Not available at this time). I didn’t get that unrecyclable pointer thing there; can anyone expand that for me? I really want to start coding with Jass, but with only knowledge of functions and how to call them, I feel like a deaf guy in a celebration and get discouraged and run to GUI, but I am aiming to become a coder of Vexorian’s level (way over my head but if I want to become the best than I should be aiming for the best) and would like to start as soon as possible. |
|
|
|
|
|
#6 |
|
†6†
Join Date: Oct 2008
Posts: 841
![]()
|
1) yup
__________________2) depends on type, groups/locations/rects/effects should be destroyed 3) best way...get you jngp from this site... as long there is one pointer (variable that holds) to the object, it's id won't be reused jass is not that har (esp vJass), you mainly need the functionnames and parameters...the rest is intuitive (function ... takes ... returns ... endfunction) |
|
|
|
|
|
#7 |
|
obey
|
there is no need of leakseeking if you using GUI, this is completely impossible to prevent leaks in many cases.
|
|
|
|
|
|
#8 |
|
User
Join Date: Jul 2008
Posts: 180
|
DioD, I heard of such thing, can you make an example (or a general guide line to avoiding them, I am sure I can code my way around some of these cases).
__________________Since GUI is leaking regardless of what we do than why is it allowed in spell contests and hell we even have GUI spells in the resources section! |
|
|
|
|
|
#9 | |
|
Procrastination Incarnate
Development Director
|
Quote:
|
|
|
|
|
|
|
#10 |
|
User
Join Date: Jul 2008
Posts: 180
|
Then we have a problem here.
__________________There are people out there who say that you can GUI a decent spell while you (the elite coders of the moding society) say that no one should use that piece of trash. Now I read the tutorial section and find tons of GUI triggering tutorials and how to remove memory leaks and how to MUI spells in GUI and then I enter the resources section and find GUI spells and I say to myself: “hay, GUI isn’t as bad as some say because they accept it” and I end up learning, and getting addicted to, GUI. Instead, the administrators should remove all the GUI tutorials and all the GUI spells and declare GUI none efficient coding method and that every self respecting coder (or coder want to be) should learn Jass and any code that isn’t Jass will be rejected. I did participate in a spell contest and got wacked on the head with “memory leaks, you have memory leaks” and I got scolded by Vexorian with a “we want spells that are decently coded in this site, and while we approve GUI we still get to beat you on the head with it” (no he didn’t say that) and I still have the impression that GUI is alright and Jass is just a little better. |
|
|
|
|
|
#11 | |
|
Procrastination Incarnate
Development Director
|
Quote:
|
|
|
|
|
|
|
#12 |
|
User
Join Date: Jul 2008
Posts: 180
|
I do have the problem of thinking in black and white, but is that really a bad thing?
__________________Is GUI good or bad (by the standards of good coding)? GUI leaks (regardless of the memory leak tutorials), less efficient and no longer acceptable as a spell making tool. Why leave it there? Why not just get rid of it? Why not let the better alternative (Jass) take over? What is “good enough for you” is supposed to mean? I am not going to work for 12 hours to make a map for myself. I make maps for others and if you don’t think GUI is good enough, and I think there are others who rightfully think that too, then I should learn Jass to please the people, right? I apologize for being argumentative (part of my nature), but if something isn’t acceptable anymore then it is beneath the standards and should be disposed of, right? I have been in a discussion like this one before, but every time we get to this point, good Jass using coders say: “you better learn Jass” but they never go ahead and say: “GUI is bad”. They say: “GUI isn’t … Jass is better, but if you like GU then it is ok” but GUI isn’t ok and you wouldn’t submit a GUI spell to contest even though you can. What is preventing you from saying that GUI should be totally replaced with Jass (save for the casual use, like in cinematics and onetime events)? |
|
|
|
|
|
#13 |
|
User
|
GUI is a part of WC3 whether we like it or not, and GUI is, in pretty much 100% of cases, where we all started out. It's not complete trash, just mostly trash.
JASS is not just a little better, it can do many, many things which GUI cannot do, and run them consistently with at least 2x better speed. And when you learn JASS, complex triggering becomes a breeze and you'll spot your memory leaks before your very eyes, instead of the "does this leak?" question which plagues many GUI-dependents. vJass, on the other hand, is not even comparable to GUI. Without the limitations and grievances of World Editor and without the annoying table-tree which you must select from, with private members, inheritance, textmacros, modules, delegates and a plethora of other cool features, you're playing big-leagues. |
|
|
|
|
|
#14 |
|
Procrastination Incarnate
Development Director
|
Again, while we think vJass is considerably better than GUI, that does not automatically mean that we think everyone should learn vJass or GTFO. Standards that apply to the resource section needn't apply to the whole site, in fact, the whole point of the resource section is to have tougher standards. The site is designed to serve the community, that is why GUI isn't accepted in the resource section (because we think the community is best served by having only the best resources at its disposal) while it is still supported elsewhere (because many people use GUI and can not/do not want to learn vJass, but they are still a part of this community and so the site should serve them too).
__________________ |
|
|
|
|
|
#15 |
|
obey
|
GUI is fast and easy way to make something like framework for actual code.
One time events (like cinematics) is leak proof, few handles is not issue. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |