fix the memory usage bug