I use Google V8 as shared library in simple application under Windows. 
Right now, the application just compile JavaScript without execution. Vld 
shows the memory leaks into v8.dll.

Leaks have call stack like these:
c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0 (977
):v8.dll!std::_Wrap_alloc<std::allocator<std::_Container_proxy> >::allocate
()
c:\program files (x86)\microsoft visual studio 14.0\vc\include\vector (580):
v8.dll!std::_Vector_alloc<std::_Vec_base_types<unsigned char,std::allocator<
unsigned char> >>::_Alloc_proxy() + 0xF bytes
c:\program files (x86)\microsoft visual studio 14.0\vc\include\vector (545):
v8.dll!std::_Vector_alloc<std::_Vec_base_types<unsigned char,std::allocator<
unsigned char> >>::_Vector_alloc<std::_Vec_base_types<unsigned char,std::
allocator<unsigned char> > >() +0xA bytes
c:\program files (x86)\microsoft visual studio 14.0\vc\include\vector (706):
v8.dll!std::vector<unsigned char,std::allocator<unsigned char> >::vector<
unsignedchar,std::allocator<unsigned char> >() + 0xA bytes
c:\work\v8\4.1.0.3\v8\src\type-feedback-vector.h (21): v8.dll!v8::internal::
FeedbackVectorSpec::FeedbackVectorSpec() + 0x31 bytes
c:\work\v8\4.1.0.3\v8\src\ast.h (175): v8.dll!v8::internal::AstProperties::
AstProperties() +0x33 bytes
c:\work\v8\4.1.0.3\v8\src\ast.h (2607): v8.dll!v8::internal::FunctionLiteral
::FunctionLiteral() + 0x22 bytes
c:\work\v8\4.1.0.3\v8\src\ast.h (3515): v8.dll!v8::internal::AstNodeFactory
::NewFunctionLiteral() + 0xDC bytes
c:\work\v8\4.1.0.3\v8\src\parser.cc (3814): v8.dll!v8::internal::Parser::
ParseFunctionLiteral() + 0xBD bytes
c:\work\v8\4.1.0.3\v8\src\parser.cc (1957): v8.dll!v8::internal::Parser::
ParseFunctionDeclaration() + 0x80 bytes
c:\work\v8\4.1.0.3\v8\src\parser.cc (1188): v8.dll!v8::internal::Parser::
ParseModuleElement() + 0x11 bytes
c:\work\v8\4.1.0.3\v8\src\parser.cc (1104): v8.dll!v8::internal::Parser::
ParseSourceElements() + 0x17 bytes
c:\work\v8\4.1.0.3\v8\src\parser.cc (938): v8.dll!v8::internal::Parser::
DoParseProgram()
c:\work\v8\4.1.0.3\v8\src\parser.cc (861): v8.dll!v8::internal::Parser::
ParseProgram() +0x27 bytes
c:\work\v8\4.1.0.3\v8\src\parser.cc (5131): v8.dll!v8::internal::Parser::
Parse() + 0xA bytes
c:\work\v8\4.1.0.3\v8\src\parser.h (673): v8.dll!v8::internal::Parser::Parse
() + 0xA bytes
c:\work\v8\4.1.0.3\v8\src\compiler.cc (1148): v8.dll!v8::internal::
CompileToplevel() + 0x12bytes
c:\work\v8\4.1.0.3\v8\src\compiler.cc (1338): v8.dll!v8::internal::Compiler
::CompileScript()+ 0x15 bytes
c:\work\v8\4.1.0.3\v8\src\bootstrapper.cc (1448): v8.dll!v8::internal::
Genesis::CompileScriptCached() + 0x9E bytes
c:\work\v8\4.1.0.3\v8\src\bootstrapper.cc (1418): v8.dll!v8::internal::
Genesis::CompileNative() + 0x64 bytes
c:\work\v8\4.1.0.3\v8\src\bootstrapper.cc (1404): v8.dll!v8::internal::
Genesis::CompileExperimentalBuiltin()
c:\work\v8\4.1.0.3\v8\src\bootstrapper.cc (2198): v8.dll!v8::internal::
Genesis::InstallExperimentalNatives() + 0x19B bytes
c:\work\v8\4.1.0.3\v8\src\bootstrapper.cc (2766): v8.dll!v8::internal::
Genesis::Genesis() +0xD bytes
c:\work\v8\4.1.0.3\v8\src\bootstrapper.cc (351): v8.dll!v8::internal::
Bootstrapper::CreateEnvironment() + 0x32 bytes
c:\work\v8\4.1.0.3\v8\src\api.cc (5229): v8.dll!v8::CreateEnvironment() + 
0x34 bytes
c:\work\v8\4.1.0.3\v8\src\api.cc (5260): v8.dll!v8::Context::New()


May be someone met the same issue before and can help me to find root of 
these memory leaks into v8.dll to fix it.


here code of the application:
#include <iostream>
#include <string>
#include <memory>

#include <v8.h>
#include <libplatform/libplatform.h>


namespace
{
 using platform_ptr = std::unique_ptr<v8::Platform>;

 std::string v8_exec(v8::Isolate *isolate, const std::string &java_script)
 {
 v8::Locker locker(isolate);
 v8::Isolate::Scope scope(isolate);

 v8::HandleScope handle_scope(isolate);
 v8::TryCatch try_catch(isolate);

 auto global_template = v8::ObjectTemplate::New(isolate);
 v8::Local<v8::Context> context = v8::Context::New(isolate, nullptr,
 global_template);
 v8::Context::Scope context_scope(context);

 auto global = context->Global();
 auto source = v8::String::NewFromUtf8(isolate, java_script.c_str());
 auto script = v8::Script::Compile(source);

 if (try_catch.HasCaught())
 {
 v8::String::Utf8Value error_str(try_catch.Message()->Get());
 throw std::string(*error_str);
 }


 //auto result = script->Run();
 //if (try_catch.HasCaught())
 //{
 // v8::String::Utf8Value error_str(try_catch.Message()->Get());
 // throw std::string(*error_str);
 //}
 //auto ran_res = result->ToString();
 //v8::String::Utf8Value result_str(ran_res);
 //return std::string(*result_str);

 return "";
 }
}

int main(int argc, char *argv[])
{
 if (argc == 1)
 {
 std::cerr << "Nothing to do, exit\n";
 return 126;
 }

 v8::V8::InitializeICU();
 auto platform = platform_ptr(v8::platform::CreateDefaultPlatform());
 v8::V8::InitializePlatform(platform.get());
 v8::V8::Initialize();

 auto isolate_ = v8::Isolate::New();
 std::cout << "Result is: " << v8_exec(isolate_, argv[1]) << "\n\n";
 isolate_->Dispose();

 v8::V8::Dispose();
 v8::V8::ShutdownPlatform();

 return 0;
}


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

Reply via email to