Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1288)

Unified Diff: src/d8.cc

Issue 1147343004: Fixed memory-leak in d8. It did not clean evaluation context used for executing shell commands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed version Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/d8.h ('k') | test/mjsunit/regress/regress-crbug-493284.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index e43a7c54055b8bf3ee37cb6f10d354331d035a01..feda52a61086dde3d6d2f90e12005847cb34e9c3 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1339,19 +1339,7 @@ void SourceGroup::ExecuteInThread() {
Execute(isolate);
}
}
- if (Shell::options.send_idle_notification) {
- const double kLongIdlePauseInSeconds = 1.0;
- isolate->ContextDisposedNotification();
- isolate->IdleNotificationDeadline(
- g_platform->MonotonicallyIncreasingTime() +
- kLongIdlePauseInSeconds);
- }
- if (Shell::options.invoke_weak_callbacks) {
- // By sending a low memory notifications, we will try hard to collect
- // all garbage and will therefore also invoke all weak callbacks of
- // actually unreachable persistent handles.
- isolate->LowMemoryNotification();
- }
+ Shell::CollectGarbage(isolate);
}
done_semaphore_.Signal();
} while (!Shell::options.last_run);
@@ -1413,6 +1401,10 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--test") == 0) {
options.test_shell = true;
argv[i] = NULL;
+ } else if (strcmp(argv[i], "--notest") == 0 ||
+ strcmp(argv[i], "--no-test") == 0) {
+ options.test_shell = false;
+ argv[i] = NULL;
} else if (strcmp(argv[i], "--send-idle-notification") == 0) {
options.send_idle_notification = true;
argv[i] = NULL;
@@ -1542,6 +1534,17 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {
options.isolate_sources[0].Execute(isolate);
}
}
+ CollectGarbage(isolate);
+#ifndef V8_SHARED
+ for (int i = 1; i < options.num_isolates; ++i) {
+ options.isolate_sources[i].WaitForThread();
+ }
+#endif // !V8_SHARED
+ return 0;
+}
+
+
+void Shell::CollectGarbage(Isolate* isolate) {
if (options.send_idle_notification) {
const double kLongIdlePauseInSeconds = 1.0;
isolate->ContextDisposedNotification();
@@ -1554,13 +1557,6 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {
// unreachable persistent handles.
isolate->LowMemoryNotification();
}
-
-#ifndef V8_SHARED
- for (int i = 1; i < options.num_isolates; ++i) {
- options.isolate_sources[i].WaitForThread();
- }
-#endif // !V8_SHARED
- return 0;
}
@@ -1729,6 +1725,13 @@ int Shell::Main(int argc, char* argv[]) {
#endif // !V8_SHARED
RunShell(isolate);
}
+
+ // Shut down contexts and collect garbage.
+ evaluation_context_.Reset();
+#ifndef V8_SHARED
+ utility_context_.Reset();
+#endif // !V8_SHARED
+ CollectGarbage(isolate);
}
OnExit(isolate);
#ifndef V8_SHARED
« no previous file with comments | « src/d8.h ('k') | test/mjsunit/regress/regress-crbug-493284.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698