change memory manager to class, need to add a complete memory free method