Fixed memory leak when SAPI flush fails
Probably we should check the value of AutoDelete configurations...