Browse thread
Questions on replacing finalizers and memory footprints
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] Questions on replacing finalizers and memory footprints |
On Thu, Dec 06, 2007 at 11:12:04AM +0000, Thomas Fischbacher wrote: > Also, is there a simple way to implement a function (perhaps using > Obj.magic) which will walk a (possibly circular) network of tuples, > arrays, variadic entities and lists, and return the total number of > bytes used up by that structure? I see that this should be possible > in principle with the present implementation of the runtime if one > could get some basic information about the internal type of an array. You might get some ideas by having a look at the ancient module (http://merjis.com/developers/ancient), specifically at how the C function _mark in ancient_c.c is implemented. Also have a look at the implementation of the Marshal module in the OCaml sources which takes a slightly different approach. If you want to do this in pure OCaml, probably your best bet would be to just Marshal the structure and count how big it is. It'll be slow of course. Rich. -- Richard Jones Red Hat