Quantcast WoWInterface - View Single Post - Memory Leak ?
Thread: Memory Leak ?
View Single Post
05-02-17, 07:08 PM   #2
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 215
Answer to your first question, it is possible. Local variables are not deleted right away, a method to get around it is to declare the function with the variables inline and simply use them from there. It, I believe, reserves the location in memory allocating it only once and will be garbage collected eventually without creating excessive copies.

Answer to your second question, yes as that is best practice. But it would also help if globals are scoped properly as it can cause some minor issues that slowly stack. This has resulted in both Blizzard developers, and addon authors, creating stack overflows.

Lua Code:
  1. local LE_FOLLOWER_TYPE_GARRISON_7_0 = LE_FOLLOWER_TYPE_GARRISON_7_0
  2. local GetAvailableMissions = C_Garrison.GetAvailableMissions
  3. local GetInProgressMissions = C_Garrison.GetInProgressMissions
  4. local GetCompleteMissions = C_Garrison.GetCompleteMissions
  5.  
  6. function dataobj.OnTooltipShow(tooltip, mis_avl, mis_pro, mis_fin)
  7.         -- [ blabla ]
  8.    
  9.         mis_avl = #GetAvailableMissions(LE_FOLLOWER_TYPE_GARRISON_7_0)
  10.         mis_pro = #GetInProgressMissions(LE_FOLLOWER_TYPE_GARRISON_7_0)
  11.         mis_fin = #GetCompleteMissions(LE_FOLLOWER_TYPE_GARRISON_7_0)
  12.  
  13.         -- [ blabla ]
  14. end
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
  Reply With Quote