Fix memory leak in ResourceMgr