Tutorial A friendly metaphor for leaks

Genkora

Frog blast the vent core!
Reaction score
92
This is not a tutorial for learning how to remove leaks, technically this isn't even a tutorial at all, but more a way to better help understand what a leak is.

I for one had a tough time understand what exactly a leak was; I learned how they worked long after I learned how to remove them, and I figure many people might be the same as I was.

Now memory leaks, better known simply as leaks, are when a bit of information is no longer used, but still there. These unused bits of information, points, units, groups, special effects, etc. can pile up and up and up and eventually slow everything down, causing lag or even server splits.

When I first learned of leaks, I wondered how exactly they were still there, but unused. It didn't make much sense to me, and I eventually came up with a metaphor that made a whole lot of sense to me. I suppose you can all be the judge of that.

Say you are at a public pool. This pool is rather large, it has a lot of length, width, and depth, a lot of people can swim in it at once. Now, the pool has a diving board, people keep jumping into the pool, they just keep jumping in and in and in, and eventually it starts to be pretty crowded. But oh no! Some fool has forgotten to put any stairs or ladders into this pool and the people inside can not get out. The people outside the pool don't pay attention and keep jumping in. The pool is so full now it is hard to swim around, you have to ease your way around everyone and pay close attention to what you are doing.

Now, after time, the water level rises because of so many people. It gets higher and higher and eventually it spills over and people are able to leave. They are very upset and go find a different pool. Unfortunately, not everyone can leave because the water level lowers as people get out. There are now roughly half as many people as there were when the pool spilled over. It's easier to move now, but that doesn't stop anyone from jumping into the pool.

Now for the explanation. The pool is, as you may have guessed, your map. The people are bits of information, points, groups, effects, etc. The diving board? That is a trigger. The diving board, or trigger, generates information like points, which are used in your map, or pool. As new points are made, the old ones get pushed into the pool, somewhere on the map.

There is only room for one on the diving board.

If a point is continually used, say as a spawn point, then you don't have any new points that want to jump off of the diving board. That continually used point gets its own personal diving board that only it uses.

If a point is not continually used, say in an ability, then you need to provide some sort of exit for that point, or swimmer. What I mean is, stairs or ladders to the pool. Those stairs are usually custom scripts like:

Trigger:
  • call RemoveLocation (udg_PointVariable)


Now if you remember, the pool overflowed. When there are a tremendous amount of leaks in a multiplayer game there is a thing called a server split, essentially where the game splits into pieces, and the players are split up into these different games, no longer together. Or rather, they get angry and walk to a different pool.

I hope this has been insightful and useful to anyone who does not understand what exactly leaks are. Thank you.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
ZzZ, +graveyard vote. I read about this topic for ages already. Additionally, your statement is not strong enough to persuade me not to vote it to graveyard.
 

Trollvottel

never aging title
Reaction score
262
^
|
+1

Actually it doesnt tell what leaks are but what they cause. And its not new anyway. Oh i think using metaphors to explain somethink is not a good idea.
Leaks are not just undestroyed data pieces but data pieces you cannot refer to.
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
I see this every time at the start of a leak tutorial
 

RaiJin

New Member
Reaction score
40
+graveyard vote o-o we have plenty of leak tutorials and this one doesn't provide enough
 

quraji

zap
Reaction score
144
I think this 'tutorial' is all wet. Hah.

Seriously though, the whole pool analogy is just very confusing. Just sum it up:
"Memory leaks in WC3 are handles (points, triggers, or whathaveyou) that have been dereferenced (no variable stores their location in memory) but they still take up memory".
JASS:

local trigger t = CreateTrigger() // the trigger that t points to is lost forever after the next statement, but it still uses memory <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown    :(" loading="lazy" data-shortname=":(" />
set t = CreateTrigger()
 

Jesus4Lyf

Good Idea™
Reaction score
397
>"Memory leaks in WC3 are handles (points, triggers, or whathaveyou) that have been dereferenced (no variable stores their location in memory) but they still take up memory".
LOL. I like the pool better.

Problem is, I don't actually believe they cause server splits... Else why doesn't DotA split? Lol. (Even in -wtf mode.)
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Why use a metaphor? Metaphors are rubbish. Just explain the damn thing.

IE:
Your computer has memory. Programs will go "hey, I want this section of memory for this". Like, it will allocate this area of memory, for your number variable, or for your unit, or for your location variable.

Once it has finished doing whatever it wants with the memory, it releases it, allowing the memory to be used for other things, or for other programs to use that section of memory.

A memory leak is when a program takes a section of memory, but does not release it once it has finished using it. WarCraft III is prone to this problem, as it does not have an automatic system to deal with memory leaks.
 

D.V.D

Make a wish
Reaction score
73
>"Memory leaks in WC3 are handles (points, triggers, or whathaveyou) that have been dereferenced (no variable stores their location in memory) but they still take up memory".
LOL. I like the pool better.

Problem is, I don't actually believe they cause server splits... Else why doesn't DotA split? Lol. (Even in -wtf mode.)

Dota doesn't leak. Why the heck do you think that? And what difference does it make on wtf mode? Wtf mode is basically a trigger that sets mana to 100% and resets all cooldowns when a ability is casted.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
i think dota still uses gui rofl

also this metaphor is compete rubbish
 

Jesus4Lyf

Good Idea™
Reaction score
397
Dota doesn't leak. Why the heck do you think that? And what difference does it make on wtf mode? Wtf mode is basically a trigger that sets mana to 100% and resets all cooldowns when a ability is casted.
This is obviously coming from someone who has no idea.

DotA creates timers dynamically, pauses them and forgets about them (instead of destroying).

>Dota doesn't leak. Why the heck do you think that?
I hacked it open and looked at the code. Seems you didn't.

-wtf mode means these leaky spells can be cast much faster, causing many more leaks.

I've also seen dummy units being created and stored in a local variable ~10 times a second without nulling, and of course it uses gamecache to attach to timers, meaning the handle strings are leaked also (since the timer object is).

That's just from the code for Spectral Dagger. :p
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
i think dota still uses gui rofl
No, most of the spells are using vJass now...

They are now testing 6.62 in wc3 1.24 but it does not work well, because IceFrog uses the StringHash in most of the time... He should use the integer instead...
 
Reaction score
91
> Dota doesn't leak.
Lol, it does. That's why my friend's PC gets totally raped from constant fps drops.

Anyway, there isn't really much to say about leaks and (as stated above) it has already been written in a few tutorials. Metaphors isn't the way to do it, even though it's an interesting way to represent the information. It just doesn't fit this subject correctly.
 

Igor_Z

You can change this now in User CP.
Reaction score
61
This tutorial is very long and confusing. There are many leak tutorials that are much simpler and more usefull. You need to mention all types of leaks like points,groups,special effects, triggers etc... You need to add a how to remove tutorial. Maybe add a link to leak check the newest version for new mapers.
About dotA i have hacked it too and it still has some disadvanteges. But the following 4 flaws can be seen in game as well...

1. DotA uses A unit attacks event in some spells making them vulnerable to Stop(S) command. Examples(Greater Bash, Backstab).
2. When >60 minutes of time have passed some of the spells cause great amouth of lag. Examples(Earthshaker's Ultimate, Shiva Guard etc..)
3. Spectral dagger causes lags when cast many times.
4. DotA has dummies that are visible. Icefrog probably forgot to add locust to them. Examples(Lina's second spell and Broodmother's second spell)
Enough about dotA. Sorry but I have to give +graveyard vote too...
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
No one can hack dota completly like it was never protected.....
 
Reaction score
91
> He should use Key Timers 2 instead.
Indeed, or some attachment system.
The funny thing now is that his 1.23 version does not use any system to ease his coding and instead uses raw game cache in every script (correct?) and currently he has to edit every trigger in order to make it 1.24 compatible instead of replacing a single script for less than a minute. :nuts:
It seems like poorly coded maps are better than good made ones. :D
 

Trollvottel

never aging title
Reaction score
262
This tutorial is very long and confusing. There are many leak tutorials that are much simpler and more usefull. You need to mention all types of leaks like points,groups,special effects, triggers etc... You need to add a how to remove tutorial. Maybe add a link to leak check the newest version for new mapers.
About dotA i have hacked it too and it still has some disadvanteges. But the following 4 flaws can be seen in game as well...

1. DotA uses A unit attacks event in some spells making them vulnerable to Stop(S) command. Examples(Greater Bash, Backstab).
2. When >60 minutes of time have passed some of the spells cause great amouth of lag. Examples(Earthshaker's Ultimate, Shiva Guard etc..)
3. Spectral dagger causes lags when cast many times.
4. DotA has dummies that are visible. Icefrog probably forgot to add locust to them. Examples(Lina's second spell and Broodmother's second spell)
Enough about dotA. Sorry but I have to give +graveyard vote too...

1. may be
2. lol no, never got ANY lag in dota the performance is very good and my pc isnt the best. actually, these leaks dont cause any lags since they just take up some space but everybody has about 1-2 gb ram, so WHO exactly cares?
3. thats right, but you only can spam it in wtf mode which is crap anyway and the lag is because of the effects.
4. well thats right
 

Jesus4Lyf

Good Idea™
Reaction score
397
Agreed with Vottel.

>It seems like poorly coded maps are better than good made ones.
DotA is poorly coded, and the reason is it is a legacy map. Once you start with bad code, you have to support it. It's too much work to port everything. You live with it.

And DotA prooves that leaks aren't as bad as people think, and if you have to code in GUI to make a map fast (and actually get it released), freaking do it. :p (Not saying DotA uses GUI, just making a point about leaks and efficiency.)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top