- Home /
Is there a need to destroy assets created during runtime to prevent memory leaks?
Hi, I'm currently working on a project where most of my assets(in this case, Texture2D) are created dynamically on runtime(they are downloaded from a server). My question here is whether there is a need to destroy those assets when I no longer need them to avoid memory issues? If yes, what would be the best way to go about this?
Answer by Landern · Aug 29, 2016 at 01:23 PM
Hopefully there aren't any memory leaks. You hope one of two things happens.
If you explicitly destroy an object that it will be collected and release by the garbage collector at some point.
If something is out of scope(local variables and the like, previously loaded level) that the objects that were in memory were marked to be collected and gets released at some point by the garbage collector.
If you're not seeing any issues with memory management on the platforms you're targeting, you may be introducing overhead to your project that may kill performance(like trying to get the garbage collector to execute on demand).
You should be fine unless you're seeing something to the contrary.
Your answer
Follow this Question
Related Questions
Memory Management: Assets between scenes 1 Answer
The cheapest way to store a pointer to the addressable asset 1 Answer
Difference between Resources folder Vs normal folder 0 Answers
Do Addressable assets generate memory allocation? 0 Answers
Assigning a texture for object in inspector. Is it loaded right away? 0 Answers