3

Is there any possibility to execute some custom js code when some object instance is going to be collected by GC in IE9? Maybe DOM nodes can afford this functionality somehow?

I'm trying to build some interop library and need to find a way of controlling object instances lifetimes...

controlflow
  • 6,667
  • 1
  • 31
  • 55
  • possible duplicate of [When are JavaScript objects destroyed?](http://stackoverflow.com/questions/10112670/when-are-javascript-objects-destroyed) – user Apr 02 '14 at 14:36

1 Answers1

0

Not to the best of my knowledge. But you can fake it.

One approach is to manually implement a disposal method on each of your JavaScript objects, and have each object dispose all of its members when it is disposed. It does mean you'll have disposed object instance shells lying around before garbage collection, but as long as you're diligent about disposing instances it gives you reasonable resource management.

Jonathan
  • 8,497
  • 41
  • 35