fix memory leak/high cpu use on fd exhaustion