fix memory leak on socket clear