[MLton-devel] very unfortunate behavior when profiling allocations

Henry Cejtin henry@sourcelight.com
Thu, 3 Jul 2003 02:55:04 -0500


My  notion  of  having an ML atExit was that just as in C, it is useful to be
able to specify a function to be called on  program  exit.   One  possibility
would  be  that  the  semantics  would  run  the function even if the program
`exits' because of an unhandled exception or running  out  of  memory.   This
should  make the implementation easier since you then would know that all the
stack frames are dead.

The problem I was mentioning was that in C, the  semantics  of  atexit()  are
that  if you end the program by calling exit(), or having main() return, then
the functions are called, but if you end the program by  calling  _exit()  or
getting  a  signal  then  they are not run.  This is used in C since it means
that when you want to end the program you can decide, at that point,  if  the
atexit functions should be run.  This is probably not a big deal for ML.

Any  way, I agree that the design of just having an exception for running out
of memory isn't completely clear, but I think it is something that  would  be
useful.  I would still think that just waiting until you are `completely out'
would be good enough because of the  stack  frames  and  corresponding  items
being dead, but who knows.

Either  way,  I am not particularly arguing that the mlprof dumping code stay
in ML, just pointing out that it argued that an ML atExit function,  and  one
which  got  run  even  when  running  out  of  memory  or having an unhandled
exception, is a useful thing.



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel