scheduler: avoid the memory leaks