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. 

What is the proper way to create and destroy UMG widgets?

Hello, to create UMG widgets i use Create Widget and then add to viewport, should i create it only once and then just toggle visibility or it's fine creating the widget everytime? There is no Destroy Widget, so i assume Remove from Viewport destroys the widget or at least removes it's reference for late destruction, but what about it's children? Do i need to clear them before removing from the viewport, or he will do that automatically when he's removed from the viewport? Thank you

Product Version: Not Selected
more ▼

asked Oct 19 '14 at 11:20 PM in Using UE4

avatar image

6k 161 129 304

avatar image BaronPumpky Dec 05 '14 at 03:29 PM

I'd love an answer to this. I would assume removing the widget would clean it up as well, but I don't see anything about that online.

avatar image Kokuyouseki Jul 12 '17 at 11:02 AM

So far I found no way to remove widgets completely. GC appears to not do anything about them either as long as your level is running. This goes of course for dynamically created buttons etc. as well, so if you want to make an inventory that is not constant, every time you "remove" an item, it will stay with you forever. So all you can do is use the already created ones and only create new ones if you need one.

I really hope they add a delete widget node eventually. After all this time I doubt it though.

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

2 answers: sort voted first

Hello xlar8or,

When a widget is removed from parent or removed from viewport it stays in memory. A new widget is not created beyond the initial creation, it is simply added to the viewport. There are a couple of important things to note.

  1. The Event Construct will fire every time it is added to viewport.

  2. A widget can be added to viewport more than once (in effect doubling it up, this can result in a widget that cannot be removed)

  3. Though the widget is removed from viewport the variables within the widget retain what ever values that have.

I hope that this answers the questions that you had.

Make it a great day

more ▼

answered Dec 23 '14 at 09:26 PM

avatar image

Rudy Q ♦♦ STAFF
47.4k 545 132 523

avatar image xlar8or Dec 23 '14 at 09:30 PM

Thank you for taking the time to answer my question, so how do i actually remove it from memory? Should i just leave it to the GC after removing it from the viewport?

avatar image Rudy Q ♦♦ STAFF Dec 23 '14 at 10:02 PM

Hello xlar8or,

Yes, I believe it would be best to let the garbage collection handle it after it has been removed.

avatar image xlar8or Dec 23 '14 at 10:04 PM

Ok thank you :)

avatar image LotiyaPathaan Jul 08 '16 at 09:09 AM

Thanks for the reply

avatar image kingcrimson Oct 01 '16 at 03:14 AM

great answer! :D

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

Don't forget to invalidate any timers going in the widget, otherwise GC won't destroy it.

more ▼

answered Feb 05 '19 at 11:31 AM

avatar image

847 31 13 47

(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