Commit 3f1ea190 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Plug memory leak in Isolate.

R=jkummerow@chromium.org
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10702060

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11965 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 34d79888
// Copyright 2008 the V8 project authors. All rights reserved.
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -238,12 +238,18 @@ static int ArchiveSpacePerThread() {
ThreadState::ThreadState(ThreadManager* thread_manager)
: id_(ThreadId::Invalid()),
terminate_on_restore_(false),
data_(NULL),
next_(this),
previous_(this),
thread_manager_(thread_manager) {
}
ThreadState::~ThreadState() {
DeleteArray<char>(data_);
}
void ThreadState::AllocateSpace() {
data_ = NewArray<char>(ArchiveSpacePerThread());
}
......@@ -306,8 +312,19 @@ ThreadManager::ThreadManager()
ThreadManager::~ThreadManager() {
delete mutex_;
delete free_anchor_;
delete in_use_anchor_;
DeleteThreadStateList(free_anchor_);
DeleteThreadStateList(in_use_anchor_);
}
void ThreadManager::DeleteThreadStateList(ThreadState* anchor) {
// The list starts and ends with the anchor.
for (ThreadState* current = anchor->next_; current != anchor;) {
ThreadState* next = current->next_;
delete current;
current = next;
}
delete anchor;
}
......
// Copyright 2008 the V8 project authors. All rights reserved.
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
......@@ -57,6 +57,7 @@ class ThreadState {
private:
explicit ThreadState(ThreadManager* thread_manager);
~ThreadState();
void AllocateSpace();
......@@ -114,6 +115,8 @@ class ThreadManager {
ThreadManager();
~ThreadManager();
void DeleteThreadStateList(ThreadState* anchor);
void EagerlyArchiveThread();
Mutex* mutex_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment