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

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:

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.

Jörn Magens

Attachment: memstat.patch
Description: Text Data

Attachment: memory_int32.vala
Description: Text Data

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]