Bugzilla – Bug 18610
Transferable should expose a close() method
Last modified: 2012-10-19 21:25:23 UTC
Every Transferable object is neuterable. Neutering is useful in cases other than transferring.
For example, being able to programmatically neuter a large ArrayBuffer when you're finished performing computations in it would be useful, to give the UA the option of freeing the memory associated with it immediately instead of waiting for GC.
Any object big enough for Transferable to be useful (aside from MessagePort, which is a minor anomaly) is also big enough for close() to be useful. Instead of APIs handling this one by one, this should simply be supported for all Transferables.
This should be no burden for any API supporting Transferable, since they already have to do the work of implementing the "neuter" concept.
(MessagePort already has a close() method. It would be nice if its behavior could be aligned with Transferable.close(), so they can be the same method.)
You don't need to close a large object. Just forget the object and let it GC.