Real time works but memory leaks somewhere