Remove out of memory related code by using glib APIs