| 04-04-2006, 09:35 PM | #1 | |
In the documentation for function CollisionMissile_Create: Quote:
Yeah, it is really stupid that a unit cant be set to instantly change facing angle. After I once did a test where I created and instantly removed a lot of units and discovered War3 never really recovers all memory a unit uses, I started worrying about creating a whole lot of new casters. I have an idea that might work, but I want what you think about it. I don't know how you would implement this, so this is only an example: Let's say there are 8 unit groups: N, NE, E, SE, S, SW, W, NW. Every time a caster is recycled, you add it to whichever of these 8 groups has the least members, and set it's facing to the facing of the group. Whenever a caster is needed that already faces approximately a direction, you pick from one of these groups. If the group is exhausted, and thereby empty, create a new caster. A new projectile would never be more than max 22.5 degrees wrong initially (which is hardly noticable), and in return, maybe this would increase the recycleability for casterunits? |
| 04-04-2006, 10:31 PM | #2 |
I made my own tests a long ago and creating / removing units does not cause leaks, seriously |
| 04-05-2006, 08:13 AM | #3 |
How did you do your test? I did: JASS:function test takes nothing returns nothing call RemoveUnit(CreateUnit(Player(0), 'hfoo', 0, 0, 0)) endfunction And then Trigger: The above trigger runs for the first 60 seconds of the map. Watching memory usage in real-time using an external program, I see War3 use more and more memory until 60 seconds has elapsed, after which it stops using more memory, but certainly does not release any memory. War3 will after 60 seconds of the above code use 94080 Kilobytes of memory on my machine, and the same map with the above trigger set to disabled, will use 86180 Kilobytes after the same 60 seconds. The amount of memory used does not change even if I let the map do nothing for 10 minutes. |
| 04-05-2006, 10:28 AM | #4 |
It doesn't leak. Your memory use floats up and down from stuff caching but warcraft doesn't lose reference to it. It will deallocate after a some MB, as you observe when the use flattens out or starts a stable oscillation. Edit: Of course, loading a certain unit type does in some sense (probably) leak, if you're never going to use a unit of that type again. |
| 04-05-2006, 12:09 PM | #5 |
you are doing much more things than you should in that test like using globals for the loop (boo GUI!) and calling an extra non-native function, anyways in my test the memory got increased but eventually stabilized, seems war3 takes sometime to clean the resources related to a unit, perhaps a garbage collector kind of thing, but it does not leak. |
