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

Unified Diff: src/api.cc

Issue 1159513003: Even without --trace-gc dump the last few GC messages on OOM (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | src/heap/gc-tracer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | src/heap/gc-tracer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698