implementation of memory_mangement