Hello, i got a second question but since its quite a bit different than the previous one will post it here
1.)
function scene:create( event ) local sceneGroup = self.view
has its own group which is called sceneGroup, if i add all the display objects i use during my code they will niled and destroyed upon calling destroyScene
i make my own
sceneGroupStartingMenu = display.newGroup()
and insert objects in it then add it to sceneGroup
sceneGroup:insert( sceneGroupStartingMenu )
then depending which button i press i do :removeSelf() and =nil on the group (and i quess when doing removeScene it kills anything that is left)
i remove listeners manually BUT i am not sure what to do with require functions
local composer = require( “composer” )
local composer = require( “json” )
local composer = require( “widget” )
should i leave composer as he gets called in another scene again? can i make it global and only call it once? i noticed if i remove json and widget upon being called again they get my memory usage HIGHER for some reason (for some small amount but it piles up, if i don’t do as it is said below i won’t get additional usages which leaves me confused…)
package.loaded["json"] = nil json=nil
trying to optimize but so many problems so far and hope someone had similar problem/solution
2,)
now i have a login scene with 2 input fields 2 buttons and 2 text variables
i am connecting to my own (local database thru network.request and php script) but once i enter my mainMenu chaos happens
from 244k memory it jumps to 370k and only thing inside is
local tableWidget = widget.newTableView {...}
am i correct in assuming that code below actually doesn’t remove it? because when i go back into previous menu 100k of memory is permanently used by something
tableWidget:removeSelf()
tableWidget=nil
are widgets removed differently?
3.) this might aswell be a bug but when i put tableWidget from the 2nd step into sceneGroup (from self.view) and then upon exiting the scene i ordered it to be deleted together with other objects inside
function logoutButton:touch( event ) if event.phase == "began" then bgCreate:removeEventListener( "touch", bgCreate ) logoutButton:removeEventListener( "touch", logoutButton ) createButton:removeEventListener( "touch", createButton ) sceneGroupMainMenu:removeSelf() sceneGroupMainMenu=nil tableWidget:removeSelf() tableWidget=nil composer.gotoScene( "welcomeScreen", "slideLeft", 800 ) end return true end
the above code will work without error letting me go to some other scene BUT removing two red lines will produce an error
?:0: attempt to perform arithmetic on field 'contentHeight' (a nil value) stack traceback: ?: in function '\_manageRowLifeCycle' ?: in function \<?:524\> ?: in function \<?:221\>
my understanding of this is that if i don’t manually delete this widget, later when i remove the scene this error happens due to something (maybe it can’t access widgets properly or something)
just thought i would point it out as i am still not sure i properly “cleaned” this widget out of my system and if no one has any idea will prolly comment parts of code piece by piece until i find out
function scene:show( event ) local phase = event.phase if "did" == phase then print( "1: show event, phase did" ) -- remove previous scene's view composer.removeScene( "mainScreen" )
EDIT:
just went to test the theory and if i want to remove the widget with removeScene i gotta add widget library (which i suppose makes sense since its local and it can’t be deleted as easily)
but even having done that i am still losing ~100k somewhere with this widget (it doesn’t add up next time i go into the same scene btw so there is no “memory” leaks just this object that doesn’t move)
local widget = require( "widget" ) -- remove previous scene's view composer.removeScene( "mainScreen")
- i just tested weirdest thing aswell so this confuses me even more so
THERE IS other code i just didn’t write it i was focusing on these lines here producing additional memory leaks and stuff
case1:
nothing
produces 260k of memory
case2:
local widget = require( “widget” )
produces 290k as it should since it uses its library
case3:
local widget = require( “widget” )
package.loaded[“widget”] = nil
widget=nil
produces 278k of memory AFTER being deleted
??? i mean if it cleared everything it should be 260k, so either i cleared it bad and have no idea what i am doing or i don’t understand it quite right yet so would like some explanation since i see it as a waste to clear it 
is there some way to see “what” is in the memory? thx for all the help! i know its plentiful read 