Hi. In my game there is a huge memory leak. When l am doing memory profiling l see problem is related to ShaderVariablesProbeVolumes.
l am adding screenshot below for detailed info.
As you can see object id with 5280 is cause. l wrote to log actual instance name and it was ShaderVariablesProbeVolumes. So, l cant find what is actual cause.
Can you help me? Thanks!
What does it tell you about this object when you select the ID: 5280 entry in the Memory Profiler? What does it show you if you search the All Off Memory table for “ID: 5280”?
And how did you find the object to log it out? Was this an Editor snapshot and did you find it in the same Editor session as the one you took the snapshot from? Did you confirm that it’s .name property was an empty string?
Hi MartinTilo,
Here it is. l used
Object gameObject = EditorUtility.InstanceIDToObject(5280);
Debug.Log(gameObject.name);
to find real object.
l cant find why this object can cause memory leak.
Thank you!
If this logged out a name, it’s a different object. The object in the table has no name assigned to the .name property. The instance ID is only valid during the same session. Did you put a breakpoint on that log to probe what that object is in your IDE?
Also, an object can’t just have a graphics side to it. It also has to have a native root, and in this case a native object. If you search the table for the ID, you should be able to find that and get more info on it, than in the Graphics category. Also, if you update to version 1.1.3 you would see more info for it under the Graphics memory category.
@MartinTilo firstly great thanks for your support.
l upgraded to 1.1.3. l added new screenshot below. No additional info show on graphics part.
On the other hand, l see huge difference in UI Toolkit elements such as VisualElement etc. l think maybe these object count is increasing and it affects also graphic part.
Can it be cause?
Thanks
You are selecting a different entry, i.e. the Untracked > Graphics item instead of the Graphics > <No Name> > <No Name> > ID: 5280 that you selected before.
You can still use the Search field to filter the table for “ID: 5280” to find that item again.
What version of the memory Profiler did you upgrade from? It could be that the Managed Data Crawler got better at finding some Managed objects on the heap that were previously not found.
No, these are managed allocations and have nothing to do with graphics memory.
l upgraded memory profiler from 1.1.0 to 1.1.3
l searhed by id 5280. But still cant identify problem.
Also l noticed that when l taking memory snapshot, memory also increasing. (maybe it does mean something to you)
So, there is 2 situation for memory increase:
- Changing scene
- Taking memory snapshot
l think l found the problem. l am using UI Toolkit in my project. l removed component from scenes, and played without UI. No memory leak was shown. l think l should find a way of removing UI components
Instance IDs are very fleeting identifiers. They are only valid for one session. Which package version you made the snapshot with doesn’t matter, so if you go back to the 2 snapshots you were comparing in the beginning where an object with that ID popped up and search there, you should be able to get more info on that object with the 1.1.3 memory profiler UI.
Yes, changing scenes can increase the memory usage. Often some of that ends up as just an increase in reserved memory.
Taking a snapshot shouldn’t increase memory that much. If you are taking snapshots in the Editor and maybe even opening the snapshots in between, this is very much to be expected though, as there is no way for the Memory Profiler to just capture play mode. It’ll capture the entire Editor, including the UI for the Memory Profiler and the native and managed memory used for opening a snapshot or displaying the snapshot’s screenshot in the list of snapshots.
Thank you, MartinTilo!
l just set null for every visual element in UI Toolkit scripts. And it solved my memory leak.
Just like that. l dont know is it right way or maybe it is a bug. l think this objects should be collected by garbage collector in scene change. But objects live in memory. So, l should do this way.
If this script and the UIDocument component sits on a Game Object that no longer exists in the next scene, the UI Elements would get garbage collected. So something else must also be happening here
l agree.
l will review my project again and maybe can find a clue why it is happening.
Thank you!