int main(int argc , char* argv[]) {
map<string , string> options; string file; ParseOptions(argc , argv , &options , &file); if (file.empty()) { fprintf(stderr , "No script was specified.\n"); return 1; } // 初始化v8 v8::V8::InitializeICUDefaultLocation(argv[0]); v8::V8::InitializeExternalStartupData(argv[0]); std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform (); v8::V8::InitializePlatform(platform.get()); v8::V8::Initialize(); Isolate::CreateParams create_params; create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator:: NewDefaultAllocator(); Isolate* isolate = Isolate::New(create_params); gisolate = isolate; { Isolate::Scope isolate_scope(isolate); HandleScope scope(isolate); Local<String> source; if (!ReadFile(isolate , file).ToLocal(&source)) { fprintf(stderr , "Error reading '%s'.\n" , file.c_str()); return 1; } JsHttpRequestProcessor processor(isolate , source); map<string , string> output; if (!processor.Initialize(&options , &output)) { fprintf(stderr , "Error initializing processor.\n"); return 1; } if (!ProcessEntries(platform.get() , &processor , kSampleSize , kSampleRequests)) return 1; PrintMap(&output); } isolate->Dispose(); v8::V8::Dispose(); v8::V8::ShutdownPlatform(); delete create_params.array_buffer_allocator; } still crash at here: https://github.com/v8/v8/blob/bd15e18905cb86c69a5c82cd3fd1dd63f72e0c56/src/global-handles.cc#L72 On Friday, March 8, 2019 at 2:46:26 AM UTC+8, Ben Noordhuis wrote: > > On Thu, Mar 7, 2019 at 2:39 PM helloev <stonedre...@gmail.com > <javascript:>> wrote: > > So here we don't need to release resources? If need to release it, what > should we do? > > The process is terminating so any resources will be reclaimed anyway > but if you want to reclaim them manually, use proper scoping: > > int main() { > // ... > { > Isolate::Scope isolate_scope(isolate); > // ... > } // closes the isolate scope > isolate->Dispose(); > // ... > } > -- -- 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.