Handle out of memory and integrate with corelib