[Vala] [PATCH] Enable glib's memory statistics by option

From: JM <interflug1 gmx net>

To: vala-list gnome org

Subject: [Vala] [PATCH] Enable glib's memory statistics by option

Date: Sat, 09 Jan 2010 16:27:26 +0100

Hi all
I wrote a small patch to enable glib's memory statistics support for
vala programs.
It is trivial, but gives the programmer the possibility to use the
mem_profile() call. This function needs an initialization done by the
commandline option from this patch first.
There seems to be some interest to use this function:
http://mail.gnome.org/archives/vala-list/2009-December/msg00128.html
g_mem_profile is described like this in documentation:
...
It outputs the frequency of allocations of different sizes, the total
number of bytes which have been allocated, the total number of bytes
which have been freed, and the difference between the previous two
values, i.e. the number of bytes still in use.
... and it prints a nice table to the terminal.
So, if anybody is interested feel free to add this patch to vala.
I added a testcase ("memory_int32.vala"). If you compile it with a
patched vala and the -C switch, you can see the call to
"g_mem_set_vtable (glib_mem_profiler_table);"
before anything else in the program in the main function. This is
necessary to use the memory statistics functionality.
Regards
Jörn Magens