[MLton-user] Does GC always trigger MLtonFinalizable?

Wesley W. Terpstra wesley at terpstra.ca
Fri Feb 16 11:23:37 PST 2007


On Feb 16, 2007, at 7:06 PM, Henry Cejtin wrote:
> A full GC is quite expensive so I wouldn't use MLton.GC.collect as  
> the only way
> to close the database.  You could use finalizers to do the close if  
> needed,
> but normally just do the close by hand.

I agree that a full GC is expensive, but you shouldn't be opening/ 
closing the database very often.

I really want queries to close automatically. They are just memory  
objects. It's quite cumbersome to have to free them yourself (and  
very un-SML-like).

The database handle has actual file descriptors and other system  
resources. I wanted people to explicitly close this like in the basis.

However, you may be right. If I use finalizers for queries, perhaps I  
should also use a finalizer for the database. Although, then it is  
possible to leak file handles until a GC.

I don't know what is best. I do know that closing queries is a PITA.

Thoughts?




More information about the MLton-user mailing list