The external memory counter is really just a hint to the garbage
collector and we may, and probably will, change the exact way it is
used, but here's how it currently works. Whenever garbage is
collected in new-space some of the objects are promoted to old-space,
which is garbage collected less often. Between collections we keep a
count of how much data has been promoted since the last old-space gc
and this number includes the amount of external memory allocated since
the last gc, as set through AdjustAmountOfExternalAllocatedMemory.
One of the rules that determines whether or not to collect old-space
looks at the amount of data that has been promoted, and when it
reaches a certain limit we do a full garbage collection. So it is
indeed used.
Garbage is only collected when new-space is full, so if you allocate
few but extremely big objects you may run out of memory before
new-space has been filled. That could be the explanation for bad
behavior when really big objects are involved.
-- Christian
On Thu, Sep 25, 2008 at 5:11 PM, Northorn <[EMAIL PROTECTED]> wrote:
>
> Also, you can use v8::V8::AdjustAmountOfExternalAllocatedMemory() to
> tell the GC how much external memory those handles are referring to.
>
> I'm not sure this actually does anything currently. It seems to GC
> more based on the number of handles you've allocated. If you're
> allocating very large objects very quickly your app will exhaust its
> address space and crash before GC kicks in.
>
>
>
> On Sep 25, 10:07 am, Northorn <[EMAIL PROTECTED]> wrote:
>> I had to put a:
>>
>> v8::HandleScope handle_scope;
>>
>> in this function. If not I would occasionally get an error about not
>> having a handle scope in this function.
>>
>> On Sep 22, 3:57 am, [EMAIL PROTECTED] wrote:
>>
>> > Thank you for the example.
>> > I also use:
>> > ........
>> > Persistent<Object> self = Persistent<Object>::New(args.Holder());
>> > self.MakeWeak(0, Point_Destroy);
>>
>> > self->SetInternalField(0, External::New(p));
>> > return self;}
>>
>> > void Point_Destroy(Persistent<Object> self, void* parameter)
>> > {
>> > Local<External> external =
>> > Local<External>::Cast(self->GetInternalField(0));
>>
>> > delete static_cast<Point*>(external->Value());
>>
>> > }
>>
>> > but the "Point_Destroy" Function is never called. So when should it be
>> > called in your example?
>>
>> > Thanks
>> > bg
> >
>
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---