Reduce memory usage
Merge pull request #863 from romainneutron/purge

[3.9] Reduce memory usage