check client liveness && fix memory leak