x

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"

Is it necessary to unbind events before destroying an actor

I have some custom events bound in an AIController, and I was wondering if it is necessary to unbind those events before calling DestroyActor in order for it to be garbage collected. If it is not necessary, do the events unbind immediately, or only when the controller is garbage collected?

Editing for clarification: - Do event bindings prevent garbage collection - If not, do they get removed when the actor is flagged for collection, or upon being collected

Product Version: UE 4.16
Tags:
more ▼

asked Jun 07 '17 at 09:19 PM in Blueprint Scripting

avatar image

Rakosman
58 3 9 12

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

1 answer: sort voted first

Yes it is recommended to unbind events when you no longer need them, they can be fired unpredictably and cause bugs very hard to track down.

more ▼

answered Jun 08 '17 at 08:28 AM

avatar image

AZTECCO
1k 17 8 15

avatar image Rakosman Jun 08 '17 at 06:26 PM

Best practice, sure. But that doesn't really address my question. I have run into some other issue regarding destroying the AIController, and I'm doing things a different way now, but it would still be useful to know if event bindings prevent garbage collection (i.e., is unbinding necessary) and, if not, if they get removed when it gets flagged for collection, or upon being collected.

avatar image AZTECCO Jun 09 '17 at 11:10 AM

No they won't, the references are weak. The problem is that you don't know if an object is removed yet and you can call accidentally it.

(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