Re: out-of-mem handler



Hi Havoc,

> I remember that we talked about how to do an out-of-memory handler for
> g_malloc() etc., did anyone ever do the patch? Should I make a patch?

Just to reiterate:

Do not add a callback for out of memory. You wouldn't be allowed to call any
glib-function (let alone GTK) inside this handler, as that might screw up the
internal state, depending on where the g_malloc call came from, also Xlib
doesn't allow overloading the Xmalloc. Thus the callback wouldn't be called,
when out of mem in X. 

Add a g_malloc_try (we already talked about it then). This is a really
necessary function, but a handler will yield exactly nothing. 

I have a patch here on my harddisk, that includes a hacked up glibc-2.1
version of malloc and friends, that internally reserves a
run-time-configurable amount of memory. If that reserved mem has to be
touched, because there's no other mem left, then a flag is set, which can
effectivly be used as an asyncronous signal (via g_source_add) to the main
loop. I had a test prog and it worked quite well. But noone seemed to
interested, so I left the issue alone (not being sure, anything sane could be
done in case of out-of-mem).

So, please don't add an out-of-mem-callback.

Bye,
Sebastian
-- 
Sebastian Wilhelmi                   |            här ovanför alla molnen
mailto:wilhelmi@ira.uka.de           |     är himmlen så förunderligt blå
http://goethe.ira.uka.de/~wilhelmi   |



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]