C++ Array.Insert BUG/CRASH

Here is my code



 MyArray.Insert(128, 1);
 MyArray.Insert(64, 2);
 

When i use array insert more than one time after the other (Correctly) it crashes my game and doesn’t give me one of those epic games bug report messages. Even though it all checks out and compiles correctly?

Is you Array sized correctly? Crashs when using arrays are mostly due to access errors.

I guess not? iv’e never really paid attention to the size of the array, In my current setup i just keep adding to the array until MyArray.Num() gets to a certain size.

Adding is ok, because it will create a new index and reserve memory for it.

But inserting does only work if the index already has memory reserved. You can use MyArray.Init(SIZE); and then use a for loop to set the Arrays Default values correctly.
Make sure removing is not set to shrinking or at least check if the length is > the Index. You could also use “MyArray.IsValidIndex(INDEX)”

Yeah thanks for you time, I managed to fix my problem thanks :smiley: