• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Does this leak?

Status
Not open for further replies.
Hello guys,

This is like the 100th edition of me asking about leaks to double check. So please bear with me. :p

1) Using Target of current camera view like this? (This was used in the campaign maps)

  • Sound - Play Earthquake <gen> at 100.00% volume, located at (Target of current camera view) with Z offset 0.00

2) So, should i use this:

  • Set TempPoint = (Target of current camera view)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Region100 <gen> contains TempPoint) Equal to True
    • Then - Actions
      • Sound - Play Sound at 100.00% volume, located at TempPoint with Z offset 0.00
      • Custom script: call RemoveLocation( udg_TempPoint )
    • Else - Actions
or just this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Region100 <gen> contains (Target of current camera view)) Equal to True
    • Then - Actions
      • Sound - Play Sound at 100.00% volume, located at (Target of current camera view) with Z offset
    • Else - Actions

3) Using a condition like this, does it count as a group leak?

  • (Number of units in (Units in Region 215 <gen>)) Greater than or equal to 1

4) If i wanted to make a Two Plate Puzzle like they did in the campaign in UndeadX07c, where you have to press both plates at the same time. (the plates work like push-buttons)
Can i rely on this?:

(Checking if there are units on the plate)
  • Events
    • Time - Every 0.10 seconds of game time
  • Conditions
    • (Number of units in (Units in Region 216 <gen>)) Greater than or equal to 1
  • Actions
(Checking if there are items on the plate)
  • ((Random item in Region 216 <gen>) is in Region 216 <gen>) Equal to True

5) I noticed that when i start a game, Warcraft uses about 280mb and after a while of playing the map, the RAM usage gets up to 340mb and sometimes more. Does that necessarily mean that the map has memory leaks?

I ran a little test with my map, in 20 min of doing nothing the reserved memory for Warcraft 3 went from 280mb to 315mb. So, i disabled all 8 triggers that i spoke about in Question 4, and in 20min test the Ram usage went from 280mb to 295mb. Does that mean that these 8 triggers leak or might just be a coincidence?
(The triggers are like the ones from Question 4, they use a periodic event to check if there are units in a region, there are no group or point leaks in the actions.)

6) Aside from memory leaks, do periodic events (like every 0.10sec) exhaust the CPU or cause trouble?

Please let me know what you think guys and if there are any issues with the triggers.
Thank you. :grin:
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
  1. Yes. It's a point. Any point you don't re-use or remove is a memory leak. Any point.
  2. See above.
  3. Yes. Any group you don't re-use or remove is a memory leak. Any group.
  4. You want the plate to be triggered by items? If yes, check "Random item in Region 216 <gen> not equal to No Item"
  5. Yes it seems you are periodically leaking a group in the trigger.
  6. No.
 
Level 8
Joined
May 21, 2019
Messages
435
5) I noticed that when i start a game, Warcraft uses about 280mb and after a while of playing the map, the RAM usage gets up to 340mb and sometimes more. Does that necessarily mean that the map has memory leaks?
Climbing memory usage is often indicative of a memory leak. However, it isn't always the case.

Since you say that you've asked a lot about memory leaks, I wanna try to explain the concept to you, so you may figure this out yourself:

The game uses your memory to store information. If you create 100 units using a "leakless trigger", your memory will still climb, as there's now 100 units in the map that the game has to keep track of. Once those 100 units die and fully decompose, the memory should be cleared back up (although apparently units leak a tiny amount of memory which can't be prevented, but don't worry about that).
Memory leaks are different from memory usage, in that it's the game keeping track of something that is irrelevant to the game. It'd be more accurately described as having garbage cluttering up your memory. So the basic concept behind clearing memory leaks is to clean up useless data. In this game, that means that every time the game uses something like a Unit Group or a Point, you have to delete those yourself, once you are done using them. The tricky part to some people, is understanding that actions like "Pick every unit in", actually stores the information it finds in a Unit Group.
It's rather easy to build an intuitive feel for this, by simply asking yourself, if it looks like you're asking the trigger to gather information for you, or if you are pointing it towards the information explicitly. If you are telling it to do something with a piece of information, like "Kill this unit", then you are giving it "this unit", and thus, you aren't asking it to gather up any data. However, if you were to ask it to "kill every footman", you are asking it to go out and find every footman, and store that in a group.

Points are a rather tricky part of this, since many don't realize that a point is actually a piece of data in itself. This means that "center of region" actually generates a point at the center of said region. So if you were to run something that uses the center of a region 1000 times, you'd have 1000 points laying in your memory, since you are asking the game to find the center every time. This leaves you with 2 solutions: Delete the point every time you are done using it (preferably for points that may change, or aren't used again) or save the point in a variable (preferable if you use the exact same point a lot in very rapid intervals).

6) Aside from memory leaks, do periodic events (like every 0.10sec) exhaust the CPU or cause trouble?
Well, yes and no.
Periodic events can easily become very volatile to the game's performance, but they can also be harmless.
The general gist, is that basic computation is extremely fast. Computers can crunch numbers, text, and what have you really really fast.
So, what begins to present itself as a problem, is when you are using heavy functions. It's hard to pin down exactly what those are, as certain things can pull a lot more resources than you'd expect, because performing a certain action triggers a ton of underlying stuff in the game itself. In general, anything that interacts with the visible part of the game, is going to be heavier to execute. If you start piling those up excessively, they are going to have an impact on the performance of your game. In general, it's good practice to disable any periodic event that isn't relevant. This is a good mindset to have in any kind of development: Never use any more resources than you have to.
In the reality of todays borderline supercomputers, it's very very hard to push an old game like Warcraft 3 to a point where your computer will struggle to keep up, and if it's the case, it will be easy to see.
 
Status
Not open for further replies.
Top