[gclist] The ML Kit with Regions?
Tue, 5 Aug 97 17:32:14 -0700
I am trying to understand The ML Kit with Regions
In Oberon or Java, programmers have to make the "artificial" distinction
between the objects on stack and the objects on heap. However, this
effort on the programmers' part can reduce the heap usage, to the extent
that we can achieve a good overall performance even with a classic
mark-n-sweep garbage collector. So I think it is a great idea to do some
compile-time analyses to the ML programs, to achieve the performance
comparable to those stack-based languages, in terms of both speed and
However, the compiler cannot perform the "compile-time garbage
collection" in all cases, so sometimes you end up with memory leaks. The
ML Kit with Regions comes with a profiler, so you can monitor your
program, catch these cases, and explicitly insert the region annotations
to fix the leaks.
A profiler is like a debugger. We make mistakes and we need the debugger
to help us catch bugs, but still we have to do our best to aim at a good
design that is ideally bug-less. So I am not quite comfortable with the
idea of catching all the memory leaks solely with the profiler: Some
leaks may escape from the profiling sessions. You may have a library that
works perfectly with one program, but leaks with another program.
On the other hand, tail-recursion elimination can be viewed as a kind of
compile-time (stack space) garbage collection, but I am quite comfortable
with tail-recursion elimination. When I code a program, I can tell myself
"This recursive call is a tail recursion, and the compiler will optimize
it out, so it's ok".
So my question is: Is it possible to obtain some "intuitive feelings"
toward the region management, just like I have had with tail recursion?