fix memory in BIO