Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 9fe3759c5edaa3b9ca22984e4aedd208ac6dbc36..457a64f1245369bc20643669d3a7c25eef0f7a53 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -213,6 +213,10 @@ void i::FatalProcessOutOfMemory(const char* location) { |
// When V8 cannot allocated memory FatalProcessOutOfMemory is called. |
// The default fatal error handler is called and execution is stopped. |
void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { |
+ i::Isolate* isolate = i::Isolate::Current(); |
+ char last_few_messages[Heap::kTraceRingBufferSize + 1]; |
+ memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1); |
+ |
i::HeapStats heap_stats; |
int start_marker; |
heap_stats.start_marker = &start_marker; |
@@ -254,13 +258,17 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { |
heap_stats.size_per_type = size_per_type; |
int os_error; |
heap_stats.os_error = &os_error; |
+ heap_stats.last_few_messages = last_few_messages; |
int end_marker; |
heap_stats.end_marker = &end_marker; |
- i::Isolate* isolate = i::Isolate::Current(); |
if (isolate->heap()->HasBeenSetUp()) { |
// BUG(1718): Don't use the take_snapshot since we don't support |
// HeapIterator here without doing a special GC. |
isolate->heap()->RecordStats(&heap_stats, false); |
+ char* first_newline = strchr(last_few_messages, '\n'); |
+ if (first_newline == NULL || first_newline[1] == '\0') |
+ first_newline = last_few_messages; |
+ PrintF("\n<--- Last few GCs --->\n%s\n", first_newline); |
} |
Utils::ApiCheck(false, location, "Allocation failed - process out of memory"); |
// If the fatal error handler returns, we stop execution. |