Thread Tools Display Modes
12-17-09, 07:54 AM   #1
Smacker
A Deviate Faerie Dragon
 
Smacker's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 16
Garbage Collection

I can use various addons to see how much Garbage Collection my addon is causing. How can I find out which objects are being colected so I can reduce this burden?

Cheers
  Reply With Quote
12-17-09, 08:20 AM   #2
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
All objects which are not referenced, are free for garbage collection. For example, if you have stored a table in a variable and set this variable nil, the table could not be accessed any more and will be cleared. But if you have another variable pointing to the same table, the table would of course stay in memory. Same goes for functions.
Frames cannot be deleted/collected, they just stay in memory. And, concerning strings, I think they are stored in a global place of the Lua environment and they won't be deleted, too.

Garbage-collection is actually a good thing, because it helps to delete unnecessary objects which would otherwise take up memory.
You should rather focus on the rate your memory is increasing - which of course sets a lot objects free which later become obsolete and will be garbage-collected. So, look when memory-increase or garbage-collection of your addon has a peak and then go in your addon and look which code was executed at this specific time. Make sure that you do not create a lot of new tables and/or frames which won't be used again. This mistake could often happen when you are using tables within OnUpdate-functions or often called events.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
12-17-09, 08:26 AM   #3
Katae
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 208
Finding out which objects are adding to memory use would be up to you to find, no addon will be able to help you write code. Here's a few places to help you spot offenders:

Lua Performance Tips (PDF)
Optimizing memory usage in LUA
Lua object memory sizes - WoWWiki

Last edited by Katae : 12-17-09 at 08:36 AM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Garbage Collection


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