Revision: 11965 Author: [email protected] Date: Mon Jul 2 05:15:23 2012 Log: Plug memory leak in Isolate.
[email protected] BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10702060 http://code.google.com/p/v8/source/detail?r=11965 Modified: /branches/bleeding_edge/src/v8threads.cc /branches/bleeding_edge/src/v8threads.h ======================================= --- /branches/bleeding_edge/src/v8threads.cc Mon Jan 16 04:38:59 2012 +++ /branches/bleeding_edge/src/v8threads.cc Mon Jul 2 05:15:23 2012 @@ -1,4 +1,4 @@ -// 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,10 +238,16 @@ 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() { @@ -306,8 +312,19 @@ 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; } ======================================= --- /branches/bleeding_edge/src/v8threads.h Thu Dec 8 08:07:07 2011 +++ /branches/bleeding_edge/src/v8threads.h Mon Jul 2 05:15:23 2012 @@ -1,4 +1,4 @@ -// 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 @@ private: explicit ThreadState(ThreadManager* thread_manager); + ~ThreadState(); void AllocateSpace(); @@ -114,6 +115,8 @@ ThreadManager(); ~ThreadManager(); + void DeleteThreadStateList(ThreadState* anchor); + void EagerlyArchiveThread(); Mutex* mutex_; -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
