add infrastructure for releasing the memory