Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Found a bug, a notification theme ! — Gideros Forum

Found a bug, a notification theme !

YanYan Member
edited January 2017 in Bugs and issues
I have a simple codebelow - and its not collected via garbagecollector

-- Class function
function Canvas:init(w, h)
 
	self.canvas	= RenderTarget.new(w, h, true)
	self.bitmap	= Pixel.new(self.canvas)
 
	self:addChild(self.bitmap)
 
end
--Using this class in mu level as local
local canvas	= Canvas.new(levelSize.w, levelSize.h)
--The fix is use
self.bitmap	= Bitmap.new(self.canvas)
after this fix class collected properly, be carefully to use Pixel as lowcost bitmap with RenderTarget !

Bugless coding and have a nice day to to everybody !
vk.com/yan_alex

Comments

  • hgy29hgy29 Maintainer
    It seems to be collected properly here. What makes you feel/say it doesn't work ?
    I used the code below to check:
    function tellGC(obj,name)
       obj.proxy = newproxy(true)
       getmetatable(obj.proxy).__gc = function() print(name.." collected!") end
    end
     
     
    Canvas=Core.class(Sprite)
    function Canvas:init(w, h)
    	tellGC(self,"Canvas")
    	self.canvas	= RenderTarget.new(w, h, true)
    	tellGC(self.canvas,"RenderTarget")
    	self.bitmap	= Pixel.new(self.canvas)
    	--self.bitmap	= Bitmap.new(self.canvas)
    	tellGC(self.bitmap,"Bitmap")
     
    	self:addChild(self.bitmap) 
    end
     
    collectgarbage()
    print("INIT MEM:",collectgarbage("count"))
     
    local canvas	= Canvas.new(1024,1024)
    collectgarbage()
    print("ALLOC MEM:", collectgarbage("count"))
     
    canvas=nil
    collectgarbage()
    print("GC'ED MEM:", collectgarbage("count"))
  • YanYan Member
    If it used in Scenemanager Level it does collected, but MemoryAllocation is growing every time I reload level
    vk.com/yan_alex
  • piepie Member
    @Yan please setup a simple project where this happens :)

    Likes: totebo

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.