[MLton-user] Tracking down allocations
fluet at tti-c.org
Sun Jul 15 09:18:34 PDT 2007
> I got a confusing result that I
> hope someone on this list can explain to me. I had a function of the
> general form
> fun f intArrayRef1 intArrayRef2 i =
> fun g j k = ...big but non-recursive...
> val j = ...
> val k = ...
> g j k
> and the result of
> mlprof -show-line true -raw true x mlmon.out
> pointed me to the "let" line with 40,000,000,000 allocations being
> done. Where exactly should I look next to see where the allocations
> are being done?
You could try compiling with
mlton -profile alloc -profile-branch true -keep ssa -keep ssa2
That will keep the main intermediate language programs. You ought to be
able to look through the .ssa and .ssa2 files for statements of the form
Enter <fn> <source-pos>
Leave <fn> <source-pos>
These profiling statements should properly nest (according to the
control-flow graph). Looking for your function "f" above, you should be
able to trace out the activities going on. Allocations aren't explicitly
marked in the ILs, but basically anything that looks like
x = C (x_1, x_2, x_3)
corresponds to an allocation, as does
x = Array_array (y)
Also, if you are working with a recent build of the compiler from the
Subversion repository, then the recent compiler flag
will additionally profile (expansive) val bindings (such as val j = ...
and val k = ... in your code above), which could expose finer-grained
More information about the MLton-user