Memory Leak With TArray of Struct
If i use this struct ( without USTRUCT() cause i don't need it to be in blueprint ) :
I Store them in This Array:
Adding them by:
And when i want to remove area i just use This:
Will it cause Memory Leak? Cause I Don't destroy structure and TSet in it Manually.
asked May 09 '16 at 07:31 PM in C++ Programming
This won't cause a memory leak, your structs and the TSet inside it will be automatically destroyed soon after VisibleAreas_T1 gets out of scope. You don't have to destroy them manually because you're not allocating memory manually (i.e. with the new operator).
The story would be different if there were pointers involved. In that case, if you have a pointer to a UObject you should store it in a variable marked UPROPERTY, and to support that, your class must be a UCLASS or USTRUCT. Not doing so would not give you a risk of memory leak, but rather that the object could be garbage collected too early by UE's built-in garbage collection which does reference counting via UPROPERTY marked variables.
If you create a non UObject pointer, its your own responsibility to delete it eventually.
answered May 10 '16 at 11:56 AM
Zhi Kang Shao
Follow this question
Once you sign in you will be able to subscribe for any updates here