Re: out-of-mem handler

Sebastian Wilhelmi <> writes: 
> 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. 

The only reason I want a callback is to do this:

while (TRUE)
   gpointer p;

   p = g_malloc_try();
   if (p)
     return p;

(perhaps with a max number of tries for safety)

I want this specifically for gnome-session. If other apps do this it's
obviously very bad, but gnome-session should not be the app to fall
over if memory runs out.

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

Right, I remember we wanted the _try() functions.


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