Here's a good, if dated, introduction to memory usage analysis under
GNU/Linux: http://ktown.kde.org/~seli/memory/analysis.html

exmap
=====

http://www.berthels.co.uk/exmap/

The memory usage can be checked with exmap. This requires compiling a
kernel module::

  aptitude install exmap-source
  m-a a-i exmap
  sudo modprobe exmap

Now:

* run FreeDink and wait until it's loaded

* run "gexmap" and check Resident Mapped in particular

Note: exmap hasn't been updated since 2006, so it doesn't compile with
recent kernels. Drop a word of encouragement to the author - or even
better send him a patch :)

There's a partial patch at
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=495335 - apparently
there are still issues in the client size.


memprof
=======

http://www.gnome.org/projects/memprof/

It's a GUI to display a progress bar with how much heap your
application is allocating or freeing. Unlike exmap it's updated in
real time, so you'll immediately notice when your code is eating some
more memory, or when it released it.

It's not packaged in Debian because of a 2002->2006 gap in the
development. But we can easily compile it::

  aptitude install libgtk2.0-dev libgnomeui-dev libglade2-dev libgconf2-dev
  aptitude install binutils-dev # libiberty
  ./configure
  make
  sudo make install

Then you can FreeDink through memprof::

  memprof src/freedink -- --window --game ...

Note that memprof only report the heap size (allocated with malloc),
but there's also the data segment or .bss (Block Started by Symbol,
e.g. static arrays, allocated on program startup).


readelf
=======

It can inspect an executable and in particular display the size of the
data segment::

  readelf -S freedink

For example::

  $ readelf -S freedink | grep .bss
    [24] .bss              NOBITS          0808c0e0 0430c4 71d8e0 00  WA  0   0 32

The third numerical field is the size in hexadecimal, i.e. 7.1MB.
