fix deadlock when system is low on memory