Status: New
Owner: ----
New issue 1432 by [email protected]: Isolate memory leak?
http://code.google.com/p/v8/issues/detail?id=1432
It looks like Isolate seems to have a small memory leak. I haven't found an
exact location yet. Continue to create and dispose Isolate in different
threads seems to increase memory usage significantly.
#include <v8.h>
#include <process.h>
#include <windows.h>
#include <stdio.h>
using namespace v8;
static unsigned int __stdcall ThreadEntry(void* arg) {
Isolate* isolate = Isolate::New();
{
v8::Isolate::Scope iscope(isolate);
v8::V8::Initialize();
v8::Locker l(isolate);
// Create a stack-allocated handle scope.
HandleScope handle_scope;
// Create a new context.
Persistent<Context> context = Context::New();
if (context.IsEmpty())
{
printf("I'm dying");
}
// Enter the created context for compiling and
// running the hello world script.
Context::Scope context_scope(context);
// Create a string containing the JavaScript source code.
Handle<String> source = String::New("1+1");
// Compile the source code.
Handle<Script> script = Script::Compile(source);
// Run the script to get the result.
Handle<Value> result = script->Run();
// Dispose the persistent context.
context.Dispose();
// Convert the result to an ASCII string and print it.
String::AsciiValue ascii(result);
//printf("%s\n", *ascii);
}
isolate->Dispose();
return 0;
}
void tryMany(int count) {
HANDLE handles[100];
for(int i=0; i<count; i++)
{
handles[i] = (HANDLE) _beginthreadex(NULL, 1024*1024, ThreadEntry, NULL,
0, NULL);
}
for(int i=0; i<count; i++)
{
WaitForSingleObject( handles[i], INFINITE );
CloseHandle( handles[i] );
}
}
int main(int argc, char* argv[]) {
for(int i=0; i<100; i++)
{
tryMany(10);
}
return 0;
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev