Hi Alex, > As far as I know, there is no (supported) way to do this.
thanks for response. I was afraid of this :-( I will probably file this as a bug, because it seems logical to me that when a JS context is destroyed, all data objects in it should get GC'ed. What is your opinion? O. > > There are other ways around it, however. For instance, you can keep a > list of the database connections that are open in the current context, > and when you get rid of the context, just go through that list and > close them. > > I ran into a similar problem with files; although the memory and the > handle to the file would be destroyed by the operating system, the > stream's "flush" command would not be called, and as such, the output > would be incomplete. I rigged up an auto-deleter that basically > allowed me to say: > //on object creation > autoDestroy(theObject); > //on object deletion > cancelAutoDestroy(theObject); > > The auto deleter would then be triggered when the program exited. > > Alex > > On Feb 25, 2009, at 12:31 PM, Ondrej Zara wrote: > >> >> Bump... is there any V8 dev that can confirm that one cannot truly >> guarantee that GC of an object will ever occur? >> >> >> O. >> >> >> 2009/2/24 ondras <[email protected]>: >>> >>> Hi, >>> >>> I have the following scenario: >>> >>> - a JS class / function is defined in C++; this class represents DB >>> connection. >>> - I have a persistent handle to that class's instance. >>> - I make the handle weak, wanting to be informed when GC collects it: >>> this way, I can close the DB connection when it is no longer used. >>> >>> This solution works, provided that GC gets a chance to clean the >>> (lost) reference. However, I want to make sure that the MakeWeak >>> callback gets executed _always_ (at least when my script ends and >>> Context gets deleted), because after execution ends, I don't want any >>> DB connections hanging around. Is there some way to "purge" whole >>> global object / context so everything gets GC'ed ? >>> >>> >>> Thanks a lot, >>> Ondrej Zara >>> >>>> >>> >> >> > > > Alex Iskander > Web and Marketing > TPSi > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
