Memory leaks are killing me..

KingJohn

New Member
Reaction score
0
Okay guys, I'm working for at least 15 hours on that son of a ***** spell, and it won't work. Specifically, it does the first time, but won't every next time, so there must be memory leaks. Unfortunately, I don't know much about them yet, and so I would humbly ask for help.
What the spell does:
Sucks every foe unit in a radius about 500 around the caster towards the caster. Quite simple, but very hard to do for me.

Here are the triggers:
Setup
Pulling

And here are the memory leaks destroyer I used (I implemented them by Wait 2 seconds - run trigger to make absolutely sure, they will be triggered):
Memory Leak

I know it's exhausting to think your way into new triggers you didn't write yourself, it would be very kind if you'd make the effort.

Thank you!
 

keychup

Active Member
Reaction score
34
Be creative.

Trigger 1:
Event: A unit Starts the Effect of an ability
Condition: Ability Being Cast is Equal To Disroot
Action:
- Set PointVariableA = Position of Casting Unit
- Create Dummy unit at PointVariableA
- Custom Script: call RemoveLocation (udg_PointVariableA)
- Add Last Created unit to DisrootGroupVariable

Trigger 2:
Event: Every 0.05 seconds
Condition:
Action:
- Pick every unit in DisrootGroupVariable:
-- Set DummyUnit = Picked Unit
-- Set PointVariableA = Position of DummyUnit
-- Set TargetGroupVariable = Units within 500 of DummyUnit matching conditions: (Matching unit is alive/an enemy of Owner of DummyUnit/ not a structure)
--Pick every unit in TargetGroupVariable:
----Set PointVariableB = Position of Picked Unit
----Set PointVariableC = PointVariableB offset by 10 towards angle from PointVariableB to PointVariableC
---- Custom script: call SetUnitX(GetEnumUnit(), GetLocationX(udg_PointVariableC))
---- Custom script: call SetUnitY(GetEnumUnit(), GetLocationY(udg_PointVariableC))
---- Custom Script: call RemoveLocation (udg_PointVariableB)
---- Custom Script: call RemoveLocation (udg_PointVariableC)
-- Custom Script: call RemoveLocation (udg_PointVariableA)
 

Imp Midna

Active Member
Reaction score
52
Specifically, it does the first time, but won't every next time, so there must be memory leaks.

I dont get your point. You mean, memory leaks suddenly destroy spells? Where did you get this idea from? Memory leaks dont affect your actual trigger at all, in fact, the charactaristica of a leak is that there is no way to access the memory again and thus i can not modifiy any aspect in your map in any way anymore. So, how would it be able to actually destroy a spell?

Looking through your trigger, i do see a lot of memory leaks, but you really have to clarify what you want from us, because the memory leaks in your trigger (i didnt look at them yet) and the fact that they are not working are thery unlikely to correlate. So tell us: do you want us to fix your spell or do you want us to point out the leaks?
 

KingJohn

New Member
Reaction score
0
I dont get your point. You mean, memory leaks suddenly destroy spells? Where did you get this idea from? Memory leaks dont affect your actual trigger at all, in fact, the charactaristica of a leak is that there is no way to access the memory again and thus i can not modifiy any aspect in your map in any way anymore. So, how would it be able to actually destroy a spell?

Looking through your trigger, i do see a lot of memory leaks, but you really have to clarify what you want from us, because the memory leaks in your trigger (i didnt look at them yet) and the fact that they are not working are thery unlikely to correlate. So tell us: do you want us to fix your spell or do you want us to point out the leaks?
Oh, well, I think, I was mistaken. I had the idea, a "memory leak" occurs, when a variable is not resetted and thus having the wrong value when you run the trigger another time. I've learned the correct form of what a "memory leak" is now. My bad.

I have forgot to point out that the spell is only casted by one unit, so the trigger don't need to be able to run for several units/players at one time.
I would want you to fix the spell, so it will work properly every time. It does the first time, though.
Here is my latest version of the whole second trigger.
I know, you will shake your head in disbelief because of the
- Wait 2 seconds
- Performing newby attempts to remove memory leaks
but I can't do it any better by now.

It all works pretty fine, except for the Lightning Effects:
The first time a cast the spell, everything is fine.
The second time, a lightning is created to the center of the map, denoted with the red 1.
The third, forth and fifth time, (denoted with 2, 3 and 4) the lightning effect is also created from the point of the caster to the center of the map. It seems to get fatter every time.
I hope, this does help?
Picture

Be creative.
I'm working on copying your version now, maybe it will help.
 

Imp Midna

Active Member
Reaction score
52
Ok, this is a extremly long trigger that is hard to understand so i tried to copy it and look if my trigger would show the same behavior. But it didnt. What happened in my version was, that:
- the lighnings didnt get removed because, in the picture, you forgot to write them into the lightning variable in the periodic trigger where you move the target and create a new lightning
- that the whole process stopped for every unit when one single unit reaches me which totally does make sense though i think its not what you wanted
- apart from that, it works perfectly, no matter how often i use it. I can not reproduce the bug you got.

Thus, i can only ask: are you sure that the part you didnt show us does not alter any variable that is used in there? Because i can not see a locical flaw in your trigger, nor do my tests show me any. Try to remove every other part of your trigger and look if it still doesnt work.
 

KingJohn

New Member
Reaction score
0
- the lighnings didnt get removed because, in the picture, you forgot to write them into the lightning variable in the periodic trigger where you move the target and create a new lightning
Yes, that's true. It worked for me though, I don't know why. Now I implemented that, my problem still exists.
- that the whole process stopped for every unit when one single unit reaches me which totally does make sense though i think its not what you wanted
Doesn't do so in my map, neither. Of course that wouldn't be my intend, if they would stop to be moved towards the caster, when the first unit reaches it.
Thus, i can only ask: are you sure that the part you didnt show us does not alter any variable that is used in there? Because i can not see a locical flaw in your trigger, nor do my tests show me any. Try to remove every other part of your trigger and look if it still doesnt work.
I really appreciate your effort, you even copied my complex trigger. I really don't want to bother you or the community anymore, so this is my last try:
Here is everything that has to do with the spell. It does look very long by the first look, but it isn't, there is just one loop for every level (left trigger).
If you still have the nerves to help me and see something, which may cause this error, it would be great if you could point it out. If you know a multiple pull system someone else has created, you could link me to it, it would be fine too. I found nothing properly on hiveworkshop, even made my trigger on base of a Butcher-Hook spell.
Thank you again for your efforts.
 

keychup

Active Member
Reaction score
34
How's my version of the triggers working for you?
Remember that the variables in my trigger must not use Indexing.
Also if the Dummy Unit dies that unit should be removed from the game and from the unit group.
This way you can set the duration of the spell by setting the expiration timer for the dummy unit.
Also Lightning Effects should be individually set.
One way is to create a specific lightning effect for each target unit and save it into a variable but i think that it would be better to create another dummy unit for each target and make it cast Aerial Shackles.
It should have an expiration timer equal to the main dummy.
But you wont be able to color the lightning unless you overwrite its texture with a recolored one using photoshop and such.
Importing a lightning effect also allows you to change the shape of the lightning effect.
 

Imp Midna

Active Member
Reaction score
52
So, im quoting my own post to clarify some things:

- the lighnings didnt get removed because, in the picture, you forgot to write them into the lightning variable in the periodic trigger where you move the target and create a new lightning
-> fixed in your trigger it seems

- that the whole process stopped for every unit when one single unit reaches me which totally does make sense though i think its not what you wanted
-> my bad, i replaced some vars with the wrong when upon copying it

- apart from that, it works perfectly, no matter how often i use it. I can not reproduce the bug you got.
-> i did not exactly copy it, but i spared out some variables that seemed unneccasary to me, and funnily, that fixed the bug.

Now, i brought my trigger to work (well, "work", it showed a behavier similar to yours). I added some test outs to see whats happening and i think i found your mistake which is so horrifically simple that it bugs me that i did not see it: The Target Group is not cleared. It stays the same and the old units seem to stay in it while the unit array is cleared. Casting your spell the next time you will only add more units to it, not removing the old ones. I used to use the array counter in the periodic trigger and completely ignored that group since it seemed unneccasary to me which is why my trigger worked. You do use the size of this group in your for loop, so the loop trys to go through the array searching for the units from the last time you castet the spell too. Since there is no Location in the array, it takes the default location to chain the lightning on, which is the maps center. Also, it will create more and more lightnings the more you cast the spell and the more units are in the group, which is why your lightning semms to get brighter.

Suggestions:
either: remove the unneccasary variables (namingly the prev counter you dont use, the group and replace the actualgroupcounter by the array counter)
or: just clear the group in the wait 2 seconds part.

EDIT:
Ah, and before i forget, you might consider deactivating that trigger (Trigger - Turn Trigger off) when you dont need it (means after the 2 seconds wait) and turn it on again when you need it (means, in the setup trigger). I usually wouldnt bother you with such things because you obviously are new to triggering, and pointing out what is possible with the trigger editor is pointless since you wont learn it on this way (its faster if you learn it by doing imao) but this one seems pretty lethal to me. Just note that 0.05 seconds is not much and though you might not see it, a slow computer other the internet in a big map could get problems if this trigger is permanently running. So, just a pretty general tip here: Turn off periodic Triggers when you dont currently need em. Thats all ;)
 

KingJohn

New Member
Reaction score
0
The Target Group is not cleared. It stays the same and the old units seem to stay in it while the unit array is cleared. Casting your spell the next time you will only add more units to it, not removing the old ones. I used to use the array counter in the periodic trigger and completely ignored that group since it seemed unneccasary to me which is why my trigger worked. You do use the size of this group in your for loop, so the loop trys to go through the array searching for the units from the last time you castet the spell too. Since there is no Location in the array, it takes the default location to chain the lightning on, which is the maps center. Also, it will create more and more lightnings the more you cast the spell and the more units are in the group, which is why your lightning semms to get brighter.
This does totally make sense to me. My problem was: I initially thought about clearing it, but I used the custom script "call destroygroup", which caused the spell to do just nothing any another time after the first time casted. I saw this function in a different trigger and just used it, is it possible that the whole variable is "destroyed" somehow and can't be valued again after the first time? Would be great if you could show me the right function.

Suggestions:
either: remove the unneccasary variables (namingly the prev counter you dont use, the group and replace the actualgroupcounter by the array counter)
or: just clear the group in the wait 2 seconds part.
I will do the first, if the unit group cleaning won't work. Just for experience, I'd like to try the second way too.

EDIT:
Ah, and before i forget, you might consider deactivating that trigger (Trigger - Turn Trigger off) when you dont need it (means after the 2 seconds wait) and turn it on again when you need it (means, in the setup trigger). I usually wouldnt bother you with such things because you obviously are new to triggering, and pointing out what is possible with the trigger editor is pointless since you wont learn it on this way (its faster if you learn it by doing imao) but this one seems pretty lethal to me. Just note that 0.05 seconds is not much and though you might not see it, a slow computer other the internet in a big map could get problems if this trigger is permanently running. So, just a pretty general tip here: Turn off periodic Triggers when you dont currently need em. Thats all ;)
Yes, I will do it. Also makes sense to me.
Thank you very much for you help.
Now it will work in either the one or the other way.

@keychup
I wasn't finished with it yet, since it is a whole new trigger with new units.
I guess it will work too, but I don't know if it's good for fluent gameplay to create so many units at once.
 

Imp Midna

Active Member
Reaction score
52
I saw this function in a different trigger and just used it, is it possible that the whole variable is "destroyed" somehow and can't be valued again after the first time? Would be great if you could show me the right function.

Its true, Destroy Group will literally destroy your entire group. To use the variable again, you have to create a new group, either by the CreateGroup() function or by doing something like set group = (units within 300 of some unit) which will also create a new group. Its meant to destroy groups after you dont need them anymore. You do, however, still use your group (you fill units in it) so there is no need to destroy it, you just have to clean it up (make it empty). You can find it in Unitgroup - Clear, right above the Unitgroup - Destroy you used to destroy it ;)
 

KingJohn

New Member
Reaction score
0
Its true, Destroy Group will literally destroy your entire group. To use the variable again, you have to create a new group, either by the CreateGroup() function or by doing something like set group = (units within 300 of some unit) which will also create a new group. Its meant to destroy groups after you dont need them anymore. You do, however, still use your group (you fill units in it) so there is no need to destroy it, you just have to clean it up (make it empty). You can find it in Unitgroup - Clear, right above the Unitgroup - Destroy you used to destroy it ;)
Oh my holy goodness, it finally works! I'm nearly bursting out in tears. You made it. Jetzt sehe ich gerade, dass du auch aus Deutschland kommst. Hätten wir das auch einfacher gestalten können :D Aber so können die anderen wenigstens mitlesen. Vielen Dank für deine Hilfe.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top