Why does this program eat RAM?