core-5088 5092 fix file save issue and memory leaks