[Addon Dev] Blizzard Frames, override?

Re: [Addon Dev] Blizzard Frames, override?

by Rhena » Fri Jan 22, 2016 12:41 pm

@ OP: You can't free the memory that is occupied by the default interface. Even if you set it to nil all you are doing is deleting the pointer that points to that memory address. Every frame you (or the game client) creates will stay in memory until the UI is reloaded. So if you want to "get rid" of something all you can do is unhook all events/scripts and hide it.

And here is another tip for free:

LUA uses a garbage collection. That means everything you "throw away" will be freed once a certain threshold is met. So to make your addon better performance wise don't do
Code: Select all
local array = {"Test","LoL","12345"}
array = {}

to clear it.

Do
Code: Select all
local array = {"Test","LoL","12345"}
for _,v in pairs(array) do
 v = nil
end
Author of LunaUnitFrames - The most advanced unit frames for classic WoW. Visit my GitHub page for them and some other tools i wrote.
Rhyna - Warrior | Nost PvP | Alliance
User avatar
Rhena
Sergeant Major
Sergeant Major
 

Re: [Addon Dev] Blizzard Frames, override?

by modernist » Fri Jan 22, 2016 12:59 pm

neat, i didn't actually know there was a distinction there. thanks rhena
modernist
Sergeant Major
Sergeant Major
 

Re: [Addon Dev] Blizzard Frames, override?

by Falls » Fri Jan 22, 2016 6:10 pm

Rhena idk if that is right, i tried:

Code: Select all
local a = {"one", "two", "three", "four", "test", "try", "dance", "naked"}
print(collectgarbage("count"))
for _,v in pairs(a) do
   v = nil
end
print(collectgarbage("count"))


I got increased memory on the second collect. I just read the only way to force the reduction in memory is to force a rehash. Since we dont know when a rehash will happen we can actually tell if you memory is being deallocated. Alternatively you can rely on the GC to do it for you, either wait for the cycle or force it with collectgarbage("collect").

I got some of this info from http://www.lua.org/gems/sample.pdf
Falls
Private
Private
 

Re: [Addon Dev] Blizzard Frames, override?

by Rhena » Fri Jan 22, 2016 7:16 pm

The method i posted applies to small tables that are reused often.

Here is some more info and some other tricks:
http://old.wowace.com/Coding_Tips#Recycle_tables
Author of LunaUnitFrames - The most advanced unit frames for classic WoW. Visit my GitHub page for them and some other tools i wrote.
Rhyna - Warrior | Nost PvP | Alliance
User avatar
Rhena
Sergeant Major
Sergeant Major
 

Re: [Addon Dev] Blizzard Frames, override?

by Falls » Fri Jan 22, 2016 9:26 pm

Oh i see, so its not about deallocating memory; just efficient use of small reusable tables.
Falls
Private
Private
 

Previous

Return to Addons & macros