From f2cc5cf15235854a2449be01c7cea3a6635cb75c Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 30 Jan 2012 16:38:45 -0500 Subject: [PATCH] ShellRecorder: drop frames to keep from running the user out of memory. Once we're buffering more than 3/4's of the "half of memory" target for total buffer usage, start dropping frames. https://bugzilla.gnome.org/show_bug.cgi?id=669066 --- src/shell-recorder.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shell-recorder.c b/src/shell-recorder.c index 40df07c42..0575856db 100644 --- a/src/shell-recorder.c +++ b/src/shell-recorder.c @@ -526,6 +526,12 @@ recorder_record_frame (ShellRecorder *recorder) guint8 *data; guint size; + /* If we get into the red zone, stop buffering new frames; 13/16 is + * a bit more than the 3/4 threshold for a red indicator to keep the + * indicator from flashing between red and yellow. */ + if (recorder->memory_used > (recorder->memory_target * 13) / 16) + return; + size = recorder->stage_width * recorder->stage_height * 4; data = shell_screen_grabber_grab (recorder->grabber,