Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-26-12, 01:27 AM   #1
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Issue with endlessly increasing addon memory

Good Evening everyone,

I wanted to inquire about an issue I am having with an addon I am creating/modifying.

I used to use Shadowed's DamnChatTabs addon to hide the chat frame tabs, but considering I never utilized it to toggle tab visibility, just hiding them, I decided to cut the saved variables out, and bring it up to current standards (getglobal() being deprecated and the like).

Everything is going....well, it works fine, but whenever I mouseover the chat window, the addon memory increases by around 30kb every time, and I can cause this to continue infinitely. After a while it does return to a reasonable level (never less than after I first log in/reload the UI).

Can anyone shed any light on why the memory continues to increase with no end?

Lua Code:
  1. --[[
  2. Nearly -ALL- credit goes to Shadowed's DamnChatTabs addon.
  3.  
  4. I have stripped the code down, and modified it -SLIGHTLY- to disable
  5. all chat tabs by default, and added support for hiding the pet battle tab.
  6. ]]--
  7. local _G = _G
  8.  
  9. -- Function to determine the number of active chat windows, borrowed from Tekkub's FloatingChatFrame
  10. local function GetNumActiveChatFrames()
  11.     local count = 0
  12.     local chatFrame
  13.     for i = 1, NUM_CHAT_WINDOWS do
  14.         chatFrame = _G["ChatFrame"..i]
  15.         if (chatFrame) then
  16.             if (shown or chatFrame.isDocked) then
  17.                 count = count + 1
  18.             end
  19.         end
  20.     end
  21.     return count
  22. end
  23.  
  24. local function hideTab(self)
  25.     if (self.tabHide and self.tabHooked) then
  26.         self:Hide()
  27.     end
  28. end
  29.  
  30. local eventHandler = CreateFrame("Frame")
  31. eventHandler:RegisterEvent("ADDON_LOADED")
  32. -- frame:RegisterEvent("PET_BATTLE_OPENING_START")  -- Event to hook for hiding the PetBattle Chat Tab (ChatFrame11Tab)
  33. eventHandler:SetScript("OnEvent", function(self, event, addon)
  34.     if (event == "ADDON_LOADED" and addon == "ClamChatTabHider") then
  35.         for i = 1, GetNumActiveChatFrames() do
  36.             local frame = _G["ChatFrame"..i.."Tab"]
  37.             if (not frame.tabHooked) then
  38.                 if (frame) then
  39.                     if (frame:GetScript("OnShow")) then
  40.                         frame:HookScript("OnShow", hideTab)
  41.                     else
  42.                         frame:SetScript("OnShow", hideTab)
  43.                     end
  44.                     frame.tabHide = true
  45.                     frame.tabHooked = true
  46.                     frame:Hide()
  47.                 end
  48.             end
  49.         end
  50.     eventHandler:UnregisterEvent("ADDON_LOADED")
  51.     end
  52. end)

Thanks so much for taking the time to help me.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Issue with endlessly increasing addon memory


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off