• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Minor memory leak after nullifying?

Status
Not open for further replies.
Level 2
Joined
Jun 28, 2010
Messages
20
I've tested this many times through the task manager with different types of variables, but it seems that there is still some kind of leak left after you remove a variable.

As an example, i made one of my functions (GUI) like this: ( )

set udg_Point1 = (Position of Peasant 0000 <gen)
set udg_Point2 = (Point1 offset by 0.01 towards (Facing of Peasant 0000 <gen) degrees)
call RemoveLocation (udg_Point2)
call RemoveLocation (udg_Point1)

Obviusly this would not leak, at least i don't think so, but apearently warcraft is still affected, even though the memory leak is about 50 times larger without the nullifying of the locations.

I ran this 400 times every 0.01 seconds. This is ALOT, and that many points every second would obviusly not be used in a game. The problem is the groups who uses one hell of a lot more space than the points.

Also, even though the memory leak is reduced to 2% it is still a big problems for maps like Warloc where there is a constantly running system who uses a huge amout of points and groups.

Is there anyone who knows how to remove this leak? Preferably without moving to JASS.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
You have proof that this was leaking? Remember that WarCraft III increases memory usage by itself.

Compare the rate of memory usage increase by not running the script at all and then running it 1000 times a second. This allows you to detect leaks.

Remember that unique strings leak as well since WarCraft III cannot perform any kind of string garbage collection at all (or at least does not do so regularly).
 
Level 2
Joined
Jun 28, 2010
Messages
20
I have compared it to the memory usage when not using any triggers, and it is clearly rising alot more with the trigger on, and different from when the trigger was off it never stopped rising. I've also tried to nullify the variable too, but somehow it got even worse.

I'm actually making a map that i already have taken away all memory leak from (I've been searching for different kinds of memory leak for 3 months ):), but yet, it keeps lagging after about 15 minutes.
 
Level 2
Joined
Jun 28, 2010
Messages
20
In my map i have actually used that to save every units knockback, instead of using a point. But doing that should not be possible on everything, since you would still need to use X/Y of POINT, so the point will still be leaking.
 
Level 2
Joined
Jun 28, 2010
Messages
20
I've tested some more and I could be wrong about the points still causing memory leak, it might have been just the ordinary increase of memory usage, that happened to go on for a litle longer with the trigger on. But if that is the case, what could be causing such a huge leak in my map? Is it groups that leak after removed, or is it some kind of leak that i don't know about. I've checked for: Points, groups, forces, special effects, units, sounds, timers and maybe some more things. Please help me out, I'll continue to test for this wierd leak.
 
Level 2
Joined
Jun 28, 2010
Messages
20
When will you have to use the X/Y of a point? I can think of no times one has to use a point next to getting terrain Z.

What the hell are you talking about? If i want to find, lets say, the possition of picked unit, how am I supposed to just take X/Y of Picked unit? The commands are called X of point and Y of point, and then you put those in as coordinates, which creates yet another point. Just check in the editor.

I've tested for unit groups some more, they make a clear leak, doesn't matter if i destroy, destroy and nullify it, or use the set bj_wantDestroyGroup = true command. It is however still hard to say if it is just groups that leak, or just that they leak alot more than points do after destroyed.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
What the hell are you talking about? If i want to find, lets say, the possition of picked unit, how am I supposed to just take X/Y of Picked unit? The commands are called X of point and Y of point, and then you put those in as coordinates, which creates yet another point. Just check in the editor.

I have checked it in the editor and there are 4 natives provided to do this.
JASS:
native GetWidgetX takes widget whichWidget returns real
native GetWidgetY takes widget whichWidget returns real
constant native GetUnitX takes unit whichUnit returns real
constant native GetUnitY takes unit whichUnit returns real
Both are usable on unit handles as a unit extends a widget handle.

I've tested for unit groups some more, they make a clear leak, doesn't matter if i destroy, destroy and nullify it, or use the set bj_wantDestroyGroup = true command. It is however still hard to say if it is just groups that leak, or just that they leak alot more than points do after destroyed.
I assume you are using some kind of debugger to check for leaks? Do remember that memory can only be allocated and freed in pages and sub-page allocation algorithms will only free a page if everything allocated on that page has been freed.

Also be aware you are after the Virtual Memory size of WarCraft III's process and not the working set size as the working set size is only the amount of memory allocated to it that is regularly used. Working Set might fluctuate over time and will sometimes remove entire pages that have leaked due to how the memory manager computes the working set. The Virtual Memory size of the WarCraft III process is the actual amount of memory that it owned by the process. Further more you might just want the Private Virtual Memory owned by the process as Shared Virtual Memory should have nothing to do with the game engine. The Private Virtual Memory size increases when new pages are allocated to the process (it needs more memory) and decreases when pages are freed (the page is no longer needed for storage).

Remember that WarCraft III caches art assets once loaded so you could consider a model that only appears once for a few seconds a memory leak and you can easily expect memory to increase as more art is used during game play.
 
Level 2
Joined
Jun 28, 2010
Messages
20
Thanks for your help, unfortunately i can't really get much out of it.

As for the points, like i wrote in a previus post I might have been wrong about them leaking after removed. However, the groups are the real problem. And i am completely sure that the increase of memory is not just an ordinary increase, since it keeps going up to more than twice the starting value, then i have to stop warcraft because of the lag, even though my computer can take WAY more than that. I've heard some things about "never to use BJ Groups", but i don't know how not to do that when using GUI. If it has anything to do with that i am obviusly using global variables for the groups.

I've tested running a trigger that creates and removes 50 unit groups every 0.01 seconds. I've tested both destroying, destroying and nullifying, using "set bj_wantDestroyGroup = true" and clearing, destroying then nullifying. But none of these seem to work! Destroying the group clearly decreases the lag, but there is still a lot of memory leak left. What i want to know is if there is yet another command I didn't know about before. Preferably one that can be used in GUI through custom script.

Finaly i want to inform you that I'm not using a debugger. I remove the memory leak myself. I have windows 7 so I couldn't get the leak check for warcraft even if i did trust it enough to use it in my maps.

Edit:
In my map, I've tested the memory leak though first playing untill the last round. Then dying and letting the mobs run around on the field for about 20 minutes. During these 20 minutes both the ingame lag and the memory usage is greatly increased, so it must be memory leak.
 
Level 2
Joined
Jun 28, 2010
Messages
20
I've tested some more, it seems like the memory usage is only going up when exploring the map if no triggers is activated. If you stay still it stays as it is. Howerver i also tested turning on and of the trigger that generates unit groups and destroys them in game. As expected the memory usage increased at a high rate while it was on, and stopped increasing when it was turned off. The important part is that it didn't go down to normal when turned off, this is yet another clear proof that it is memory leak.

Same goes for points. They also make memory leak even though they are removed, however, i create points at 20 times the rate that i create groups, and they still only do a very small memory leak compared to the groups.

Now that I've finnished proving my suspections where right, I will start searching for a solution to this problem.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Both strings and units leak. There is no fix for both leaks as they are game code related.
Unit groups can be fixed by recycling the same unit group (you do not have to create a new unit group each time like GUI forces on you).
Locations can be fixed by simply not using them or recycling the same location to get Z coordinates.
 
Level 2
Joined
Jun 28, 2010
Messages
20
I had actually already thought about the idea of using a few unit groups that i add units to as they are created, instead of making a new group every time. However, this would still not work when using unit groups like "Units within range of point", since these change all the time, and using a trigger that adds a unit to a unit group every time it comes within range of an other unit would still probably require alot of CPU. However using this method you could still reduce the amount of unit groups used from an avarage of 30 every 0.02 seconds to maybe 2 for every unit and dummy unit in a map like mine.

I dont quite get how you are supposed to reuse a location without creating a new one, but that might be a JASS command i don't know anything about. And like i said, i use GUI.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Yes, both the problems you describe above are GUI only.

The JASS script you are provided by WC3 to get units within a certain rage takes a unit group and fills it with the resulting units. The GUI facade for this native forces the creation of a new group every time but the actual mechanics means that for most tasks you will only ever need to use 1 single unit group.

The polar projection GUI function takes in a location which it disassembles into X/Y pairs that it uses simple trigonometry on and reassembles them as a new location. As most location creating natives have X/Y pair equivalents you can just skip locations entirely for most tasks. GUI for some reason forces you to use locations which is a huge source of inefficiency by itself.

I am afraid the only real way to resolve the problems you are having is with JASS. The GUI of WarCraft III was just too badly designed. In StarCraft II the GUI has been much improved and can do most things the scripting language can do.

Probably because they will do the cleaning next week.
Only specific personal have moderation permission over this forum. I advise contacting them instead of spamming off topic messages in this thread.
 
Level 2
Joined
Jun 28, 2010
Messages
20
Thanks alot Dr Super Good, now i at least know what to do. Too bad i have to learn Jass though. I am actually pretty used to programing through script in other programs, but those are programs like C++ where you build up the system from the begining, and i just thought it would be disturbing having to learn yet another language for world editor, when there is a much easier choise. Also it is going to take a while converting my entire map into script, but whatever, I would better just start as soon as possible. Once again, thanks for the help.

Try clearing the groups before destroying them. It is said that the references are not properly cleaned up by the destroy function and the group leaks more with more units in it. Also upload the map.

I think i wrote i had done that already... and it didn't work.

- There are bugs with wc3, but most of time, the bug is between the keyboard and the chair.
- Never believe some warcraft "fact" without a proof, even from an "experienced" user, that's how myths & legends born.
You spam "...", "lol", and smilies such as "; p", "^)^",">.>"? You think you're the best and all other ones are stupids or at least less clever than you ? You think your errors are funny, while the other ones are incredibly lame ?
Maybe you've too much ego,or worse, you're a douchebag

I don't really know if you are refering to me or if you are trolling (which seems pretty suspicius since your name is "troll-brain"), but if you check this forum the only such thing i did was one single sad smiley... which is by the way usefull to express how you feel. Also, what the hell do you know about me thinking others are stupid? I posted this simply to tell others about a possible problem, and to find a solution to that problem. I even wrote how i did my trigger, just test it yourself and you will most likely find that there is some kind of leak. And if you don't, then i might as well turn your own reference against you and say that you where the one that failed. I do however have a strong feeling that you may have used those lines over and over in different forums, and that you are just trolling. I try to evolve, while you just do something that helps nobody, exept for possibly making some assholes laugh.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
It's not about you ...
That's just a signature. Actually the second part if for Nestharus if you want know, while the two first sentences are general.
Btw you could also check the forum, i'm not trolling that much, regardless my pseudo.

Now, care to read the link i've given ?
 
Level 2
Joined
Jun 28, 2010
Messages
20
That is a stupid message to have after every line you do, you know that?
This is my first thread, so i didn't realize that was just some kind of epigraph, sorry dude, but it really caused some confusion.
 
Level 2
Joined
Jun 28, 2010
Messages
20
Didn't i say i thought you where trolling?

Edit: What the hell now? Did you edit your message or something? The only thing i saw in your first message was the link and the epigraph... That explains alot.
My fault for missunderstanding. I'm sorry.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Yes, but before assuming that, you could at least have check some of my posts.
Btw if i was really trolling, would you except that amout of rep or even messages ?
Plus, a signature is rarely directly adressed personnaly to the user above, hell that's how a signature work.

Now, let's stay on topic.
 
Level 2
Joined
Jun 28, 2010
Messages
20
Whatever, i didn't realize it was a signature, that was why i thought it was a troll.
This post is however solved. I believe the only solution may be, like Dr Super Good said, to learn Jass. But thanks anyway, and sorry again for missunderstanding you.

Edit: Now i just have to figure out how to set this as solved...
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Upload the map and we may identify the source of the leak more precisely. Switching to jass surely makes a lot of things more effective but I doubt that you would experience a major leak within 10min from a single part of code from just the hardcoded leak. The leak described in Troll-Brain's link is really minor. And maybe there is a better triggering approach in general. Fixing leaks is not the only possibility to optimize performance.
 
Level 2
Joined
Jun 28, 2010
Messages
20
I am very sure there is no leak that i've missed, and if you check what this thread was all about, you might realize that i the problem is this leak that stays after you remove the usual memory leak. There is some part of the variable that stays after it is removed, and the only way to get rid of that is to change to JASS and avoid using points and groups. My map uses a constant knockback system for everything, and thus have a trigger that runs 50 times per second to calculate the paths of every projectile and unit. That is why this minor leak, that can't be removed in GUI is a problem, and it will not be for the maps without these frequently running triggers. Also, my map will be playable untill about 30 minutes, however you can see the effeckts of the leak after about 15-20 minutes.
 
Status
Not open for further replies.
Top