Release data of TArray and manage it manually

Is it possible to release the data of a TArray so it does not get managed anymore?

What I want to do:

TArray<int32> myArray; // lots of data
int* dataObjectOfExternalCode;
check(sizeof(int32) == sizeof(*dataObjectOfExternalCode);
dataObjectOfExternalCode = new int[myArray.Num()];
dataObjectOfExternalCode = myArray.Release();

We need to move around lots of mesh data and for exporting it we use Assimp library. Data is handled with unreal types (TArray) until the export occours. Means the data is already there and allocated. For export we need to give pointers to the data to Assimp data types. Assimp also manages that memory from its classes. So it would be nice to just get the allocated memory (Release it from beeing managed from TArray) and hand it over to Assimp to prevent lots of FMemory::Memcpy.

Accoring to that thread, there are issues with the allocators used in the background. Though I don’t understand the excact problem.
As far as I get it, an allocator is responsible for managing a block of memory and reallocating it if more space is needed. The block of memory though only consists of instances of the managed type without any other data (e.g. management data). Means it should be possible to just release the block and destruct it manually without knowledge of the constructing instance.

Also target memory should be allocated with

 byte* targetMemory = new byte[sizeof(targetType) * numElements];
 targetType* casted = (targetType*)targetMemory;

to prevent constructor calls of targetType

I’m not familiar with the Assimp library, but you can get a pointer to the data with TArray::GetData().

TArray<int32> MyArray;
int32* FirstElement = MyArray.GetData();
for (int32 i = 0; i < MyArray.Num(); ++i)
    int32 a = *FirstElement*;

And as long as the TArray hasn’t been resized and is in scope that should be valid. If you initialize the array with enough size with SetNumZeroed you can even prevent memcpy while you’re filling it with data. Is it possible to keep that TArray in scope or is that hidden inside the Assimp library?

thank you. That was my work around idea as well. But that solution requires to keep all TArray around until export done and needs a propper cleanup of the pointers in the Assimp types before they get destructed. To prevent any issues, I trashed that idea.
Though I might get back to it again depending on how the resulting export time looks like just to get the performance. Probably inheriting from all Assimp types and create all parameters again as TArray types. Add a function to set all pointers when TArrays are filled and provide a proper destructor.