Version franēaise
Home     About     Download     Resources     Contact us    
Browse thread
Questions on replacing finalizers and memory footprints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: dmitry grebeniuk <gds-mlsts@m...>
Subject: Re: [Caml-list] Questions on replacing finalizers and memory footprints
Hello, Thomas.

TF> Also, is there a simple way to implement a function
TF> (perhaps using Obj.magic) which will walk a (possibly
TF> circular) network of tuples, arrays, variadic entities
TF> and lists, and return the total number of bytes used up
TF> by that structure? I see that this should be possible in
TF> principle with the present implementation of the runtime
TF> if one could get some basic information about the
TF> internal type of an array.

 When I faced this problem, I wrote a function to
get the size of value.  This is a C-world function
which walks though values and marks visited
values by changing (and then restoring) their "color".
Colors are stored using RLE-like compression to
decrease memory usage.

  But it's possible to calculate the size of the value
using pure ocaml code, using Obj to examine values and
Hashtbl to store visited values.  It will work well
with small or medium-sized values.

-- 
WBR,
 dmitry             mailto:gds-mlsts@moldavcable.com