Entire ZIP file is loaded into memory

Create issue
Issue #63 on hold
Seppi created an issue

So I've found that when a game is launched, the entire zip is loaded into memory.

For a game.love:

-rw-r--r-- 1 seppi users 159M May  9 16:42 game.love

It uses this much memory on launch:

433969 kB: com.binarycocoa.hdf (pid 4155)

For a game.love:

-rw-r--r-- 1 seppi users 196M May  9 16:36 game.love

It uses this much memory on launch:

472216 kB: com.binarycocoa.hdf (pid 4766)

Shouldn't love-android-sdl2 be loading in the content of the zip from the source, not from a zip loaded into memory? Perhaps if this is hard to work around, the system could use the assets/ folder as a directory (e.g. assets/main.lua) instead of assets/game.love.

Comments (8)

  1. Martin Felis repo owner

    I am not sure I understand the issue correctly: you would like to have the files in assets/ loaded directly instead of a zip in the asset folder?

    This is not possible as physfs does not have the ability to mount the asset/ folder inside the apk.

  2. Seppi reporter

    When the app starts up, I don't want it to load the entire APK into memory until I use a love.graphics.newImage etc.

  3. Pablo Mayobre

    This is true, when I build a game I usually use different assets for different platforms, currently I place the needed assets for android and remove the others before zipping (since that also reduces the size) but if I left all the assets it would mean that those unnecessary ones would be loaded into memory too (for example long .ogg clips that will never be played)

  4. Martin Felis repo owner

    Still not sure what the actual issue is. Would you like to draw stuff before game.love is loaded into memory or have finer control when it is loaded?

    In that case it might be possible to add the possibility to mount additional .zip files from the assets/ directory which then hold the heavy stuff. So game.love contains game + minimum of required assets and the heavy stuff is in a separate file. How does that sound?

  5. Pablo Mayobre

    Amazing indeed... Maybe it would mean to make many zip files but I think it could work.

    It should be an alternative that doesn't replace the original method.

  6. Alex Szpakowski

    I'm not familiar with how Android app file storage works, but maybe love.filesystem.mount(love.filesystem.getSourceBaseDirectory(), "") could be taken advantage of? On Windows/Mac/Linux/iOS that line will let love.filesystem read from the directory that the .love file (or executable file, if it's fused like that) is in, when the love game is in fused mode.

  7. Martin Felis repo owner

    Files in the assets/ directory are only accessible using SDL2's RWops. Physfs unfortunately can therefore not mount it. However I could add code such that mounting of zip files within the assets/ directory would be possible.

  8. Log in to comment