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"

Remove material instance after use?

Hi, I'm creating dynamic grid meshes in my level based on the user click location. I'm changing their material color from blueprint based on the distance from the player. I create material instances as soon as I spawn these grid meshes, with different vector parameters for color. Later when the user clicks on a new location, I destroy these meshes. What I want to know is whether these material instances will get removed from memory when I destroy the mesh actors? Or do I have to remove them explicitly in some way?

Here's a screenshot of what I'm doing in the blueprint: alt text

Product Version: Not Selected
Tags:
matinst.jpg (291.8 kB)
more ▼

asked Jan 30 '15 at 05:43 AM in Rendering

avatar image

Stormrage256
1k 82 75 117

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hey Stormrage256 -

Assuming that you are just deleting the mesh and not the whole blueprint that has created the MID (Dyanmic Material Instance) then you will still have the MID in memory but unreferenced. It should not hurt anything as it is part of the memory footprint of the Blueprint itself. Of course, it would also not hurt anything to remove the MID either. Typical garbage cleanup would take care of the MID if you removed the entire blueprint.

Hopefully that helps you out -

Eric Ketchum

more ▼

answered Jan 30 '15 at 03:15 PM

avatar image

Lovecraft_K ♦♦ STAFF
36.8k 702 256 733

avatar image Spoondog Apr 14 '17 at 06:29 AM

Is there any way to remove the dynamic material instances from memory without removing the blueprint? I've had situations where there could be a lot of these created.. not sure I like the idea of them sitting there unreferenced.

avatar image Flashback Feb 21 '18 at 10:31 PM

I was also worried by this Eric's statement: "you will still have the MID in memory but unreferenced". Characters in my project can swap materials hundreds of times during their life cycle, and there can be dozens of characters on the map, which would leave significant and unnecessary memory footprint.

Maybe we misunderstood Eric in some way, but that statement appears to be false. Though I haven't found a way to delete a MID manually, I have just checked and can confirm that MIDs follow general UObject garbage collection rule: as soon as they're not referenced by anything, they get GC'ed and deleted. No need to do anything special.

(comments are locked)
10|2000 characters needed characters left
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