2009/11/25 Xiang Zhong <[email protected]>:
> Suppose they speficy heap constraint seperately
> with SetResourceConstraints(ResourceConstraints* constraints)

You can only use that interface once to set the heap size (and you
have to do it before initializing V8).  It applies to all threads.

>
>
> On Wed, Nov 25, 2009 at 4:15 PM, Xiang Zhong <[email protected]> wrote:
>>
>> Hi, Mads,
>>
>> Yeah, I see. Thanks for your answer.
>> Another question :-), if we enable multi-thread by v8::V8::Locker, will
>> other threads dead too if one thread encounter OOM?
>>
>> Sincerely~
>> Xiang
>>
>>
>>
>> On Wed, Nov 25, 2009 at 3:54 PM, Mads Sig Ager <[email protected]> wrote:
>>>
>>> Nothing like that exists.  We do not know in advance that we are going
>>> to run out of memory.
>>>
>>> -- Mads
>>>
>>> On Wed, Nov 25, 2009 at 8:52 AM, Xiang Zhong <[email protected]> wrote:
>>> >
>>> > Hi, Mads,
>>> >
>>> > Is there a way that the caller can get notified before an OOM situation
>>> > happen?
>>> > If that is possible, the caller can call v8::V8::TerminateExecution()
>>> > beforehand, and dispose the global object in time to free memory.
>>> > That will save v8 from being dead or crashing.
>>> >
>>> > We can hook a callback through SetGlobalGCEpilogueCallback() after GC
>>> > happen, if we can get a flag some like "
>>> > GC_FAIL_GOING_TO_OUT_OF_MEMORY",
>>> > then it is possible to check the flag and terminate in time.
>>> > Does there exist something like that?
>>> >
>>> > Wishes~
>>> > Xiang
>>> >
>>> > On Wed, Nov 25, 2009 at 3:35 PM, Mads Sig Ager <[email protected]>
>>> > wrote:
>>> >>
>>> >> An out of memory situation can leave the VM in an inconsistent state,
>>> >> so it is not possible to continue.  It is therefore the expected
>>> >> behavior that we cannot continue here.
>>> >>
>>> >> Cheers,    -- Mads
>>> >>
>>> >> On Wed, Nov 25, 2009 at 3:45 AM, Xiang <[email protected]> wrote:
>>> >> >
>>> >> > Hi, All,
>>> >> >
>>> >> > I have declared  v8::V8::IgnoreOutOfMemoryException(), and the out
>>> >> > of
>>> >> > memory exception is caught by trycatch as expected.
>>> >> >
>>> >> > However, after disposing the current context, we can't create a new
>>> >> > context.
>>> >> >
>>> >> > The handle is empty.
>>> >> >
>>> >> > Please check the following UT case:
>>> >> >
>>> >> > Reproduction steps
>>> >> > ---------------------------------------------------------
>>> >> > Please add the following case to test-api.cc,
>>> >> >
>>> >> > When creating a new context,
>>> >> >   v8::Persistent<v8::Context> context = v8::Context::New(0,
>>> >> > v8::Handle<v8::ObjectTemplate>(), v8::Handle<v8::Value>());
>>> >> > It will fail
>>> >> >
>>> >> > TEST(CreateNewContextAfterOutOfMemory) {
>>> >> >        // It's not possible to read a snapshot into a heap with
>>> >> > different
>>> >> > dimensions.
>>> >> >  if (v8::internal::Snapshot::IsEnabled()) return;
>>> >> >  // Set heap limits.
>>> >> >  static const int K = 1024;
>>> >> >  v8::ResourceConstraints constraints;
>>> >> >  constraints.set_max_young_space_size(256 * K);
>>> >> >  constraints.set_max_old_space_size(4 * K * K);
>>> >> >  v8::SetResourceConstraints(&constraints);
>>> >> >
>>> >> >  // Execute a script that causes out of memory.
>>> >> >  v8::HandleScope scope;
>>> >> >  {
>>> >> >    LocalContext context;
>>> >> >    v8::V8::IgnoreOutOfMemoryException();
>>> >> >    Local<Script> script =
>>> >> >        Script::Compile(String::New(js_code_causing_out_of_memory));
>>> >> >    Local<Value> result = script->Run();
>>> >> >
>>> >> >    // Check for out of memory state.
>>> >> >    CHECK(result.IsEmpty());
>>> >> >    CHECK(context->HasOutOfMemoryException());
>>> >> >  }
>>> >> >
>>> >> >  {
>>> >> >        v8::Persistent<v8::Context> context = v8::Context::New(0,
>>> >> > v8::Handle<v8::ObjectTemplate>(), v8::Handle<v8::Value>());
>>> >> >
>>> >> >
>>> >> >        //Check here!
>>> >> >
>>> >> >        //I think we should  be allowed to create a new context
>>> >> >        //And the Handle should not be empty
>>> >> >        CHECK(!context.IsEmpty());
>>> >> >        context.Dispose();
>>> >> >        context.Clear();
>>> >> >  }
>>> >> > }
>>> >> > >
>>> >> >
>>> >
>>> >
>>> >
>>> > >
>>> >
>>>
>>>
>>
>
>
> >
>

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

Reply via email to