Turns out that GTK, by design, exits in out-of-memory situations. That
makes our efforts to detect OOM and recover somewhat moot, on that
platform anyway.
But Nokia's Maemo platform uses GTK on embedded devices. Does anyone
know how they deal with OOM?
Rob
Got a link to any sort of documentation about the motivation behind this
design? A quick Google search didn't turn up anything obvious...
Dan
It actually exits in situations where it just thinks it's out of memory, sadly.
We've had bugs on this before.
> That makes our efforts to detect OOM and recover somewhat moot, on that
> platform anyway.
Only OOM in calls to GTK. We can still usefully detect and recover from OOM for
other (esp. large) allocations.
-Boris
Antonio might know or be able to find someone who can answer...
chris h.
Yes, but we will never be able to reliably survive a persistent OOM
condition ... eventually we'll call into GTK and die.
Rob
Yeah, indeed.
Could we push on the GTK folks to fix this? Say give the app control over the
OOM behavior?
-Boris
They would need to change a ton of code. I'd like to find out what the
folks who are embedding GTK think first ... they're the ones who would
really be suffering, you'd think.
Rob
Well, at the very least, it gives us the opportunity to try and free up
a bunch of memory and/or gracefully shut down to avoid data corruption.
Dan
Maybe search and replace for exit? Replace it with g_maybe_exit that
invokes a user defined callback function or else invokes exit.
-Darin
That would avoid the immediate exit, but unless the allocation can be
retried and succeed, the callers must all be able to gracefully handle
NULL working its way back up the stack. I suspect that very few
callers will do so, since GTK style is very much not to check
allocation success (since, after all, it will exit rather than fail).
Mike
Beyond that, NULL wouldn't work its way back up the stack due to work
being done asynchronously. See
https://bugzilla.mozilla.org/show_bug.cgi?id=210931
--
Andrew Schultz
ajsc...@verizon.net
http://www.sens.buffalo.edu/~ajs42/
Edjard Mota (of INDT) was working on a kernel patch which allowed you to
set an low and high water mark on memory usages -- so, before you even
had a OOM problem, your app would get signaled.
See for some details: http://www.linuxjournal.com/article/8502
However this doesn't buy us much on most platforms.
Doug
longjmp! j/k... you're right... we'd need gtk to unwind cleanly and
leave itself in a consistent state.
-darin