I see. And you have to do real garbage collection, and not just delete  
all the objects in a context, because an object could exist in more  
than one context. The garbage collection would then occur globally,  
which could cause a slowdown.

What about a manual cleanup function? This could, perhaps, be  
potentially useful for Chromium; it could be called when a frame is  
closed, but only be called once if the whole process is being closed.

Alex

On Feb 26, 2009, at 6:53 AM, Søren Gjesse wrote:

> Take a look at http://codereview.chromium.org/27201. It runs a full  
> GC when a new context is created and contexts have been destroyed  
> since a new context was created the last time.
>
> This is still somewhat experimental, as adding such GC heuristics  
> sometimes have unexpected negative results. For this change the  
> reason for postponing the GC until a new context is created is due  
> to the fact that in Chromium each frame has its own context, and  
> leaving a page with say 10 iframes would cause 10 GC's which is not  
> desired.
>
> Regards,
> Søren
>
> On Thu, Feb 26, 2009 at 8:05 AM, Ondrej Zara <[email protected]>  
> wrote:
>
> 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
> >
> >
> >
> >
> >
> > >
> >
>
>
>
>
> >

Alex Iskander
Web and Marketing
TPSi




--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to