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

Unified Diff: runtime/vm/heap.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: cosmetic changes 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
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/heap_profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap.cc
diff --git a/runtime/vm/heap.cc b/runtime/vm/heap.cc
index d2f16159afb2e63da022d3d5fafdd49fb40ba368..79c335d6af4dba55ea28134da71b9621c060ca86 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -286,6 +286,26 @@ void Heap::Profile(Dart_FileWriteCallback callback, void* stream) const {
}
+void Heap::ProfileToFile(const char* reason) const {
+ Dart_FileOpenCallback file_open = Isolate::file_open_callback();
+ ASSERT(file_open != NULL);
+ Dart_FileWriteCallback file_write = Isolate::file_write_callback();
+ ASSERT(file_write != NULL);
+ Dart_FileCloseCallback file_close = Isolate::file_close_callback();
+ ASSERT(file_close != NULL);
+ Isolate* isolate = Isolate::Current();
+ const char* format = "%s-%s.hprof";
+ intptr_t len = OS::SNPrint(NULL, 0, format, isolate->name(), reason);
+ char* filename = isolate->current_zone()->Alloc<char>(len + 1);
+ OS::SNPrint(filename, len + 1, format, isolate->name(), reason);
+ void* file = (*file_open)(filename);
+ if (file != NULL) {
+ Profile(file_write, file);
+ (*file_close)(file);
+ }
+}
+
+
const char* Heap::GCReasonToString(GCReason gc_reason) {
switch (gc_reason) {
case kNewSpace:
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/heap_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698