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!
 
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)
 
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?
 
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.
 
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.
 
- 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.
 
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.
 
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 ;)
 
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.
 
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 ;)
 
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 The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/
  • The Helper The Helper:
    Happy Thursday!
  • Ghan Ghan:
    I'm not so sure, there's still a lot of Thursday left for it to become unhappy.
    +3
  • The Helper The Helper:
    still a few hours
  • The Helper The Helper:
    Its Friday!!!!
    +1
  • Ghan Ghan:
    Thursday 7/10 would Thursday again
    +3

      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