Quantcast

Memory leak :/

Scott Sibley [08-20-10 - 02:56]
Memory leak :/
Filename
Modules/Text.lua
StarTip.lua
diff --git a/Modules/Text.lua b/Modules/Text.lua
index 54c99bf..57325a6 100644
--- a/Modules/Text.lua
+++ b/Modules/Text.lua
@@ -117,7 +117,7 @@ if self.UnitExists("mouseovertarget") then
     end
     return c
 else
-	c = self.new()
+	if not c then c = self.new() end
 	c.r = 1
 	c.g = 1
 	c.b = 1
@@ -465,7 +465,9 @@ do
 			else
 				fontString:SetVertexColor(1, 1, 1, 1)
 			end
-
+
+			StarTip.del(c)
+
 			font = LSM:Fetch("font", fontsList[appearance.db.profile.font])

 			if widget.bold then
diff --git a/StarTip.lua b/StarTip.lua
index 0708c69..6f8985e 100644
--- a/StarTip.lua
+++ b/StarTip.lua
@@ -177,6 +177,7 @@ local options = {

 do
 	local pool = setmetatable({},{__mode='k'})
+	local newCount, delCount = 0, 0
 	function StarTip.new(...)
 		local t = next(pool)
 		local newtbl
@@ -186,10 +187,12 @@ do
 				t[i] = select(i, ...)
 			end
 		else
+			--StarTip:Print("new table " .. GetTime(), "new " .. newCount, "del " .. delCount)
 			newtbl = true
 			t = {...}
 		end
 		t.__starref__ = true
+		newCount = newCount + 1
 		return t, newtbl
 	end
 	function StarTip.del(...)
@@ -208,6 +211,7 @@ do
 		end
 		t.__starref__ = nil
 		pool[t] = true
+		delCount = delCount + 1
 	end
 end