Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
memory leak and BHleak showing a nil class replicating on certain conditions: how to track it down? — Gideros Forum

memory leak and BHleak showing a nil class replicating on certain conditions: how to track it down?

piepie Member
edited September 2014 in General questions
Hi, I am using "BHleaky" - source and info in this post -
http://giderosmobile.com/forum/discussion/2645/help-with-memory-leak/p1

I got this error:
leaky.lua:44: bad argument #2 to 'format' (string expected, got nil)
stack traceback:
	leaky.lua:44: in function 'printAllInstances'
I made a slight mod to avoid it, so that it can work, and it works (to a certain extent):
function EventDispatcher.printAllInstances(tag)
	print("*** OBJECT SNAPSHOT", tag or os.date("%c"), "***")
	for class, tally in pairs(EventDispatcher._allObjectsBag.contents) do
		local classname = getClassName(class) -- ADDED 
		if classname == nil then classname = "unknown, class nil" end -- ADDED 
		print(string.format("%s has %d instances", classname, tally)) --UPDATED
	end
	print("*** OBJECT SNAPSHOT END ****")
end
My problem is that this "unknown class" it's there from the beginning of my level loading, and on certain conditions it (they) become more and more unknown classes, each always referenced by 1 instance.

I'd like to understand which one it is, and if its moltiplication is given by the impossibility to remove it from the list, since its class.name is nil..

I'm trying to print out everything is being added if self.class is nil, but my output becomes mostly unreadable, because there are a lot of userdata being processed.
function EventDispatcher:postInit()
	EventDispatcher._allObjectsBag:add(self.class)
 --ADDED
	if self.class == nil then 
		for i,k in pairs(self) do
		print("EventD_postInit, class nil", i, k)
			local meta = getmetatable(self)
				print_r(meta)
		end
	end
 
	self._proxy = newproxy(true)
	getmetatable(self._proxy).__gc = function() self:_destroy() end
end
</end>
Any smart advice on how I could get it?

Thank you!
[-O<
Sign In or Register to comment.