[MLton] Memory layout debugging
Wesley W. Terpstra
wesley at terpstra.ca
Sun Nov 2 07:40:46 PST 2008
Something I would find very useful is to be able to get a graphical
picture of the memory used by my application from a specified root.
MLton.size is nice, but I was thinking of a similar function that
instead created a graphviz dot format file. Nodes in the graph are
addresses in the heap, and arcs correspond to objptrs. I bet this
would be a very easy picture for 'dot' to render as cycles are not
that common in SML programs' memory. This part I am sure I'd have no
trouble implementing.
To make this picture easier to understand, it would be helpful if
objects had their point of allocation or type marked. I know that
-profile alloc is able to record the # of allocations at a point in
the program. However, I also understand that there may be several
points in the program which allocate a given objectType. What sort of
sensible information could I provide based on the object type?
The other question is how to get this information back to ML. I could
just spew the graphviz data to stderr, but this seems crude. I could
also allocate a C-side string that I keep growing as the dotfile
grows, then convert this string to an ML-string inside the basis
library. What's best?
I think that a tool like this would not only help the working
programmer, but would also help MLton development pick the best places
to make representation optimizations.
Thoughts?
More information about the MLton
mailing list