Address charts memory leaks.

This pr addresses #1139.