#1908 Used Memory => how to mesure it?

Xan Sun 10 Jun 2012

Hi,

Is there any tool for knowing how much memory is used by Fantom program? If it's, it could be used too for non-fantom programs?

Thanks, Xan.

SlimerDude Sun 10 Jun 2012

Assuming you want to look at JVM memory usage, there's a host of JVM profiling tools out there... but for basic stuff you can just use JConsole that's bundled with the JDK.

  1. Start your Fantom app
  2. type JConsole on the command line
  3. select your Fantom process from the list

brian Sun 10 Jun 2012

You can get current heap usage from:

Env.cur.diagnostics["mem.heap"]

In general most important two things for managing JVM memory:

  1. give yourself enough heap size on startup
  2. make sure have nice working chunk of that heap (for example steady state heap usage is only 60% of max or whatnot)

Xan Sun 10 Jun 2012

Thanks, brian. @SlimerDude: my app is too short for waiting jconsole... thanks

Is there any not JVM-specific tool for that? That we can use for C or python scripts and compare JVM against those?

Thanks, Xan.

Xan Sun 10 Jun 2012

I get error with this:

echo("Memòria consumida ${echo(Env.cur.diagnostics["mem.heap"]}")
$ fan mget-memoria.fan 
/home/xan/proves/yot-ng/propi/codi/aranya-fantom/mget-memoria.fan(61,57): Unexpected end of Str literal, missing }
ERROR: cannot compile script

What happens? Wrong syntax?

Thanks, Xan.

brian Sun 10 Jun 2012

Don't try to use a string literal inside a string literal (in fact we are going to make that an error)

echo("Memòria consumida " + Env.cur.diagnostics["mem.heap"])

Xan Mon 11 Jun 2012

Mmmm... thanks, but with "$var" don't you punt the value of the variable var? Why don't work this?

Xan.

Login or Signup to reply.