Execution: Custom Alert Mod (GUI now available)

All things /script related

Moderators: Fridmarr, Worldie, Aergis, _Chloe

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Mon Aug 17, 2009 9:41 pm

Alright. Evidently my problem with excess garbage is more serious than I thought. I thought it was my algorithm but I guess that actually had nothing to do with it (even though the new one is better anyway). I ran AddonUsage, commented out the part where the add-on does reactions, and you can just watch the add-on's memory usage get higher and higher as events come in. A quick garbage collect brings it back to normal size, though, so it must be a problem with my code.

If this WoWWiki page is correct, my strings, numbers, and booleans should be irrelevant, and this problem can only be occurring because of how I'm using my tables. It did correctly outline what I was doing wrong (creating a new table with each new event and then never using it again), but I believe I changed that and the problem is still happening. I double checked that all other variables used aren't tables, and that all other methods used don't generate tables, yet the add-on's garbage generation still seems to increase steadily with each event checked.

If anyone who knows anything about this subject would like to help out, you can grab the code here. The relevant blocks are the EX_OnEvent function and any function called therein. The OnEvent function is in Execution.lua but it does reference some functions in Ex_vars.lua.

EDIT: Right now I'm trying to comment out the different pieces to narrow it down.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Mon Aug 17, 2009 10:11 pm

I suppose disregard that last post. It ends up my excess garbage appears to be from how I'm using gsub. I was creating a new function for it to use every time (albeit a very simple function, still a function) which appears to be what's doing it.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Mon Aug 17, 2009 10:55 pm

Alright, so now I have a different problem. I'd like to be able to create new functions without excess garbage. One of the reasons this causes an issue is because my logical operator script works by making the expression into a string and loadstring'ing it. Evidently that creates a function, though, which is now creating garbage. Likewise, in my gsub function, I was using something simple like:

Code: Select all
extraFilterString = gsub(extraFilterString, argumentPattern, function(eachArgument) return tostring(checkArgument(eachArgument)) end)


Obviously that's a very tiny function, but it is technically creating a function each time, which appears to be adding to my garbage. That particular situation is easier to work around, but I'm having difficulty getting gsub to call a function with any parameters other than the ones it's found, which is another problem for me.

Bottom line: Is there a way to create a function or overwrite a function without creating extra garbage?

My add-on's memory usage continually grows to out-of-control levels in raid combat and drops FPS significantly.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby _Chloe » Tue Aug 18, 2009 1:09 am

Use local variables instead of globals?
User avatar
_Chloe
Moderator
 
Posts: 831
Joined: Fri Dec 07, 2007 6:36 pm
Location: Santa Monica, CA

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Tue Aug 18, 2009 3:59 am

_Chloe wrote:Use local variables instead of globals?


Hmm. In what sense? Like, here's one function that could cause problems. This particular one is more easily worked around but is clearer for showing you guys:

Code: Select all
function EX_CheckExtraFilter(extraFilterString)

   if extraFilterString == "" or extraFilterString == nil then return true end

   local argumentPattern = "[^&|()!][^&|()]*"

   extraFilterString = gsub(extraFilterString, argumentPattern, function(eachArgument) return tostring(EX_ExtraFilterHandler(eachArgument)) end)

   return EX_Evaluator(extraFilterString)

end


Slapping local in front of that function causes a compile-time error. Or do you mean defining the function locally beforehand, and then calling it there in the gsub? That might work. Brb trying.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Tue Aug 18, 2009 4:06 am

Doesn't look like it's doing it. I commented out the two other places it's happening before I tried it and it was still going up quickly in combat, then commented out where it was creating that function and it came back down to a steady memory usage in combat.

Or do you mean to set the function itself as local?
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby _Chloe » Tue Aug 18, 2009 5:14 am

In the WoW environment, local variables generally use up less memory and don't pollute the global namespace. If the function is declared local, then the functions it spawns should be local as well. Also are you checking to see if the function already exists or no?
User avatar
_Chloe
Moderator
 
Posts: 831
Joined: Fri Dec 07, 2007 6:36 pm
Location: Santa Monica, CA

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Tue Aug 18, 2009 5:22 am

_Chloe wrote:In the WoW environment, local variables generally use up less memory and don't pollute the global namespace. If the function is declared local, then the functions it spawns should be local as well. Also are you checking to see if the function already exists or no?


I went ahead and set the functions that create the local functions (like EX_CheckExtraFilter) as local but the problem is still happening. Normally are local variables garbage collected once the client leaves their block? I'm not sure what function I'd be checking to see if it already exists. The only one I redefine is the one in the gsub, and I'm not sure how or why I'd check if it already exists.

Now in-game, if I try to do /script EX_CheckExtraFilter() it'll tell me I'm trying to reference a global function that's nil, which is what it should do now that it's local to the add-on.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby Arees » Tue Aug 18, 2009 6:17 am

I wish I could help you modus. I could tell you all about Java garbage collecting... but thats not of much use. I do think Chloe is on to something though. It sounds like something isn't going out of scope when it should so its not being garbage collected. If I get a chance during my lunch break or something I'll look at the code some, but I'm afrad my limited LUA knowledge wont be much help.
Image
User avatar
Arees
 
Posts: 301
Joined: Tue Dec 25, 2007 9:50 pm

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Tue Aug 18, 2009 6:38 am

I talked to Chloe in vent and we took care of two of the three places that the excess garbage is being generated. I think the last has both of us stumped, and it's where it appears that using a loadstring to evaluate logical expressions is creating a function that sits in memory until it is garbage collected. I tried defining an addon-wide "placeholder" function and then changing that function to the loadstring's result, but that still creates the garbage. I'm hoping there's some solution that doesn't involve me writing my own function for logical evaluation.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Thu Aug 20, 2009 10:34 pm

moduspwnens wrote:I talked to Chloe in vent and we took care of two of the three places that the excess garbage is being generated. I think the last has both of us stumped, and it's where it appears that using a loadstring to evaluate logical expressions is creating a function that sits in memory until it is garbage collected. I tried defining an addon-wide "placeholder" function and then changing that function to the loadstring's result, but that still creates the garbage. I'm hoping there's some solution that doesn't involve me writing my own function for logical evaluation.


After a short discussion with someone else on WoWInterface's forum, I gave up on the loadstring and did write my own logical evaluation function. It's not as bad as I thought it would be now that I have somewhat of an understanding of regular expressions and gsub. Starting from version 0.19, it should no longer generate excessive garbage while parsing events.

It basically recursively calls itself on different parts of the expression until it's reduced to a simple "x or y" or "x and y", and then just evaluates those. Seems to be working. It doesn't follow order or operations, though, except basically grouping symbols and left to right. I may fix that later if it becomes an issue.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby Arees » Fri Aug 21, 2009 6:50 am

Sounds like you wrote some kind of recursive descent parser... good times =D
Image
User avatar
Arees
 
Posts: 301
Joined: Tue Dec 25, 2007 9:50 pm

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Sat Aug 22, 2009 12:51 pm

Radio buttons! I believe I've seen them, but do they exist? I don't see anything on the Widget API page, but I could be missing them or calling them the wrong name. Without them, I guess I'll just have to make a set of checkboxes that uncheck the other checkboxes when checked.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby fafhrd » Sat Aug 22, 2009 1:03 pm

Only mod I remember seeing that uses radio buttons had custom ones. But it had custom everything else for UI too.

Note that you can always do anything that a radio button does with a dropdown list, which I think is what most mods use instead.
ImageImage
1/1 Lore pre-nerf.
User avatar
fafhrd
 
Posts: 3156
Joined: Fri Aug 31, 2007 2:31 pm

Re: Execution: Custom Alert Mod (Now available for testing)

Postby _Chloe » Sat Aug 22, 2009 2:14 pm

See Tankadin2 options in the color section for a usage of radio buttons.
User avatar
_Chloe
Moderator
 
Posts: 831
Joined: Fri Dec 07, 2007 6:36 pm
Location: Santa Monica, CA

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Sat Aug 22, 2009 4:14 pm

_Chloe wrote:See Tankadin2 options in the color section for a usage of radio buttons.


Just checked over that. It looks like it's a set of checkboxes that uncheck the other boxes, only looking different (inheriting a different UI element). I suppose it is essentially the same kind of thing. Thanks!
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby _Chloe » Sat Aug 22, 2009 4:16 pm

No Problem.
User avatar
_Chloe
Moderator
 
Posts: 831
Joined: Fri Dec 07, 2007 6:36 pm
Location: Santa Monica, CA

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Sat Aug 22, 2009 4:43 pm

I am making some good progress on my GUI though. Sabin had me a little scared, and it was kind of annoying to pick up with all the WoWWiki tutorials being done in XML, but now that I have a fair grasp on it, it's not too bad.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Sat Aug 22, 2009 6:49 pm

If there happens to be someone to find this before I figure it out:

I have two different frames, and I need one to be on top of the other at all times. I know how to do this with layers, but I don't know how to do it with two separate frames. I found Frame:IsTopLevel() and Frame:SetTopLevel(), but it's telling me the method doesn't exist. I'm fairly sure I'm referring to a frame. Is this something that was changed recently or am I screwing up? Or am I down the wrong path anyway?
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby _Chloe » Sat Aug 22, 2009 8:25 pm

Frame:SetToplevel(true);
User avatar
_Chloe
Moderator
 
Posts: 831
Joined: Fri Dec 07, 2007 6:36 pm
Location: Santa Monica, CA

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Sun Aug 23, 2009 6:21 pm

_Chloe wrote:Frame:SetToplevel(true);


Welp, it's telling me the method doesn't exist, so I must have something wrong with my frame. I've got a workaround for now, so I'll come back to it later.

Another quick question: I'm about to get into my extra filter selection window, and I'm looking to make a checkbox with a little extended functionality. One example of an extra filter would be "in combat". The thing is, I want my user to be able to check the box (meaning "only do this rule while in combat") or X the box (meaning "only do this rule when NOT in combat"), or leave it blank (meaning do this rule either way). I think I've seen something like this before. It's something I could implement, but I think it may be a template or something I've seen somewhere else.

Anyway, here are some screenshots of the functional parts of the GUI.

Image
Image
Image
Image

I think it looks pretty good. Done completely in Lua. Let me know if anyone has any feedback.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby moduspwnens » Mon Aug 24, 2009 6:22 pm

moduspwnens wrote:Another quick question: I'm about to get into my extra filter selection window, and I'm looking to make a checkbox with a little extended functionality. One example of an extra filter would be "in combat". The thing is, I want my user to be able to check the box (meaning "only do this rule while in combat") or X the box (meaning "only do this rule when NOT in combat"), or leave it blank (meaning do this rule either way). I think I've seen something like this before. It's something I could implement, but I think it may be a template or something I've seen somewhere else.


Well, my first step in implementing this would include making a template, but it appears that to make a template, I need to make a virtual frame. I can't figure out how to do that without XML tagging it as virtual.
I rule.
moduspwnens
Moderator
 
Posts: 3382
Joined: Tue Nov 06, 2007 12:28 pm
Location: Shattered Hand

Re: Execution: Custom Alert Mod (Now available for testing)

Postby _Chloe » Mon Aug 24, 2009 11:40 pm

moduspwnens wrote:
moduspwnens wrote:Another quick question: I'm about to get into my extra filter selection window, and I'm looking to make a checkbox with a little extended functionality. One example of an extra filter would be "in combat". The thing is, I want my user to be able to check the box (meaning "only do this rule while in combat") or X the box (meaning "only do this rule when NOT in combat"), or leave it blank (meaning do this rule either way). I think I've seen something like this before. It's something I could implement, but I think it may be a template or something I've seen somewhere else.


Well, my first step in implementing this would include making a template, but it appears that to make a template, I need to make a virtual frame. I can't figure out how to do that without XML tagging it as virtual.


Just make a cycling button for it. Default it's either way, one click does it only in combat, next when not in combat, and just make it change the text and/or tooltip.
User avatar
_Chloe
Moderator
 
Posts: 831
Joined: Fri Dec 07, 2007 6:36 pm
Location: Santa Monica, CA

Re: Execution: Custom Alert Mod (Now available for testing)

Postby Sabindeus » Wed Aug 26, 2009 2:45 pm

moduspwnens wrote:I am making some good progress on my GUI though. Sabin had me a little scared, and it was kind of annoying to pick up with all the WoWWiki tutorials being done in XML, but now that I have a fair grasp on it, it's not too bad.


you're a better man than I, gunga-din.

Maybe the next time I find myself with copious free time (read: unemployed) I'll try doing a UI in Lua and see how it feels.
Image
Turn In, an NPC interaction automator - http://wow.curse.com/downloads/wow-addo ... rn-in.aspx
User avatar
Sabindeus
Moderator
 
Posts: 6070
Joined: Mon May 14, 2007 9:24 am

Re: Execution: Custom Alert Mod (Now available for testing)

Postby Arees » Wed Aug 26, 2009 2:49 pm

I see version 0.19 as being the latest on wowinterface... is that still right? I think I'm going to have some time this week to test it.
Image
User avatar
Arees
 
Posts: 301
Joined: Tue Dec 25, 2007 9:50 pm

PreviousNext

Return to Add-ons, UI, and Macros

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron

Who is online

In total there are 2 users online :: 1 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 380 on Tue Oct 14, 2008 6:28 pm

Users browsing this forum: Bing [Bot] and 1 guest