As you can see in the image below, I dump a magazine twice, creating two actors which are sent for GC, but the int count remains at zero, meaning that the array is empty!
All methods of calling QueueActorForGC explicitly pass an array.
If the “Add (to array)” node works in the simplest test scenario, then the problem is not the add node.
It would be a normal situation if the GC Destroy List is emptied (or were empty) before a new item is added (both items in your test would get index 0).
Deleting X on a foreach loop of an array misbehaves. You’d have to remove things end to first item by looping over index (array size - 1 to 0).
array pointers are only valid until an item is added or removed from an array.
Seeing nothing obvious on the screenshots currently.
I wonder though, are you trying to implement garbage collector functionality besides the GC that is already working in the background on every UObject?
It all magically works. It seems to be an issue with the custom events. But I’m not sure what the issue is exactly.
⠀
I wonder though, are you trying to implement garbage collector functionality besides the GC that is already working in the background on every UObject?
I’m unaware of what GC you are referring to in this case. I assume you mean actual GC like invalid pointers, garbage variables, and anything left over in memory over the course of C++ code running.
Mine is just to deal with deleting and re-setting objects between the rounds of a game.
That… would mean the blueprint system itself is basically dead unless I’m missing something.
Have you used breakpoints before? you can walk through the software node by node while it operates, and read past data.
You are using “GC” as your custom implementation context (to deal with deleting and resetting objects), I am referring to the GC which checks for unreferenced UObjects every X seconds and destroys them (nulling pointers etc.). That GC is built into the engine.
I literally always convert my events to functions (I mean theoretically they are already functions). Only downside to this is that several nodes (including delays) can not be converted to functions. I however hope not that such bug exists. It can be tested on a separate simplified test (to exclude external code affections.)
On the first screenshots there’s just an object pointer and int copy sent into the print string which don’t get the desired results. Apparently the bypass of that custom node works (as reported by the person starting the thread).
I gave it a try, though they are hard to use since they don’t support standalone play mode (which due to some plugins I use, is the only mode in which my game is fully playable, but for something as small as this, I should be able to make it function just barely enough to do a short test).
(Here would go the part where I mentioned my results, but I never got to it due to the part below…)
This is a bit odd since Unreal itself claims that it only supports pass-by-reference for arrays.
However, Unreal gaslights users about its functionality constantly so I’m going to run a test regardless where I assume that this is true.
I made it so that the “local” bool gets passed all the way through, and then the array is picked based on that bool. Theoretically this should avoid needing to pass any arrays.
I think it is technically passing the array by reference, in the sense that it isn’t making a copy. But it is a const reference, so not something you can modify.
The thing is, I remember that Event Dispatchers (which have the same limitations) would display a clear yellow warning when you try doing this. I don’t know why custom events don’t do the same.