Fixed a memory leak in MemoryManager