Weird Memory Issue

My code has a fairly large main file maybe 1600 lines, and several other files with code and fair amount of textures(.png) loaded in at different times in the code.

  1. I have one enterFrame event and for testing this issue have stripped it down to only the ‘memory check’ call running in that loop.

  2. I have this touch event(see code below) of the screen which places an image on the screen and 3 seconds later removes it from screen and from memory.
    As I monitor the memory, about every 5 seconds I tap the screen, memory jumps while the image is created and on screen, then drops back(but not back to the original memory amount… there is still some increase that does not clear). So as I continue, every 5 seconds to place an image and it calls the remove method, I watch the memory slowly build.

There is 2 strange occurrences:

  1. Taking the code (which is just part of the main.lua file in my first app) and I place that is a separate app all by itself, with an ‘enterframe’ loop to check the memory, just like it does in my first app. When image is placed, after an initial memory spike, each subsequent placement increases memory, but ‘recovers’ all the memory after 3 seconds when object is removed, as it should. I do this repeatedly and it always recovers the memory.

  2. Keeping the code listed below in the main.lua on my first app, if I instead of using a texture .png file, I make the image as a newCircle object, and follow the same steps, placing this circle image on the screen every 5 seconds or so, it removes itself 3 seconds later as it should and it recovers all that memory, as it should.

So, what other things in my main code could be influencing this memory (lua memory - not texture memory) not being released when the image object is removed properly and set to nil ???

local insGroup  
local insImage  
  
local function removeIt()  
 insImage:removeSelf()  
 insImage = nil  
 insGroup:removeSelf()  
 insGroup = nil   
 end  
   
 local function makeImage(\_x, \_y)  
 insGroup = display.newGroup()  
 insImage = display.newImage("Textures/image.png")  
 --insImage = display.newCircle(100,100,30)   
 insGroup:insert(insImage)  
 insGroup.x = \_x  
 insGroup.y = \_y  
 timer.performWithDelay(3000,removeIt)   
 end  
  
local function touchScreen(e)   
 if e.phase == "ended" then  
 makeImage(e.x, e.y)  
 end  
 return true  
end  
  
local function gameLoop(e)  
 memCheck(" in loop ", {x = 200, y = 80} )   
end  
  
Runtime:addEventListener("enterFrame", gameLoop)  
  

** the code for the newCircle is remarked… when I un-remark that, and remark the newImage line, then the memory does not continue to climb on each image placed and removed. Yet, when this code ran either way as a simple, small app all by itself recovers the memory after each image/removal action.
My big concern is that after placing many images on the screen,using this code, as my app will require, the memory just keeps climbing. Any information that can help explain this memory climb will be of great help.

Thanks!

[import]uid: 148857 topic_id: 36160 reply_id: 336160[/import]

anyone have any insight into this? [import]uid: 148857 topic_id: 36160 reply_id: 143713[/import]

anyone have any insight into this? [import]uid: 148857 topic_id: 36160 reply_id: 143713[/import]

anyone have any insight into this? [import]uid: 148857 topic_id: 36160 reply_id: 143713[/import]

anyone have any insight into this? [import]uid: 148857 topic_id: 36160 reply_id: 143713[/import]