undef
How important is undef?
Just from other peoples examples, I've used $variable = undef; but now I'm seeing undef $variable; Is either ok? Which is the proper way? Do I use it for just qglobals or any my $variables? Is it important, such as freeing up memory? Sorry for the noob questions lol. Trying to optimize my quest files. And would this be a possible cause of a zone taking up more RAM the longer zone is up? -Thanks |
Unless you were using a TON of variables, I don't think that would effect memory at all. You should really only need to undef them if you need to clear them out for some reason so they don't get used later on. Like, if you have an NPC do something and set a variable and you use that variable for an event or something for a particular player, you might not want that variable to be set the next time that event starts or the next time another player interacts with that NPC. You shouldn't really need to use undef on qglobals as long as you are using $qglobals{qglobalname} in your scripts and not just pulling qglobal information with variables named the same as your qglobal. You can check if a qglobal is not defined by doing a (!defined(qglobals{qglobalname})), and so on.
I am certainly no perl expert, so, I might be wrong, but that is my understanding of the answers to your questions. |
Maybe I'm doing globals wrong, with setglobal then my $variable = globalname; I'm trying to figure out why sometimes Anguish uses 1 gig ram after 12 hours of raiding etc. Been google searching for answers too.
|
Here is example of quest in Anguish, maybe memory leak for not enough undef? Every one of the 17 Bosses have a similar script:
For Overlord_Mata_Muram: Code:
##################################################################### Code:
##################################################################### Let me know if you see anything wrong. Thanks. |
Unless you need other scripts to be able to access your variables, you should consider using my for all of your defined variables. This will cause them to be erased from memory once the script is done running (read: mob is dead).
You may actually need to declare them out of the subs so that you can access them throughout the script, but it doesn't bleed over into other scripts (potentially leaking memory). Example: Code:
##################################################################### Code:
##################################################################### On a somewhat unrelated note, you may want to consider changing the sub EVENT_ATTACK section for the Overlord to use arrays & for loops to make it simpler since you're doing the same thing for each of them (like maybe 8 lines total for n number of mobs?) |
Yeah, other than the one qglobal you are setting, I don't see anywhere that you are pulling qglobal information in those scripts, just a bunch of variables. If you do ever need to pull qglobal values, just make sure to use the $qglobals{killed_overlord_mata_muram} way to do it instead of $killed_overlord_mata_muram. For example:
This is the correct way: Code:
if (defined($qglobals{killed_overlord_mata_muram})) { Code:
if ($killed_overlord_mata_muram == 1) { Also, if you think the memory problem might be quest related, try enabling quest logging in your log.ini file and then check out your quest logs. If the quest log is getting flooded by errors, that could definitely cause some issues. |
Thanks very much!
I will try using "my" outside of the sub and see if that makes a difference. I'll probably have to revamp a lot of quest I have to use qglobal the right way now. I learned a bit how to do stuff the right way now. I appreciate the help. Yes, I agree that the aggro can be compiled with arrays and for loops. I got lots of quest to edit now heh. More than just Anguish, but Anguish was biggest problem so I'll start there. |
Also, how important is undef? Or does "my" take care of everything for removing variable from memory?
|
Quote:
|
I just made the changes and test. First I cleared the respawn times table, and respawned the whole zone. Then I did a #reloadquest, then end process on the zone, then the (static) zone connected again 5 seconds later. I went in the zone and did a #repop many times, then #aggrozone and killed the whole zone. The Memory never went above 11 megs. Might be fixed, will have to wait until a guild raids it, cause it used to easy go over 1 gig of ram just for Anguish in one day. Might fix all my other custom quest in other zones if this works nicely. Appreciate your help.
|
Users are raiding Anguish again, and the zone is already up to 250 megs of memory. I've already corrected the quest files and rebooted the server, so I don't know. Qvic is my 2nd biggest problem, but doesn't grow up to 1 gig ram like Anguish does. Sigh.
|
Have you tried enabling quest logging in your log.ini file?
Here is what I have my log.ini set to atm: Code:
CHAT=on Other than that, a work-around for your problem might be to set the zone to do a daily reset using my Zone Reset Script posted in the custom quest section of the forums. Resetting the zone should clear out any RAM usage. |
I'll set the logs on, thanks much!
I was thinking last resort is rebooting Anguish with that quest we used when we were on windows. I still have it. The raid is set up that trash and bosses are all 24 hour respawn, and they can't skip around since higher bosses will aggro a lower boss. So its basically a 24 hour raid. So I wouldn't want to reboot every two hours. Maybe every 12 or 24 hours. Since I did the quest edits, and similar to qvic, our 2nd worst memory hog, after being up all night, Anguish is only taking up 507 megs, not over 1 gig, and Anguish is only taking up 87 megs, not 150-450 megs. So looks to be a bit better. Will check out the logs. I appreciate the help. -Hunter |
I'm seeing this come up in the logs for Anguish many many times:
"[Quest] Use of uninitialized value $qst2700501::races in concatenation (.) or string at quests/anguish/2700501.pl line 15." refering this this line of quest code: Code:
my $Phrase5 = "It's ${races}s like you who have ruined your own lands, You'll not Anguish!"; Also, turning on quest logging to see what else shows up. |
Another thing I saw in the logs:
9845 [07.30. - 22:38:48] Path File ./Maps/anguish.path not found. So I checked my /Maps/ dir and found a.. the *.map but no *.path, could that be a problem? |
All times are GMT -4. The time now is 12:04 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.