Fix deadlock when system is low on memory