mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
Fallback to unbuffered printing if OOM
This commit is contained in:
@@ -465,12 +465,17 @@ prof_recent_alloc_dump(tsd_t *tsd, void (*write_cb)(void *, const char *),
|
||||
char *buf = (char *)iallocztm(tsd_tsdn(tsd), PROF_RECENT_PRINT_BUFSIZE,
|
||||
sz_size2index(PROF_RECENT_PRINT_BUFSIZE), false, NULL, true,
|
||||
arena_get(tsd_tsdn(tsd), 0, false), true);
|
||||
buf_write_arg_t buf_arg;
|
||||
buf_write_init(&buf_arg, write_cb, cbopaque, buf,
|
||||
PROF_RECENT_PRINT_BUFSIZE);
|
||||
emitter_t emitter;
|
||||
emitter_init(&emitter, emitter_output_json_compact, buf_write_cb,
|
||||
&buf_arg);
|
||||
buf_write_arg_t buf_arg;
|
||||
if (buf == NULL) {
|
||||
emitter_init(&emitter, emitter_output_json_compact, write_cb,
|
||||
cbopaque);
|
||||
} else {
|
||||
buf_write_init(&buf_arg, write_cb, cbopaque, buf,
|
||||
PROF_RECENT_PRINT_BUFSIZE);
|
||||
emitter_init(&emitter, emitter_output_json_compact,
|
||||
buf_write_cb, &buf_arg);
|
||||
}
|
||||
emitter_begin(&emitter);
|
||||
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), &prof_recent_alloc_mtx);
|
||||
@@ -530,8 +535,10 @@ prof_recent_alloc_dump(tsd_t *tsd, void (*write_cb)(void *, const char *),
|
||||
malloc_mutex_unlock(tsd_tsdn(tsd), &prof_recent_alloc_mtx);
|
||||
|
||||
emitter_end(&emitter);
|
||||
buf_write_flush(&buf_arg);
|
||||
idalloctm(tsd_tsdn(tsd), buf, NULL, NULL, true, true);
|
||||
if (buf != NULL) {
|
||||
buf_write_flush(&buf_arg);
|
||||
idalloctm(tsd_tsdn(tsd), buf, NULL, NULL, true, true);
|
||||
}
|
||||
}
|
||||
#undef PROF_RECENT_PRINT_BUFSIZE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user