CollectionHelper CreativeNativeArray vs new

Is there any functional difference between

NativeArray< EntityAndPositionData > workArrayVersion1 = CollectionHelper.CreateNativeArray< EntityAndPositionData , RewindableAllocator >(
   _workEntityQuery.CalculateEntityCount() , ref World.UpdateAllocator ) ;

// alternative way to make a list ?benefits between the two ?
NativeList< EntityAndPositionData > workArrayVersion2 = new NativeList< EntityAndPositionData >( _workEntityQuery.CalculateEntityCount() , Allocator.TempJob ) ;

There’s quite a big difference. Different container types. Different allocators. Different lifetime guarantees. Different disposal responsibilities. You get the idea.

1 Like

Ah I meant

NativeArray< EntityAndPositionData > workArrayVersion1 = CollectionHelper.CreateNativeArray< EntityAndPositionData , RewindableAllocator >(
   _workEntityQuery.CalculateEntityCount() , ref World.UpdateAllocator ) ;

NativeArray< EntityAndPositionData > workArrayVersion2 = new NativeArray< EntityAndPositionData >( _workEntityQuery.CalculateEntityCount() , Allocator.Temp ) ;

but point taken about all the other differences, thanks.

As far as I understood it the first variant allows you to provide a custom allocator (like World.UpdateAllocator) while the second variant only works with the usual allocator labels (at least for NativeArray).

1 Like

Pretty much. And you only really need CollectionHelper for NativeArray. Everything in the Collections package works with custom allocators via ToAllocator.

2 Likes