Garbage collection and ustruct
Hello. So Here is my ustruct:
Plase take note that TMap holds another ustruct in it. This Ustruct is used as a return type of my function wich then assigns it to UProperty:
What I want to ask is how do I propertly dispose this struct before assigning a new one? I mean should I somehow "NULL" each of FTilePathData in ReachableTiles and then somehow "NULL" this structure or will itbe automatically garbage collected if there are no pointers left to it? Also, as far as I know you can not just assign NULL to struct so if I need to clean it somehow - can you please provide me an example on how to do this? Ive got not much exp in c++ programming as have not done this for last 5 years so have forgotten some basic things. Thank you for your help!
asked Jun 12 '16 at 08:04 AM in C++ Programming
You got that right: struct variables are not NULLable.
But don't worry about assigning a new struct on that variable. The arrays will delete themselves because of their destructor operators that will be called when their structs are destructed. If there were native pointers somewhere, created with the new keyword, or the arrays contained pointers, then you should start to worry about cleanup. Unless those pointers were initialized with NewObject() and their type was derived from UObject. Then, they'd get GC'ed once every minute or so.
As I understand, TArray and TMap are like any struct. If you have a variable of it and it's replaced or goes out of scope, it's instantly destroyed.
answered Jun 15 '16 at 04:26 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here