Really fix missing HandleScope to prevent local handles to DOMWindow leaking.
authormikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 18 Nov 2011 11:42:39 +0000 (11:42 +0000)
committermikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 18 Nov 2011 11:42:39 +0000 (11:42 +0000)
A follow-up to r9994.

R=vitalyr@chromium.org
BUG=102895
TEST=cctests/test-heap-profiler/NoHandleLeaks

Review URL: http://codereview.chromium.org/8468016

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10030 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/profile-generator.cc
test/cctest/test-heap-profiler.cc

index 0284b98d72a5016e17c5a356cfe43ad095459de7..5626acaba4bf7fc37c75921767c12c77a0cff172 100644 (file)
@@ -2470,10 +2470,10 @@ class GlobalObjectsEnumerator : public ObjectVisitor {
 
 // Modifies heap. Must not be run during heap traversal.
 void V8HeapExplorer::TagGlobalObjects() {
+  HandleScope scope;
   Isolate* isolate = Isolate::Current();
   GlobalObjectsEnumerator enumerator;
   isolate->global_handles()->IterateAllRoots(&enumerator);
-  HandleScope scope;
   Handle<String> document_string =
       isolate->factory()->NewStringFromAscii(CStrVector("document"));
   Handle<String> url_string =
index f835a1e0d58149e1bf4c86dd8e274a3300222538..81b68a713fbacb712ea6c284f83d5459465de593 100644 (file)
@@ -895,6 +895,20 @@ TEST(DocumentURLWithException) {
 }
 
 
+TEST(NoHandleLeaks) {
+  v8::HandleScope scope;
+  LocalContext env;
+
+  CompileRun("document = { URL:\"abcdefgh\" };");
+
+  v8::Handle<v8::String> name(v8_str("leakz"));
+  int count_before = i::HandleScope::NumberOfHandles();
+  v8::HeapProfiler::TakeSnapshot(name);
+  int count_after = i::HandleScope::NumberOfHandles();
+  CHECK_EQ(count_before, count_after);
+}
+
+
 TEST(NodesIteration) {
   v8::HandleScope scope;
   LocalContext env;
@@ -1024,6 +1038,7 @@ TEST(GetConstructorName) {
       "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6)));
 }
 
+
 TEST(FastCaseGetter) {
   v8::HandleScope scope;
   LocalContext env;