The NewType::~NewType is not called, the test code as follow.

#include "v8.h"                                                             
                                              
#include "libplatform/libplatform.h"                                       
                                               
                                                                            
                                              
class NewType                                                               
                                              
{                                                                           
                                              
    public:                                                                 
                                              
        static void WeakPtrCallback(const v8::WeakCallbackData<v8::Object, 
NewType>& data)                                
        {                                                                   
                                              
            delete data.GetParameter();                                     
                                              
        }                                                                   
                                              
        NewType(v8::Isolate *isolate, v8::Handle<v8::Object> handle): 
isolate_(isolate)                                   
        {                                                                   
                                              
            printf("%s\n", __PRETTY_FUNCTION__);                           
                                               
            handle_.Reset(isolate, handle);                                 
                                              
            handle_.SetWeak(this, WeakPtrCallback);                         
                                              
        }                                                                   
                                              
        ~NewType()                                                         
                                               
        {                                                                   
                                              
            handle_.Reset();                                               
                                               
            printf("%s\n", __PRETTY_FUNCTION__);                           
                                               
        }                                                                   
                                              
    private:                                                               
                                               
        v8::Persistent<v8::Object> handle_;                                 
                                              
        v8::Isolate *isolate_;                                             
                                               
                                                                            
                                              
};                                                                         
                                               
                                                                            
                                              
int main(int argc, char *argv[])                                           
                                               
{                                                                           
                                              
    v8::Platform* platform = v8::platform::CreateDefaultPlatform();         
                                              
    v8::V8::InitializePlatform(platform);                                   
                                              
    v8::V8::Initialize();                                                   
                                              
    v8::V8::SetFlagsFromCommandLine(&argc, argv, true);                     
                                              
    v8::Isolate* isolate = v8::Isolate::New();                             
                                               
    {                                                                       
                                              
        v8::Isolate::Scope isolate_scope(isolate);                         
                                               
        v8::HandleScope handle_scope(isolate);                             
                                               
        v8::Local<v8::Context> context = v8::Context::New(isolate);         
                                              
        v8::Context::Scope context_scope(context);                         
                                               
        v8::Local<v8::ObjectTemplate> tpl = 
v8::ObjectTemplate::New(isolate);                                           
  
        tpl->SetInternalFieldCount(1);                                     
                                               
        v8::Local<v8::Object> value = tpl->NewInstance();                   
                                              
        new NewType(isolate, value);                                       
                                               
        context->Global()->Set(v8::String::NewFromUtf8(isolate, "test"), 
value);                                          
    }                                                                       
                                              
    
isolate->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCollection);
 
                                    
    isolate->Dispose();                                                     
                                              
    v8::V8::Dispose();                                                     
                                               
    v8::V8::ShutdownPlatform();                                             
                                              
    delete platform;                                                       
                                               
}                                                                           
                                              

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to