[system] fix memory leaks