title: GLib handle out of memory
body: <p>I've a question concerning the GLib.
  I would like to use the GLib in a server context but I'm not aware on how the memory is managed:
  <a href="https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html" rel="nofollow noreferrer">https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html</a></p>
  <blockquote>
  <p>If any call to allocate memory fails, the application is terminated. This also means that there is no need to check if the call succeeded.</p>
  </blockquote>
  <p>If I look at the source code, if g_malloc failed, it will call g_error:</p>
  <blockquote>
  <p>g_error()</p>
  <h1>define             g_error(...)</h1>
  <p>A convenience function/macro to log an error message.
  Error messages are always fatal, resulting in a call to abort() to terminate the application.[...]</p>
  </blockquote>
  <p>But in my case, as I'm developing a server application, I don't want the application exit, I would prefer, as the traditional malloc function, the GLib functions returns NULL or something to indicate an error happened.</p>
  <p>So, my question is, there is a manner to handle out of memory?
  Is the GLib not recommended for server purpose applications?</p>
  <p>If I look at the man of abort I can see that I can handle the signal but I'll make the management of out-of-memory errors a little bit painful...</p>
  <blockquote>
  <p>The abort() function causes abnormal program termination to occur, unless
  the signal SIGABRT is being caught and the signal handler does not
  return.</p>
  </blockquote>
  <p>Thanks for you help!</p>