Add 0x400 flag to OCAMLRUNPARAM=v. It displays the total number of words allocated by the program just before it exits.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15499 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Alain Frisch 2014-10-09 11:50:23 +00:00
parent ccfa5d7fb1
commit 33542b3440
1 changed files with 12 additions and 0 deletions

View File

@ -48,6 +48,7 @@
#include "signals.h"
#include "stacks.h"
#include "sys.h"
#include "gc_ctrl.h"
static char * error_message(void)
{
@ -93,6 +94,17 @@ CAMLexport void caml_sys_io_error(value arg)
CAMLprim value caml_sys_exit(value retcode)
{
if ((caml_verb_gc & 0x400) != 0) {
/* cf caml_gc_counters */
double minwords = caml_stat_minor_words
+ (double) Wsize_bsize (caml_young_end - caml_young_ptr);
double prowords = caml_stat_promoted_words;
double majwords = caml_stat_major_words + (double) caml_allocated_words;
double allocated_words =
minwords + majwords - prowords;
caml_gc_message(0x400, "## Total allocated words: %ld\n", (long)allocated_words);
}
#ifndef NATIVE_CODE
caml_debugger(PROGRAM_EXIT);
#endif