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

Unified Diff: runtime/vm/isolate.cc

Issue 11478012: Provide a mechanism for dumping of heap profiles on predefined events. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
« runtime/vm/exceptions.cc ('K') | « runtime/vm/heap.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 6885ac03b96595b3776c4abcce391f29e94bcd7b..3e86dc1a271c9a669e6f8b2989f313cb89881cbf 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -30,6 +30,7 @@ DEFINE_FLAG(bool, report_usage_count, false,
"Track function usage and report.");
DEFINE_FLAG(bool, trace_isolates, false,
"Trace isolate creation and shut down.");
+DECLARE_FLAG(bool, heap_profile_out_of_memory);
DECLARE_FLAG(bool, generate_gdb_symbols);
@@ -114,6 +115,18 @@ bool IsolateMessageHandler::HandleMessage(Message* message) {
if (result.IsError()) {
isolate_->object_store()->set_sticky_error(Error::Cast(result));
}
+ if (result.IsInstance() && FLAG_heap_profile_out_of_memory) {
siva 2012/12/07 00:33:02 This check seems incorrect, at this point result w
cshapiro 2012/12/08 07:29:46 I am really confused by this. At this point resul
+ Instance& out_of_memory =
+ Instance::Handle(isolate_->object_store()->out_of_memory());
+ if (Instance::Cast(result).Equals(out_of_memory)) {
+ const char* format = "%s-out-of-memory.hprof";
+ intptr_t len = OS::SNPrint(NULL, 0, format, isolate_->name());
+ char* filename =
+ isolate_->current_zone()->Alloc<char>(len + 1);
+ OS::SNPrint(filename, len + 1, format, isolate_->name());
+ isolate_->heap()->ProfileToFile(filename);
+ }
+ }
if (Isolate::UnhandledExceptionCallback() != NULL) {
Dart_EnterScope();
Dart_Handle error = Api::NewHandle(isolate_, result.raw());
« runtime/vm/exceptions.cc ('K') | « runtime/vm/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698