• 1 page(s)
Need Help with this .lua file

Hi im having truble with this code for some resone the addon just keeps growing by 10kb a sec when its running in wow and i just cant work out why???

i was wondering if some one could please have a look and let me know thank you.

 

Code:

local SortColumn = 1;
local SortReverse;
local NextUpdate = 0;

local AddOnList = {};

--620 total
local Columns = {
  {Name = "Name", Width = 325},
  {Name = "Enabled", Width = 100},
  {Name = "Loaded", Width = 100},
  {Name = "Memory", Width = 80, Right = true, Format = function(Input)
    if(Input >= 1024)then
      return format("%.2f MB", Input / 1024);
    end
    return format("%.0f KB", Input);
  end},
};

StaticPopupDialogs["AddonDB_RELOADUI"] = {
  text = "The UI must be reloaded for the change to take effect.  Do you want to reload the UI now?",
  button1 = "Reload UI",
  button2 = "Not Now",
  OnAccept = function()
    AddonDBConfig.Show = true;
    ReloadUI();
  end,
  timeout = 0,
  exclusive = 1,
  hideOnEscape = 1
};

function AddonDB_OnLoad(self)
  tinsert(UISpecialFrames, self:GetName());
 
  SlashCmdList["AddonDB"] = function()
    AddonDBFrame:Show();
  end
  SLASH_AddonDB1 = "/AddonDB";
  SLASH_AddonDBMenuName = "Addon Data Base";

  self:RegisterForDrag("LeftButton");

  self:RegisterEvent("VARIABLES_LOADED");
  self:RegisterEvent("PLAYER_LOGIN");

  local ScrollBox = AddonDBScrollBox;

  local Left = 10;
  local Button, Text;
  for Key, Value in ipairs(Columns)do
    Button = CreateFrame("Button",self:GetName().."Col"..Key, self);
    Button:SetID(Key);
    Value.Header = Button;
    Value.Left = Left;
    Button:SetWidth(Value.Width);
    Button:SetHeight(16);
    Button:SetScript("OnClick", AddonDBColumn_OnClick);
    Button:SetPoint("BOTTOMLEFT", ScrollBox, "TOPLEFT", Left, 0);
    Text = Button:CreateFontString(Button:GetName().."Text", "ARTWORK", "GameFontNormal");
    Text:SetText(Value.Name);
    Text:SetPoint("LEFT", 10, 0);
    Left = Left + Value.Width;
  end

  ScrollBox.Entries = 20;
  local Entry;
  for Index = 1, ScrollBox.Entries do
    Entry = CreateFrame("Button",ScrollBox:GetName().."Entry"..Index,ScrollBox);
    Entry:SetHeight(16);
    Entry:SetPoint("LEFT", 10, 0);
    Entry:SetPoint("RIGHT", -10, 0);
    Entry:SetPoint("TOP", 0, -10 - (Index - 1) * 16);
    for Key, Value in ipairs(Columns)do
      Text = Entry:CreateFontString(Entry:GetName().."Text"..Key, "ARTWORK", "GameFontHighlight");
      Text:SetPoint("TOP");
      Text:SetPoint("LEFT", Value.Header);
      Text:SetPoint("RIGHT", Value.Header);
      Text:SetJustifyH(Value.Right and "RIGHT" or "LEFT");
    end
    Entry:RegisterForClicks("RightButtonUp");
    Entry:SetScript("OnClick", AddonDBEntry_OnClick);
    Entry:SetScript("OnEnter", AddonDBEntry_OnEnter);
    Entry:SetScript("OnLeave", AddonDBEntry_OnLeave);
    Entry:Hide();
  end

  DEFAULT_CHAT_FRAME:AddMessage("Addon Data Base: AddOn loaded.  Use /AddonDB for addon info.");
end


function AddonDB_OnEvent()
  if(event=="VARIABLES_LOADED")then
    if not AddonDBConfig then
      AddonDBConfig = {};
    end
  end
end


function AddonDB_OnUpdate()
  if(GetTime() > NextUpdate)then
    AddonDBUpdateList();
  end
end


function AddonDBLoadFrame_OnUpdate(self)
  self:Hide();
  if AddonDBConfig.Show then
    AddonDBConfig.Show = nil;
    AddonDBFrame:Show();
  end
end


function AddonDB_OnShow(self)
  self:ClearAllPoints();
  self:SetPoint("CENTER");
  PlaySound("gsTitleOptionOK");
end


function AddonDB_OnHide()
  PlaySound("gsTitleOptionExit");
end


function AddonDB_OnDragStart(self)
  self:StartMoving();
end


function AddonDB_OnDragStop(self)
  self:StopMovingOrSizing();
  self:SetUserPlaced(false);
end


function AddonDBColumn_OnClick(self)
  PlaySound("igMainMenuOptionCheckBoxOn");
  if(self:GetID()==SortColumn)then
    SortReverse = not SortReverse;
  else
    SortColumn = self:GetID();
    SortReverse = nil;
  end
  AddonDBSortList();
end


function AddonDBEntry_OnClick(self)
  ToggleDropDownMenu(1, self:GetID(), AddonDBDropDown, "cursor");
end


function AddonDBEntry_OnEnter(self)
  local Name, Title, Notes, Enabled, Loadable, Reason, Security = GetAddOnInfo(AddOnList[self:GetID()].Name);
  GameTooltip:SetOwner(self,"ANCHOR_CURSOR");
  GameTooltip:AddLine(Title);
  GameTooltip:AddLine(Notes,1,1,1,1);
  local Author, Version = GetAddOnMetadata(Name, "Author"), GetAddOnMetadata(Name, "Version");
  if Author then
    GameTooltip:AddLine("Author: "..Author,1,1,1);
  end
  if Version then
    GameTooltip:AddLine("Version: "..Version,1,1,1);
  end
  GameTooltip:AddLine("Enabled: |cff"..(Enabled and "19ff19Yes" or "ff1919No"),1,1,1);
  local Loaded = IsAddOnLoaded(Name);
  GameTooltip:AddLine("Loaded: |cff"..(Loaded and "19ff19Yes" or "ff1919No"),1,1,1);
  if not Loaded then
    if Reason then
      Reason = strsub(Reason,1,1)..strlower(strsub(Reason,2));
      Reason = string.gsub(Reason,"_(%a)", function(a)return (" "..strupper(a));end);
      GameTooltip:AddLine("Loadable: |cffff1919No|r ("..Reason..")",1,1,1);
    else
      GameTooltip:AddLine("Loadable: |cff19ff19Yes",1,1,1);
    end
  end
  GameTooltip:Show();
end


function AddonDBEntry_OnLeave()
  GameTooltip:Hide();
end


function AddonDBEnabled_OnClick(self)
  if self:GetChecked()then
    PlaySound("igMainMenuOptionCheckBoxOff");
  else
    PlaySound("igMainMenuOptionCheckBoxOn");
  end
  SetCVar("scriptProfile", self:GetChecked()and "1" or "0");
  StaticPopup_Show("AddonDB_RELOADUI");
end


function AddonDBUpdateList()
  NextUpdate = GetTime() + 1;
  UpdateAddOnMemoryUsage();
  local Name, Title, Notes, Enabled, Loadable, Reason, Security;
  local Data;
  for Index = 1, GetNumAddOns()do
    Name, Title, Notes, Enabled, Loadable, Reason, Security = GetAddOnInfo(Index);
    Data = {Title, (Enabled and "Enabled" or "Disabled"), Name = Name};
    tinsert(Data, (IsAddOnLoaded(Name)and "Loaded" or "Not Loaded"));
    tinsert(Data, GetAddOnMemoryUsage(Index));
    AddOnList[Index] = Data;
  end
  AddonDBSortList();
end


function AddonDBSortList()
  AddonDBArrow:ClearAllPoints();
  AddonDBArrow:SetPoint("LEFT",getglobal(Columns[SortColumn].Header:GetName().."Text"), "RIGHT");

  if SortReverse then
    AddonDBArrow:SetTexCoord(0, 0.5625, 1.0, 0);
    table.sort(AddOnList, function(a, b)
      return (a[SortColumn] > b[SortColumn]);
    end);
  else
    AddonDBArrow:SetTexCoord(0, 0.5625, 0, 1.0);
    table.sort(AddOnList, function(a, b)
      return (a[SortColumn] < b[SortColumn]);
    end);
  end
  AddonDBScrollBar_Update();
end


function AddonDBScrollBar_Update()
  local ScrollBar = AddonDBScrollBar;
  local ScrollBox = AddonDBScrollBox;
  FauxScrollFrame_Update(ScrollBar, #AddOnList, ScrollBox.Entries,16);
  local Entry, Index, Text;
  for Line = 1, ScrollBox.Entries do
    Entry = getglobal(ScrollBox:GetName().."Entry"..Line);
    Index = Line + FauxScrollFrame_GetOffset(ScrollBar);
    if(Index > #AddOnList)then
      Entry:Hide();
    else
      Entry:SetID(Index);
      for Key, Value in ipairs(Columns)do
        Text = getglobal(Entry:GetName().."Text"..Key);
        Text:SetText(Value.Format and Value.Format(AddOnList[Index][Key])or AddOnList[Index][Key]);
      end
      if GameTooltip:IsOwned(Entry)then
        AddonDBEntry_OnEnter(Entry);
      end
      Entry:Show();
    end
  end
end


function AddonDBDropDown_OnLoad(self)
  UIDropDownMenu_Initialize(self, AddonDBDropDown_Initialize, "MENU");
end


function AddonDBDropDown_Initialize()
  if not UIDROPDOWNMENU_MENU_VALUE then
    return;
  end
  local AddOn = AddOnList[UIDROPDOWNMENU_MENU_VALUE]
  local Name = AddOn.Name;
  local info = UIDropDownMenu_CreateInfo();
  info.notCheckable = true;
  info.isTitle = true;
  info.text = AddOn[1];
  UIDropDownMenu_AddButton(info);

  info = UIDropDownMenu_CreateInfo();
  info.notCheckable = true;
  info.arg1 = Name;

  local _, Title, Notes, Enabled, Loadable, Reason, Security = GetAddOnInfo(Name);
  info.arg2 = Enabled;
  info.text = (Enabled and "Disable" or "Enable").." (For this Character)";
  info.func = function(self, Name, State)
    PlaySound("igMainMenuOptionCheckBoxOn");
    if State then
      DisableAddOn(Name);
      if not IsAddOnLoaded(Name)then
        return;
      end
    else
      EnableAddOn(Name);
      if select(5, GetAddOnInfo(Name))then
        return;
      end
    end
    AddonDBScrollBar_Update();
    StaticPopup_Show("AddonDB_RELOADUI");
  end
  UIDropDownMenu_AddButton(info);

  if Loadable and not IsAddOnLoaded(Name)then
    info.text = "Load Now";
    info.func = function(self, Name)
      local _, Title, Notes, Enabled = GetAddOnInfo(Name);
      DEFAULT_CHAT_FRAME:AddMessage("AddonDB: Loading "..Title.."...");
      if not Enabled then
        EnableAddOn(Name);
      end
      LoadAddOn(Name);
      AddonDBScrollBar_Update();
    end
    UIDropDownMenu_AddButton(info);
  end
end


function AddonDBMinimapButton_OnLoad(self)
  self:RegisterForClicks("LeftButtonUp", "RightButtonUp");
  self:RegisterForDrag("LeftButton");
  self:SetFrameLevel(self:GetFrameLevel()+1);
end


function AddonDBMinimapButton_OnClick()
  ToggleDropDownMenu(1, nil, AddonDBDropDown);
  AddonDBFrame:Show();
end


function AddonDBMinimapButton_OnEnter(self)
  if self.Dragging then
    return;
  end
  GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT");
  GameTooltip:AddLine("Addon Data Base");
  GameTooltip:AddLine("View Addon information.",1,1,1);
  GameTooltip:AddLine("Shift-drag to move button.",1,1,1);
  GameTooltip:Show();
end


function AddonDBMinimapButton_OnLeave()
  GameTooltip:Hide();
end


function AddonDBMinimapButton_OnDragStart(self)
  MinimapButton_OnMouseUp(self);
  if IsShiftKeyDown()then
    self:SetScript("OnUpdate", AddonDBMinimapButton_OnUpdate);
    self.Dragging = true;
    AddonDBMinimapButton_OnLeave();
  end
end


function AddonDBMinimapButton_OnDragStop(self)
  if self.Dragging then
    self:SetScript("OnUpdate", nil);
    self:StopMovingOrSizing();
    self.Dragging = nil;
    self.Moving = nil;
  end
end


--This script handler is only active when the button is being dragged
function AddonDBMinimapButton_OnUpdate(self)
  local MapScale = Minimap:GetEffectiveScale();
  local CX, CY = GetCursorPosition();
  local X, Y = (Minimap:GetRight() - 70) * MapScale, (Minimap:GetTop() - 70) * MapScale;
  local Dist = sqrt(math.pow(X - CX, 2) + math.pow(Y - CY, 2)) / MapScale;
  local Scale = self:GetEffectiveScale();
  if(Dist <= 90)and Minimap:IsVisible()then
    if self.Moving then
      self:StopMovingOrSizing();
      self.Moving = nil;
    end
    local Angle = atan2(CY - Y, X - CX) - 90;
    self:ClearAllPoints();
    self:SetPoint("CENTER", Minimap, "TOPRIGHT", (sin(Angle) * 80 - 70) * MapScale / Scale, (cos(Angle) * 77 - 73) * MapScale / Scale);

  elseif not self.Moving then
    self:ClearAllPoints();
    self:SetPoint("CENTER", UIParent, "BOTTOMLEFT",CX / Scale, CY / Scale);
    self:StartMoving();
    self.Moving = true;
  end
end


[edited by: DKmisfit at 5:07 PM (GMT -6) on 10 Apr 2009]

Report this thread post

Going to need to see each file (especially the xml file that calls theses functions)

See my "Thread to end all threads thread" for the answer to your question!

Report this thread post

ok will do thanx

hear is the .xml

<Ui xmlns="http://www.blizzard.com/wow/ui/";   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";   xsi:schemaLocation="http://www.blizzard.com/wow/ui/";>
  <Script file="AddonDB.lua"/>

  <Frame name="AddonDBFrame" toplevel="true" frameStrata="MEDIUM" movable="true" enableMouse="true" parent="UIParent" hidden="true">
    <Size><AbsDimension x="700" y="440"/></Size>
    <Anchors><Anchor point="CENTER"/></Anchors>
    <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
      <BackgroundInsets>
        <AbsInset left="11" right="12" top="12" bottom="11"/>
      </BackgroundInsets>
      <TileSize><AbsValue val="32"/></TileSize>
      <EdgeSize><AbsValue val="32"/></EdgeSize>
    </Backdrop>
    <Layers>
      <Layer level="ARTWORK">
        <Texture name="$parentHeader" file="Interface\DialogFrame\UI-DialogBox-Header">
          <Size><AbsDimension x="300" y="64"/></Size>
          <Anchors>
            <Anchor point="TOP">
              <Offset><AbsDimension y="12"/></Offset>
            </Anchor>
          </Anchors>
        </Texture>
        <FontString inherits="GameFontNormal" text="Addon Data Base">
          <Anchors>
            <Anchor point="TOP" relativeTo="$parentHeader">
              <Offset><AbsDimension y="-14"/></Offset>
            </Anchor>
          </Anchors>
        </FontString>
        <Texture name="AddonDBArrow" file="Interface\Buttons\UI-SortArrow">
          <Size><AbsDimension x="9" y="8"/></Size>
        </Texture>
      </Layer>
    </Layers>
    <HighlightTexture file="Interface\PaperDollInfoFrame\UI-Character-Tab-Highlight" alphaMode="ADD">
      <Size><AbsDimension x="5" y="24"/></Size>
      <Anchors>
        <Anchor point="LEFT"/>
        <Anchor point="RIGHT">
          <Offset><AbsDimension x="4" y="0"/></Offset>
        </Anchor>
      </Anchors>
    </HighlightTexture>
    <Frames>
      <Frame name="AddonDBScrollBox">
        <Size><AbsDimension y="340"/></Size>
        <Anchors>
          <Anchor point="TOPLEFT">
            <Offset><AbsDimension x="30" y="-50"/></Offset>
          </Anchor>
          <Anchor point="RIGHT">
            <Offset><AbsDimension x="-30"/></Offset>
          </Anchor>
        </Anchors>
        <Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
          <EdgeSize><AbsValue val="16"/></EdgeSize>
          <BackgroundInsets>
            <AbsInset left="5" right="5" top="5" bottom="5"/>
          </BackgroundInsets>
        </Backdrop>
        <Frames>
          <ScrollFrame name="AddonDBScrollBar" inherits="FauxScrollFrameTemplate">
            <Anchors>
              <Anchor point="TOPLEFT">
                <Offset><AbsDimension y="-4"/></Offset>
              </Anchor>
              <Anchor point="BOTTOMRIGHT">
                <Offset><AbsDimension x="-26" y="4"/></Offset>
              </Anchor>
            </Anchors>
            <Scripts>
              <OnVerticalScroll>
                FauxScrollFrame_OnVerticalScroll(self, offset, 16, AddonDBScrollBar_Update);
              </OnVerticalScroll>
            </Scripts>
          </ScrollFrame>
          <!--Frame name="$parentHighlight" hidden="true">
            <Size><AbsDimension x="1" y="16"/></Size>
            <Anchors>
              <Anchor point="LEFT">
                <Offset><AbsDimension x="8"/></Offset>
              </Anchor>
              <Anchor point="RIGHT">
                <Offset><AbsDimension x="-8"/></Offset>
              </Anchor>
            </Anchors>
            <Layers>
              <Layer level="BACKGROUND">
                <Texture name="$parentTexture" file="Interface\Buttons\UI-Listbox-Highlight2"/>
              </Layer>
            </Layers>
            <Scripts>
              <OnLoad>
                getglobal(self:GetName().."Texture"):SetVertexColor(0.5,0.5,0);
              </OnLoad>
            </Scripts>
          </Frame-->
        </Frames>
      </Frame>
      <Button name="$parentCloseButton" inherits="GameMenuButtonTemplate" text="Close">
        <Size><AbsDimension x="100" y="21"/></Size>
        <Anchors>
          <Anchor point="BOTTOMRIGHT">
            <Offset><AbsDimension x="-16" y="16"/></Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnClick>
            self:GetParent():Hide();
          </OnClick>
        </Scripts>
      </Button>
      <Button name="$parentReloadUIButton" inherits="GameMenuButtonTemplate" text="Reload UI">
        <Size><AbsDimension x="100" y="21"/></Size>
        <Anchors>
          <Anchor point="RIGHT" relativeTo="$parentCloseButton" relativePoint="LEFT">
            <Offset><AbsDimension x="-5"/></Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnClick>
            PlaySound("igMainMenuOptionCheckBoxOn");
            AddonDBConfig.Show = true;
            ReloadUI();
          </OnClick>
        </Scripts>
      </Button>
    </Frames>
    <Scripts>
      <OnLoad>
        AddonDB_OnLoad(self);
      </OnLoad>
      <OnEvent>
        AddonDB_OnEvent(self, event);
      </OnEvent>
      <OnUpdate>
        AddonDB_OnUpdate(self);
      </OnUpdate>
      <OnShow>
        AddonDB_OnShow(self);
      </OnShow>
      <OnHide>
        AddonDB_OnHide(self);
      </OnHide>
      <OnDragStart>
        AddonDB_OnDragStart(self);
      </OnDragStart>
      <OnDragStop>
        AddonDB_OnDragStop(self);
      </OnDragStop>
    </Scripts>
  </Frame>

  <Frame name="AddonDBDropDown" inherits="UIDropDownMenuTemplate" hidden="true">
    <Scripts>
      <OnLoad>
        AddonDBDropDown_OnLoad(self);
      </OnLoad>
    </Scripts>
  </Frame>

  <Frame name="AddonDBLoadFrame">
    <Scripts>
      <OnUpdate>
        AddonDBLoadFrame_OnUpdate(self);
      </OnUpdate>
    </Scripts>
  </Frame>

<Button name="AddonDBMinimapButton" frameStrata="DIALOG" parent="UIParent" movable="true" inherits="MiniMapButtonTemplate">
    <Size><AbsDimension x="33" y="33"/></Size>
    <Anchors>
      <Anchor point="BOTTOMLEFT" relativeTo="Minimap">
        <Offset><AbsDimension x="-25" y="43"/></Offset>
      </Anchor>
    </Anchors>
    <Layers>
      <Layer level="BACKGROUND">
        <Texture name="$parentIcon" file="Interface\Minimap\UI-Minimap-ZoomOutButton-Disabled">
          <Size><AbsDimension x="33" y="33"/></Size>
          <Anchors><Anchor point="CENTER"/></Anchors>
        </Texture>
      </Layer>
      <Layer level="BORDER">
        <Texture file="Interface\BUTTONS\UI-GuildButton-PublicNote-Up">
          <Size><AbsDimension x="18" y="18"/></Size>
          <Anchors><Anchor point="CENTER" relativeTo="$parentIcon"/></Anchors>
        </Texture>
      </Layer>
      <Layer level="ARTWORK">
        <Texture file="Interface\Minimap\MiniMap-TrackingBorder">
          <Size><AbsDimension x="52" y="52"/></Size>
          <Anchors><Anchor point="TOPLEFT"/></Anchors>
        </Texture>
      </Layer>
    </Layers>
    <HighlightTexture alphaMode="ADD" file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight"/>
    <Frames>
      <Frame name="AddonDBDropDown" inherits="UIDropDownMenuTemplate" id="1" hidden="true">
        <Scripts>
          <OnLoad>
            AddonDBDropDown_OnLoad(self);
          </OnLoad>
        </Scripts>
      </Frame>
    </Frames>
    <Scripts>
      <OnLoad>
        AddonDBMinimapButton_OnLoad(self);
      </OnLoad>
      <OnClick>
        AddonDBMinimapButton_OnClick(self, arg1);
      </OnClick>
      <OnEnter>
        AddonDBMinimapButton_OnEnter(self);
      </OnEnter>
      <OnLeave>
        AddonDBMinimapButton_OnLeave(self);
      </OnLeave>
      <OnDragStart>
        AddonDBMinimapButton_OnDragStart(self);
      </OnDragStart>
      <OnDragStop>
        AddonDBMinimapButton_OnDragStop(self);
      </OnDragStop>
    </Scripts>
  </Button>
</Ui>

 

here is the .toc

## Interface: 30000
## Title: Addon Data Base
## Notes: Allows you to view information about all installed addons and lets you enable and disable them ingame.
## Author: DKmisfit
## Version: 0.1.1
## SavedVariables: AddonDBConfig
AddonDB.xml


[edited by: DKmisfit at 7:20 PM (GMT -6) on 8 Apr 2009]

Report this thread post

so any ideas then peaps ??

Report this thread post

Not exactly sure without debugging locally but I have a few suggestions:

1. You may want to change your OnEvent to check for what addon is loading variables.

Code:
function AddonDB_OnEvent(event, arg1)
  if(event=="VARIABLES_LOADED" and arg1 == 'AddonDB')then
    if not AddonDBConfig then
      AddonDBConfig = {};
    end
  end
end

2. Try commenting out your OnUpdate and see if that helps.

3. If none of the above you then need to start commenting out each function until you find the offending function.

If this is happening every X amount of seconds then it is one of the 'On....' functions take a close look at your code and trace each variable and function and make sure that it can only be called when you want it to be. If you still have troubles after more debugging zip up your addon and post a link to it and I am sure that we can help out more.

 

Oh... would you please use code blocks in the future as well :) ( [ code ] stuff here [ /code ] , minus spaces)


[edited by: teek5449 at 12:06 PM (GMT -6) on 9 Apr 2009]

See my "Thread to end all threads thread" for the answer to your question!

Report this thread post

Ok thanx for having a look at it and sorry for not using the code block dint know it was in use.

i'll try what you said and let you know how it go's.

Report this thread post

Besides the  code /code blocks, you can also post stuff to http://pastey.net and select the language. Makes things really, really easy to read. And the best part is that is is FREE!

Project Lead for SmartRes and MrBigglesworthDeath. SmartRes2 coming soon!

 

Report this thread post

Dint find the what was cousing the prob but i added a garbage collection to the addon and now its fixed it and also frees up memory from the rest of the addons.

With all my addons running i was using about 50mb memory but now with my addon im only using 44mb and my cpu usage has only gone up by 0.3%.

Report this thread post

Garbage collection should be automatically handled by the client as it is. I think you have just put a band aid on the underlying problem.

Also.... as posted I can not even get the addon to run in game. There are no errors and it shows up in the addon list but there is no indication of anything. The slash command is not even registered. . All I did was copy and paste the posted code. If you have a working copy for testing it would help make debugging much easier.


[edited by: teek5449 at 5:57 PM (GMT -6) on 10 Apr 2009]

See my "Thread to end all threads thread" for the answer to your question!

Report this thread post

Here is my addon but it can only be downloaded 10 times so

http://rapidshare.com/files/219880802/AddonDB.rar.html

Report this thread post

Your issue is with tables... specifically the following function is your problem

Code:

function AddonDBUpdateList()
  NextUpdate = GetTime() + 1;
  UpdateAddOnMemoryUsage();
  local Name, Title, Notes, Enabled, Loadable, Reason, Security;
  local Data;
  for Index = 1, GetNumAddOns()do
    Name, Title, Notes, Enabled, Loadable, Reason, Security = GetAddOnInfo(Index);
    Data = {Title, (Enabled and "Enabled" or "Disabled"), Name = Name};
    tinsert(Data, (IsAddOnLoaded(Name)and "Loaded" or "Not Loaded"));
    tinsert(Data, GetAddOnMemoryUsage(Index));
    AddOnList[Index] = Data;
  end
  AddonDBSortList();
end

...you will notice that your addon no longer eats up memory like a hungry hippo if you comment out the lines that have to do with the 'data' table, like
Code:

function AddonDBUpdateList()
  NextUpdate = GetTime() + 1;
  UpdateAddOnMemoryUsage();
  local Name, Title, Notes, Enabled, Loadable, Reason, Security;
  local Data;
  for Index = 1, GetNumAddOns()do
    Name, Title, Notes, Enabled, Loadable, Reason, Security = GetAddOnInfo(Index);
    --Data = {Title, (Enabled and "Enabled" or "Disabled"), Name = Name};
    --tinsert(Data, (IsAddOnLoaded(Name)and "Loaded" or "Not Loaded"));
    --tinsert(Data, GetAddOnMemoryUsage(Index));
    --AddOnList[Index] = Data;
  end
  AddonDBSortList();
end

The reason that you forcing a GC is working is because you are removing that temporary table from memory. Lua tables are confusing and I would suggest that you talk with someone else since I do not have time right now to really debug the issue.

[edited by: teek5449 at 8:22 PM (GMT -6) on 10 Apr 2009]

See my "Thread to end all threads thread" for the answer to your question!

Report this thread post

Thank you for having a look at it for me i'll try to find a way to fix this.

What do you think of the addon so fare, its my first big addon realy.

Report this thread post
  • 1 page(s)
Subscribe to this thread: (you will receive emails when new posts are made)