detailed process from malloc to memory management