Implement memory allocation