I’m not sure where to post this. Hoping this is right, if not if someone could show me where.
So, I have a screenshot of my profiler. I’m new to profiler but I’m assuming all of this is fairly high. The materials count, especially. I am assuming they should reset after exiting play mode? but they just continuously keep climbing.
I have some UI elements that are spawned once the game starts(roughly 15 different prefabs). Some are then changed via script. Such as some text. All the elements that are spawned are driven from a prefab.
Also, the total objects is crazy high. The game objects in scene, at 118 is probably about right. So why is total assets over 3500 and total object count nearly 6000?? I’m just really confused about this because I’ve never looked into the profiler but these numbers…seem insane. There’s no junk assets in folders either. It’s all neatly laid out and organized as to keep track of everything. There’s nowhere near 5000 assets lol.
You’re profiling the editor, which counts everything loaded in the editor – not just your game. As just one example, all of the settings (such as Player Settings) are actually saved as assets, and loaded as assets in the editor.
“Objects” in this context are all objects including GameObjects, components, and other C# classes.
If you want to have a better picture of what resources your game is actually consuming both in terms of memory and performance, profile a build.
The green line for “Total Allocated” memory seems to be fairly constant, and even trending slightly downwards, so I wouldn’t worry too much about runaway allocations or memory leaks in the editor unless you’re seeing it start to take a serious chunk out of your computer’s RAM.
Are you accessing .material anywhere in hat code, to change your materials? If yes, you are likely creating new Materials with that without Destroying the old ones.
Are you calling “new” on any Materials or textures in your code? Similar results.
@Madgvox
Gotcha. I wasn’t aware of that. I’ve never used the profiler. Honestly half the stuff I see in it I don’t understand. I’ll have to look into some documents on it and geek out on how it all works. I appreciate you sharing that info.
@MartinTilo
I’ll be sure and do that soon. Then I’ll get back here and show the results. Not certain exactly when that will be though. Work gets in the way of life haha. The only thing that’s accessed in any of these ui elements is the text. Nothing is “new” when instantiated. It’s not that the materials keep climbing while in play mode. What happens is, say my materials shows “20”. When I hit play, it’ll go to 30. Then when I close it goes to 40. It keeps doing so every play and end cycle. If that makes sense. So I’m guessing each time it is storing it into memory instead of clearing. If I close and reopen the project they return to the start. But repeats until closed again.
Thank you both. I’ll do some more research and come back with what I learn.
Right, so maybe its something in your “Start” or “Awake” calls, some Editor Script or level loading logic that is creating Materials and not Destroying them again on leaving Play mode. So take a snapshot before and after whenever that jump in numbers occurs to check out where they got created and what might stick around on leaving playmode.
Well, I made a development build and ran the profiler. All seems to be good. There are no build up of anything. I even created a random scene to toggle between the two scenes(to mimic hitting play/stop in editor). After each switch - everything stays normal. No excess material/object build up. If I close the build, and reopen it, everything is still smooth and functioning as expected. From my very little knowledge of the profiler, it does seem like everything is working pretty decent… a few spikes but I don’t see them as drastic. Posted image below.
So literally the only time I experience this is during edit mode when entering/exiting play mode. So that being the case, I don’t believe I’ll stress it to much and continue on. Thanks for all the feedback, I did learn quite a bit about the profiler thanks to what you guys shared.