Muzaheed
(ahsan Muzaheed)
November 15, 2016, 11:18am
26
actually i was given the opposite concept.
i added that UPROPERTY based on this line:
https://wiki.unrealengine.com/UPROPERTY
"Garbage Collection
Any Object that has at least one valid pointer stored inside a UPROPERTY will not be Garbage Collected (GC)."
Also i was informed:
"
Game Instance persists throughout the entire play session, IIRC, while a game mode will pretty much only be active during one particular level.
Also, IIRC UPROPERTY being there doesn’t effect GC of UObject types other than letting the GC know that you’re referencing the object.
So while the GC may not collect the UObject, it’s not because the UPROPERTY was removed.
If you’ve got a pointer to a UObject type (anything prefixed with U or A in UE4), you need to put UPROPERTY above it. If you dont, it can be GC at any point. There are some exceptions- but you would know if those exceptions apply to your type.
UPROPERTY simply marks the pointer as a reference within the garbage collection system, which cleans up any un-referenced memory (to put it simply).
What ryanjon2040 probably meant is that if you want to manage the pointer directly, without it being tracked by GC, then you can remove the UPROPERTY macro. That isn’t the case though.
Unreal Property System (Reflection) - Unreal Engine
https://i.gyazo.com/d38227298ff62d256eaddeb7d92e731f.png
still i did the test after removing UPROPERTY .
now it is crashing while checking.
Bcz it is now null.
strange part is that it is not giving true for (if (GameSparksComponent == nullptr))
No idea.why