Memory allocation/deallocation fixed