Fix memory hoarding bug
Merge pull request #3378 from wmtan/FixMemoryHoardingBug

Fix memory hoarding bug