Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Does Unreal detroy childrens upon parent destruction ?

Hello Guys,

I'm still working on memory management for our game and I wonder something.

Does Unreal is supposed to destroy automatically`UPROPERTY()`marked childrens objects (Actor or Object) pointers upon their destruction ?

Consider the folowing code :


 class AGame_API ADummyActor : public AActor
     ADummyActor(const FObjectInitializer& ObjectInitializer);
     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Dummy)
     UTexture* texture;

     void SetTexture();


 ADummyActor::ADummyActor(const FObjectInitializer& ObjectInitializer)
     : Super(ObjectInitializer)
     texture = nullptr;
 void ADummyActor::SetTexture()
     texture = LoadObject<UTexture>(this, TEXT("/Game/Menu/Artwork/toto/Background_fantasy.Background_fantasy"), NULL, LOAD_None, NULL);

This code would be the same for a UObject derived object.

For this case, assume that I no (0) instance of the DummyActor and I have a button to spawn an instance and another to destroy that very same instance. Also, assume that the texture is not referenced anywhere else.

When I call delete upon the button, is it supposed to also destroy the texture pointer and release the memory associated with the texture ?

If YES, that doesn't work at all.

If NO, should I declare a ClearChildrens function that will manually delet every childrens data ? or what sould I do ?

I mean in raw C++ there's no garbage, so I'm well used to clean childrens memory upon destructor call.

But with Unreal, we are supposed to have a garbage collector that is supposed to clean unused memory right ?

Or am I crazy and missed something o0 ?

Thanks for any help..


Product Version: UE 4.12
more ▼

asked Oct 20 '16 at 12:00 PM in Using UE4

avatar image

266 17 17 36

avatar image erik321123 Oct 20 '16 at 02:45 PM

As far a I know Unreal doens't destruct children on destruction of a parent since you can have children in a Level without a parent in the level. But I am not sure

avatar image gamer08 Oct 20 '16 at 03:04 PM

Hello erik,

Well, it's something I would to have a confirmation from epic staff if possible because it's not very clear on the documentation.

avatar image gamer08 Oct 21 '16 at 11:18 AM

Hey guys,

I decided to call up a function to "clear childrens" before delete the parent and this with both actor and object. In the end it works, but I would really like to know if the GC is suppose to clear childrens automatically upon parent destruction specifically if they are marked UPROPERTY() ?

Thanks for a future answer.


(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question