How do I Keep my memory useage as low as possible

0 favourites
  • 7 posts
From the Asset Store
High Low is a casino game using luck and points accumulation.
  • Hi all!

    I'm working on a fun game. It's big and advanced..

    Now.. i always take a look at the memory usage with every step i do.

    Yet i want to create a character "wardrobe" where you can "tune" your character with some fun suits and stuff..

    As you can image, every single piece of clothes ( sprite ) i put in my memory limit extends.

    Every single suit(sprite) i put in takes up 0.8MB memory limit each..

    Is there any way i can keep my Memory Limit low but my sprites high !?

    Thanks in advance!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Have you tried make one sprite for a type of costume and populating that with images ?

    Also how exactly do you test the RAM memory used? Just by looking at the counter on the status bar in Construct 2 at the bottom?

  • Hi Je Fawk,

    Thanks for your reply.

    Yes i am always thinking in the memory save way but non-the-less some things can't be changed.. I have one sprite with all other clothes as animation frames ( complete suits, no lose parts ).

    Yet i indeed only look at the counter on the status bar.

    I guess this isn't probably precisely what it will be once exported etc..

    Yet i want to add more than 20-30 different sprites ( frames ) which takes 0.8 mb each what will result in about 20MB..

    I'm just not sure how seriously i should take that memory usage in the bottom status bar..

  • I read a lot of optimization info regarding Construct 2, however i could not find anything related to RAM usage, only CPU and GPU.

    Your best bet on an Android device would be to use an app. Sadly I cannot post URLs

    My suggestion is to compare the Construct 2 memory number with those in a test project while using a few scenarios. You might find that the objects not on the screen might not be loaded into the RAM, thus your wardrobe must display as few sprites per page as possible to make it RAM-efficient.

    Here's a snippet on how to create a log file with RAM usage in Android:

    [quote:oub6smek]How to get a heap dump

    I created the heap dump using the emulator.

    I created a new avd for the 1.5 preview:

    android create avd -n test -t 2
    emulator -avd test[/code:oub6smek]
    
    Then you can logon to the emulated phone and make sure that the /data/misc directory is writable :
    
    [code:oub6smek]adb shell
    chmod 777 /data/misc
    exit
    [/code:oub6smek]
    Heap dumps are actually created by sending the process a SIGUSR1 (-10) signal.
    
    [code:oub6smek]adb shell ps[/code:oub6smek]
    
    check for the pid of your application
    
    [code:oub6smek]adb shell kill -10 pid[/code:oub6smek]
    
    You can check with
    
    [code:oub6smek]adb shell logcat[/code:oub6smek]
    whether it works. You should see something like:
    
    [code:oub6smek]I/dalvikvm(  ): threadid=7: reacting to signal 10 I/dalvikvm(  ): SIGUSR1 forcing GC and HPROF dump I/dalvikvm(  ): hprof: dumping VM heap to "/data/misc/heap-dump-tm- pid.hprof-hptemp". I/dalvikvm(  ): hprof: dumping heap strings to "/data/misc/heap-dump-tm124026 3144-pid.hprof". I/dalvikvm(  ): hprof: heap dump completed, temp file removed D/dalvikvm(  ): GC freed 1292 objects / 92440 bytes in 11 sec D/dalvikvm(  ): GC freed 215 objects / 9400 bytes in 963ms[/code:oub6smek]
    
    now you can copy the heap dump from the (emulated) phone to the Desktop machine:
    
    [code:oub6smek]adb pull /data/misc/heap-dump-tm-pid.hprof address.hprof[/code:oub6smek]
      
    Now the file you will get does not conform to the "standard" Sun .hprof format but is written in Dalvik's own format and you need to convert it:
    
    [code:oub6smek]hprof-conv heap-dump-tm-pid.hprof 4mat.hprof[/code:oub6smek]
    
    Now you can use the Eclipse Memory analyzer to analyze the memory usage of your application.
    
    
    Good luck!
  • I'm guessing not all wardrobes will be worn at the same time, so there's no need for all of them to be on the layout..

    I guess I'd put the wardrobes as seperate sprites on a seperate layout and only create the one needed through events.

    Would that work in your situation?

  • Hi Yall,

    Thanks for the awnsers.

    I will take a look into the long story.

    As you say, i indeed not taking the whole wardrobe..

    So this makes my question more obvious.. Since memory usage going up once i insert a sprite. Even when i'm not placing it in game the memory usage rises.

    So this makes my question complete:

    "Does memory usage slow down the game EVEN if you don't add all the sprites in-game at once."

    I could have a character which can only run left and right, yet with 100 animation frames that are not used. Yet my memory usage will be 100MB.

    Does this impact my game itself?

    Ofcourse i can try it out but my PC runs it smooth as always, yet i can only test on a Note 2 which is pretty smooth also..

  • Use emulators, make a test project with a lot more sprites and try to reach the maximum RAM for the low-end emulated device (which is usually 512MB). Once you reach by whatever means possible the 512 in Construct, export it and emulate it; see how it goes.

    You can then extrapolate the results for the higher end devices.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)