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"

Can obj=NewObject(outer) be garbage collected before "outer"?

Hello everyone!

Suppose I created instance MyObj with the code below inside my actor class and MyObj is not stored in UPROPERTY():

auto MyObj = NewObject<DerivedFromUObject>(this)

Does it establish Child-Parent relationship between MyObj and this, thus preventing MyObj from being garbage collected before the actor instance is GC'ed?

Does it works like in Qt library?

// Qt example: myObj lifetime is now tied to parent.
auto myObj = new QObject(parent);
delete parent; // deletes myObj as well

Product Version: UE 4.22
more ▼

asked Jun 15 '19 at 05:26 PM in C++ Programming

avatar image

3 1 3

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

1 answer: sort voted first

No, it does not prevent it, MyObj can be garbage collected before the outer (your actor) is.

Simply speaking, the child is going to held a reference to the actor through Outer, but the actor does not automatically hold a reference to the objects it's an outer of.

more ▼

answered Jun 15 '19 at 06:52 PM

avatar image

1.3k 4 5 7

avatar image sonar_e Jun 15 '19 at 10:43 PM

Thanks for the clarification!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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