This shouldn’t have anything to do with garbage collection, that only happens between frames and should only affect things such as TObjectPtr. You shouldn’t need this TMap to be a UPROPERTY().
Could you post the code that you use to generate the collisionmap (which seems to be GenerateIndices)? That might help clarify what’s happening. It might be something like not passing in the indices by reference, or something else of the sort?
Other things to try, assuming you want to do it your original way: Assuming you’re using Visual Studio, putting a breakpoint on that first line where you attempt to access collisionmap and seeing what the values of collisionmap and indices are could be illuminating. Use UE_DISABLE_OPTIMIZATION and UE_ENABLE_OPTIMIZATIONbefore and after your code respectively if the values are optimized away for some reason.
static void GenerateIndices(int64* array, const short& xi, const short& yi, const short& zi, const int& i)
{
int32 count = 0;
for (int x = -i; x <= i; x++)
{
for (int y = -i; y <= i; y++)
{
for (int z = -i; z <= i; z++)
{
*array = getindex(xi - x, yi - y, zi - z);
array++;
}
}
}
}
static int64 getindex(const uint16& xi, const uint16& yi, const uint16& zi)
{
int64 index = 0;
index |= xi;
index = index << 16;
index |= yi;
index = index << 16;
index |= zi;
return index;
}