proper memory management in vm and compiler