Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Hundreds of Lua files and performance. — Gideros Forum

Hundreds of Lua files and performance.

ChangChang Member
edited November 2012 in General questions
Let's say I am using SceneManager, and I have hundreds of scenes. In this case we have hundreds of Lua files executed and the memory usage is above 2000. Does this affect the performance of the app, especially on low-end android devices? So far I've tried with 30-40 scenes and the memory usage is above 1300. But performance is still good.

Comments

  • OZAppsOZApps Guru
    Accepted Answer
    @chang, you can set the lua files to not be executed unless you explicitly use them with require, that way you an avoid loading every .Lua file into memory and use the ones you want when you want. Plus you can always use the unload command to remove the file you do not need. Hopefully that can provide you with more memory for your app.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
    +1 -1 (+1 / -0 )Share on Facebook
  • @OZApps thanks for the info! I totally didn't release that gideros has the "exclude from execution". Just realized it today. =)

    Btw I'm using the unrequire function from a code snippet I found:
    http://snippets.luacode.org/snippets/unrequire_121
    local function unrequire(m)
     
    package.loaded[m] = nil
    _G[m] = nil
     
    -- Search for the shared library handle in the registry and erase it
    local registry = debug.getregistry()
    local nMatches, mKey, mt = 0, nil, registry['_LOADLIB']
     
    for key, ud in pairs(registry) do
    if type(key) == 'string' and type(ud) == 'userdata' and getmetatable(ud) == mt and string.find(key, "LOADLIB: .*" .. m) then
    nMatches = nMatches + 1
    if nMatches > 1 then
    return false, "More than one possible key for module '" .. m .. "'. Can't decide which one to erase."
    end
    mKey = key
    end
    end
     
    if mKey then
    registry[mKey] = nil
    end
     
    return true
    end
  • Let's say I am using SceneManager, and I have hundreds of scenes. In this case we have hundreds of Lua files executed and the memory usage is above 2000. Does this affect the performance of the app, especially on low-end android devices? So far I've tried with 30-40 scenes and the memory usage is above 1300. But performance is still good.
    I haven't seen your code so I can't comment too much however I would say that on the face of it I think your code organisation is probably a little off.

    I'd guess you've got a LOT of replicated code that you could probably condense into smaller re-useable sub modules that might drastically reduce the size of the code and the number of scenes, alternatively you might want to look at a more "data driven" approach where you have a small number of reusable scenes that are controlled from a set of data files.

    Just my $0.02

    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Sign In or Register to comment.