| 06-01-2006, 02:32 PM | #1 |
OK, just a quick question here. I'm currently going over the triggers which I have in my project so far, and cleaning up any memory leaks I am finding, but it seems I'm having to make an awful lot of variables just to clean them up, what with locations of various chat triggered pings and so forth. So what i was really wondering was wether tonnes of variables affect in-game lagginess? Also, can you remove specific arrays using the "Call RemoveLocation(udg_(LOCATION))" custom script, e.g: Call RemoveLocation(udg_Location(ARRAY)) Or could I just use one location variable and then use it in all the triggers I need a ping or whatever, just setting it and clearing it each time? My only thought was that if two players try and do something which involves the variable being set at the same time, it might screw up? -Cheers |
| 06-01-2006, 02:41 PM | #2 |
why exactly do you need a lot of variables? Most of the times you'd only need 2 or 3 |
| 06-01-2006, 02:44 PM | #3 |
Well, that was part of my question, wether I can use just 1 location variable, and use it in all the triggers I have involving a ping or a camera pan etc, just by setting it to somewhere new and then destroying it each time? |
| 06-01-2006, 02:55 PM | #4 |
Well it depends. I guess the best way to explain would be if you post an example of your current ways of cleaning locations and then we correct it if we can |
| 06-01-2006, 02:56 PM | #5 |
Yes, you can, as long as the values are only temporary. And this piece of code in your post: JASS:Call RemoveLocation(udg_Location(ARRAY)) Has errors. It should be 'call', not 'Call', JASS is case sensitive. And you wrap [] and not () around the array index. |
| 06-01-2006, 03:00 PM | #6 |
OK, well here's what I put into the leak checker and the result it gave me: ------------------ (Line:1) Bank (Line:2) Events (Line:3) Player - Player 1 (Red) types a chat message containing -Bank as An exact match (Line:4) Player - Player 2 (Blue) types a chat message containing -Bank as An exact match (Line:5) Player - Player 3 (Teal) types a chat message containing -Bank as An exact match (Line:6) Player - Player 4 (Purple) types a chat message containing -Bank as An exact match (Line:7) Player - Player 5 (Yellow) types a chat message containing -Bank as An exact match (Line:8) Player - Player 6 (Orange) types a chat message containing -Bank as An exact match (Line:9) Player - Player 7 (Green) types a chat message containing -Bank as An exact match (Line:10) Player - Player 8 (Pink) types a chat message containing -Bank as An exact match (Line:11) Player - Player 9 (Gray) types a chat message containing -Bank as An exact match (Line:12) Conditions (Line:13) MapPurchased[(Player number of (Triggering player))] Equal to True (Line:14) Actions (Line:15) Set PingLocation = (Position of Stonebridge Bank 0099 <gen>) (Line:16) Cinematic - Ping minimap for (All players matching ((Triggering player) Equal to (Matching player))) at PingLocation for 10.00 seconds (Line:17) Custom script: call RemoveLocation (udg_PingLocation) ------------------ Total lines: 17 Location variable has not been removed: PingLocation Completed Total amount of leaks: 0 Leak Rating: Excellent ------------------ |
| 06-01-2006, 03:04 PM | #7 |
What about posting a trigger where you use plenty of locations? Also better use Copy as text from the trigger editor and [trigger] tags when pasting the trigger here |
| 06-01-2006, 03:09 PM | #8 |
I don't think you can do that because once you call remove location, it tells the garbage collector to throw it out. Everytime you do that, you would have to re init that variable to use it again - which is why usually only clean up leaks in mid game on local variables which you will never use outside of its scope anyway. |
| 06-01-2006, 03:10 PM | #9 |
Leak checker is buggy. Combine it with your own disgression. |
| 06-01-2006, 03:11 PM | #10 |
OK, if I can find one lol. Also, I have special effects overhead units using the exclamation and question marks, I want the effect to stay for the duration so I'm guessing they can't be cleaned? P.S. Yes I know the leak checker is buggy, it sometimes uses exactly the same action that I have as a solution, should I just ignore it in these cases and leave it as it is? |
| 06-01-2006, 03:45 PM | #11 | |
Quote:
Unfortunatly, there is no garbage collector for Jass, most other languages have them, but Jass dosent, you have to do everything manually |
| 06-01-2006, 04:08 PM | #12 |
You don't have to re-init global location variables after you remove them. |
| 06-01-2006, 04:09 PM | #13 |
The best leak checker you can ever have is common sense. Knowing what creates leaks is your best defense, and yeah that chunk of code would be leakfree. |
| 06-01-2006, 06:28 PM | #14 |
Here's a hint for your location problem. Use coordinates instead of locations, they're real so you don't need to nullify them AND you can typecast them to locations if you seriously need to. |
| 06-01-2006, 09:55 PM | #15 |
Hmnn well you don't need a new point variable if you will destroy the location immediatelly after using it. You can always use the same temploc variable |
