qga/session: Improve memory management