User-defined out of memory handling