I don't mind being left with a load of handles knocking around as this is only for testing weak object callbacks.
Thanks for the note about --expose-gc; since all my test suites are scripts, it might be perfect. And, if not, I'm sure I can find a way to call it from C++. :-) Pete Gontier <http://pete.gontier.org/> On Oct 2, 2008, at 4:31 AM, Garry wrote: > > If you throw a load of handles at it, it'll probably push all the > older handles out, but you'll still be left with a load of handles > knocking around. > > I'd appreciate if this collectgarbage thing was official too (I also > dislike having to edit the v8 Source). > > This was mentioned in that other thread: > >> If you want to trigger a GC, you could look at >> the GC extension. For example, when running with --expose-gc, a gc() >> method will be installed on the global object. > > Which I expect would have the exact same effect as CollectAllGarbage.. > (it just feels wrong to be calling a js function to do this). > > garry > > On Oct 2, 2:03 am, Pete Gontier <[EMAIL PROTECTED]> wrote: >> More specifically: >> >> http://groups.google.com/group/v8-users/msg/47d3cc9c9a3e9d0a >> >> On Sep 27, 2008, at 12:30 PM, Garry wrote: >> >>> Thanks - for future reference for anyone looking for the same >>> thing.. >>> I ``fixed'' this by exposing v8::internal::Heap::CollectAllGarbage() >>> by adding it to the v8:V8 interface in api.cc >> >>> void V8::CollectAllGarbage() >>> { >>> i::Heap::CollectAllGarbage(); >>> } >> >>> Calling this at choice places (right before exit, after disposing a >>> context etc) solves the problem completely for me. >> >> This is just what the doctor ordered. >> >> I'm not terribly enamored of the idea of altering V8 sources because >> it becomes a maintenance hassle to stay in synch, and anyway I >> ultimately want to link to the inevitable official Ubuntu binary >> shared library which won't have my changes, but one does what one >> must. >> >> Another technique discussed in the thread was to allocate (and leak, >> from a C++ perspective) a bunch of handles to nudge V8 into deciding >> for itself to collect garbage. I suppose this could be done without >> altering V8 sources, but then the question becomes: how many handles >> is enough? The thread says it's around 4000... for now... >> >> Pete Gontier <http://pete.gontier.org/> >> >> On Oct 1, 2008, at 8:10 AM, deanm wrote: >> >>> http://groups.google.com/group/v8-users/browse_thread/thread/9effc949 >>> ... >> >>> On Oct 1, 5:07 pm, Pete Gontier <[EMAIL PROTECTED]> wrote: >>>> I would like to be able to test a WeakReferenceCallback. >> >>>> It would seem that in order to do that I need to induce garbage >>>> collection at a predictable time. >> >>>> So far, I don't see a way to do that. Ideas? >> >>>> Pete Gontier <http://pete.gontier.org/> > > --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
