View Single Post
06-30-20, 06:03 AM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
To answer a question that shows up a lot here, frames cannot be "removed" from memory. They stay persistent throughout an entire session. The best you can do is recycle frames by use of "Frame Pools".



Here's a simpler way and keeping a separate table just for active frames in a frame pool is unnecessary if you're already keeping track of them in other parts of your code.

Lua Code:
  1. local FramePool={};
  2.  
  3. local function FramePool_Acquire()
  4.     return table.remove(FramePool) or CreateFrame("Frame");--   Returns a frame if there is one in the pool or creates one if empty
  5. end
  6.  
  7. local function FramePool_Release(frame)
  8.     table.insert(frame);--  Stores frame in pool
  9. end

Note: You should create a different pool for each frame template you wish to use in order to keep them from getting mixed up.



If you're feeling adventurous, you might want to take a look at Blizzard's implementation of frame and object pools in SharedXML\Pools.lua.
You'll want to pay attention to CreateFramePool() for a singilar frame pool and CreatePoolCollection() to manage different templates.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-30-20 at 06:09 AM.
  Reply With Quote