Optimize the dynamic space allocate