Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Monitoring Memory Usage — Gideros Forum

Monitoring Memory Usage

chipster123chipster123 Member
edited December 2011 in General questions
I'm looking for advice/techniques on how to monitory memory usage of a gideros project.
Currently I'm flying blind just throwing things on a scene until it looks good. I need to keep an eye on resources utilization.

Thanks in advance,
Chip

Comments

  • MikeHartMikeHart Guru
    edited December 2011
    Hi chipster,

    Atilim posted this peace of code a few days ago:
    local monitorMem = function()
        collectgarbage()
        print( "\nMemUsage: " .. collectgarbage("count") )
    end
     
    stage:addEventListener(Event.ENTER_FRAME, monitorMem)
  • atilimatilim Maintainer
    An addition to @MikeHart, to monitor texture memory usage, you can look at logcat (for Android) or Xcode's console _while waiting for the next version_. You should see a log like:

    Inserting sky_world.png to the texture cache. Total memory is 1024 KB.
    Inserting bird_black_01.png to the texture cache. Total memory is 1056 KB.
    Inserting bird_black_02.png to the texture cache. Total memory is 1072 KB.
    Inserting bird_black_03.png to the texture cache. Total memory is 1104 KB.
    Increasing refcount of bird_black_01.png. New refcount is 2.
    Increasing refcount of bird_black_02.png. New refcount is 2.
    Increasing refcount of bird_black_03.png. New refcount is 2.
    Inserting bird_white_01.png to the texture cache. Total memory is 1136 KB.
    Inserting bird_white_02.png to the texture cache. Total memory is 1152 KB.
    Inserting bird_white_03.png to the texture cache. Total memory is 1184 KB.

  • RickyngkRickyngk Member
    edited March 2012
    Hi,

    I've see a message:
    log: Increasing refcount of file1.png. New refcount is 2.
    After that,
    log: Decreasing refcount of file1.png. New refcount is 1.
    Is it good or bad? "refcount is 1" that mean only one pointer is pointed to it, isn't it?

    Edit: I have another question. garbage collector will collect resource when refcount is 0 or 1?
  • atilimatilim Maintainer
    Exactly. When it reaches 0, it will be deleted.
Sign In or Register to comment.