[Mono-dev] Reference queue

"Konrad M. Kruczyński" konrad.kruczynski at gmail.com
Tue Jan 24 00:22:00 UTC 2012


Thanks for the answer.

Here is the case:
Let's say I have a class which contains some data in temporary
file (for example some kind of cache which should not stay in memory).
I'd like to have this file removed when object of this class dies. I
can implement a finalizer but if I do this, object will be reclaimed
later than it should, also putting additional pressure on GC. Problems
of objects with finalizers which are not manually invoked are generally
known. And this is scenario where such object can be shared and does
not fit into any kind of using block.

I think that mentioned API can resolve that kind of problems, because
I can set up a callback which deletes temporary file *after* object's
death. Therefore it is processed like any other object, without being
in special collection for disposable objects.

I think it would bring significant performance gain, especially if
objects are created often and we expect they die soon. It should be
measured, but for that I need some kind of API.

What do you think?

 > We've thought about exporting such interface, but the maintenance burden
 > made us back off.
 > This interface has some short-coming and exposing it to managed code
 > has it's problems. For example, it doesn't support unregistering.
 > But, if you make your case on why such a feature would help you, I
 > can look into it.

--
Konrad


More information about the Mono-devel-list mailing list