I have a question regarding system memory usage when using composer and modules, like in the following example:
I have a mainmenu and a level as different scenes.
I use a lot of modules which are required outside the composer functions, like this:
A sound module:
-- the sound.lua module code local mod={} local createAllSounds = function() -- code to create (load) all sounds here end mod.createAllSounds=createAllSounds return mod
Module sample 2:
-- the module1.lua local mod={} local createAllGraphics = function() -- code to create all Graphics here end mod.createAllGraphics=createAllGraphics return mod
Now for example I get to my mainmenu scene I have a system memory of about 2 MB in use.
When I get to my level.lua where I require the modules I then have in level.lua about 10 MB of system memory used.
Require sample in the level.lua file:
-- the level lua -- requiring outside the composer functions: local mygraphics=require ("module1") local mysounds=require("sound") ... composer scenes and level code here...
Now when getting back from level.lua to the mainmenu I still have a lot of system memory in use, like for example about 8MB
When going to the level.lua again and then back to the mainmenu and continuing to do so, the system memory stays at 8MB which now let me wonder if this is because of the very first requiring of the modules?
Are they still kept in memory all the time?
What about requiring the same modules in different other scenes and even other modules? What does this mean for the memory usage?