ScrollView memory leak?

 myScrollView = widget.newScrollView { top = 700, left = 32, width = 672, height = 320, horizontalScrollDisabled = true, hideScrollbar = true, verticalScrollDisabled = false, hideBackground = false, backgroundColor = { 1, 1, 1, 63/255 }, maskFile = "images/myscrollmask2.png", } group:insert(myScrollView )

After leaving a scene (which should remove the group and all children), I see ~30k fixed memory increase. Not texture memory. This persists and does not increase, but is definitely from the scrollView instantiation.

Can anyone else confirm?
 

Where is myScrollView declared?  Is it a global?  Do you have a:

local myScrollView

at the top of the scene?  Are you doing a removeScene() or a purgeScene() somewhere?

In general, seeing memory allocations go up isn’t a problem, its if it goes up and up and up.  “This persists and does not increase” to me doesn’t describe a memory leak.

Rob

I do use a local (to the scene) and I do a removeScene()

It does not go up and up and up every time I access the screen.

Another scrollview I have goes up by 40ish and when I go to multiple screens using scrollviews it does not increase between them so it’s probably reusing something permanently allocated.

Thanks for looking.

Here is what happens.

  1. Your scene is “required” in by storyboard.gotoScene(). 
  2. If it’s  already be required once, it won’t be required a second time.  Any variables declared in the main chunk of the scene file will stay in memory from when they were previously allocated…
  3. widget.newScrollView will create a Lua table to hold all of it’s information.  This is what shows up as non-texture memory.  I would guess 30K is about right for an object the size and complexity of the scrollView.
  4. Texture memory is allocated for the display objects needed for the scrollView (the scroll bars, etc.).  Since it’s just a big group, there probably isn’t a whole lot of memory.  But for something like  a tableView, those rows all have a bunch of texture things allocated.
  5. If you purge the scene, the texture memory is freed up, but the the table is still allocated. 
  6. If you exit the scene and come back, the table is still allocated and when you call widget.newScrollView() it doesn’t have tor recreate the table, ergo your memory does not go back up.  If the texture memory needs reallocated because you purged or removed the scene, then it will be.
  7. If you removeScene() the scene, then the module is unrequired and all of the memory should be released from it.

Hope that helps

Rob

Where is myScrollView declared?  Is it a global?  Do you have a:

local myScrollView

at the top of the scene?  Are you doing a removeScene() or a purgeScene() somewhere?

In general, seeing memory allocations go up isn’t a problem, its if it goes up and up and up.  “This persists and does not increase” to me doesn’t describe a memory leak.

Rob

I do use a local (to the scene) and I do a removeScene()

It does not go up and up and up every time I access the screen.

Another scrollview I have goes up by 40ish and when I go to multiple screens using scrollviews it does not increase between them so it’s probably reusing something permanently allocated.

Thanks for looking.

Here is what happens.

  1. Your scene is “required” in by storyboard.gotoScene(). 
  2. If it’s  already be required once, it won’t be required a second time.  Any variables declared in the main chunk of the scene file will stay in memory from when they were previously allocated…
  3. widget.newScrollView will create a Lua table to hold all of it’s information.  This is what shows up as non-texture memory.  I would guess 30K is about right for an object the size and complexity of the scrollView.
  4. Texture memory is allocated for the display objects needed for the scrollView (the scroll bars, etc.).  Since it’s just a big group, there probably isn’t a whole lot of memory.  But for something like  a tableView, those rows all have a bunch of texture things allocated.
  5. If you purge the scene, the texture memory is freed up, but the the table is still allocated. 
  6. If you exit the scene and come back, the table is still allocated and when you call widget.newScrollView() it doesn’t have tor recreate the table, ergo your memory does not go back up.  If the texture memory needs reallocated because you purged or removed the scene, then it will be.
  7. If you removeScene() the scene, then the module is unrequired and all of the memory should be released from it.

Hope that helps

Rob