Hi all! this time I do not have code is just a question. The texture memory is rising every 10 levels in my game and I thought it would never happen to me because I followed the rules of keeping the code as optimized as possible. To be brief, I use composer, all the visual objects that are part of the background and do not collide with another objects are in a table. In this way I do not reach the 60 up values. Those objects are created in the scene create and I only assign nil to the table in the scene destroy.
ex.
--forward variable local dispObj = {} --scene create dispObj.cloud = displayNewImageRect(..) dispObj.square = displayNewImageRect(..) --all display objects are inserted in sceneGroup dispObj.tree = displayNewImageRect(..) etc --scene destroy dispObj = nil
The objects that collide are created individually, I do not know why I decided so but I think I wanted to avoid a table inside another table that are already in another table.
I have an external module which has all the sounds in a table and also has the images sheets and their references.
ex.
local M = {} M.soundTable = { menuMusic = audio.loadSound("sounds/menu\_music.wav"), gameMusic = audio.loadSound("sounds/game\_music.wav"), bounce = audio.loadSound("sounds/bounce.wav")' --etc end --simplified sound variables --I use this to reduce the writing in the module where I'm going to use it M.music = M.soundTable["menuMusic"] M.beat = M.soundTable["gameMusic"] M.boing = M.soundTable["bounce"] -------------------------------------------------------------------------- local img1SheetInfo = require("images.images1") local img1Sheet = graphics.newImageSheet( "images/images1.png", img1SheetInfo:getSheet() ) M.logo = { type = "image", sheet = img1Sheet, frame = 1 } M.name = { type = "image", sheet = img1Sheet, frame = 2 } M.play = { type = "image", sheet = img1Sheet, frame = 3 } --etc return M
The increase in memory is slight. The measuring clock stays at 3.24mb up to level 9 and when it changes to 10 it increases 3.25 and continues like this every 9 levels.
I make this brief explanation so that everyone can understand the method I am using to program. I know it’s a bit difficult to explain everything. I have received a lot of help from here and I am very grateful. I have been able to get where I am thanks to your help.
Could someone help me explaining why these increases in memory are due? With your help I could go more precisely to see where the errors are.
Thanks in advance
DoDi