trace: implement memory allocation