partly refactored erlog_memory