We've started work on a new memory profiler

Hi @Lucas-Meijer could I get a link to this documentation please? I haven’t been able to find anything myself. I’ve tried using MemorySnapshot.RequestNewSnapshot and comparing the instance ids of objects to detect the similarities but there are so many objects in the snapshot I suspect it’s also reading objects in Editor prefabs that aren’t loaded into the scene. That being a UnityEditor function I can’t use it in a build either.

Thanks for your help :slight_smile:

The documentation can be found in your editor installation folder on any 5.3 beta release.

MemorySnapshot.RequestNewSnapshot captures snapshot from whatever you connected your profiler to before you call it. If you did not connect profiler to any player, it will capture data from the editor.

Yet another feature while a looong list of existing features do not work as advertised…? Thanks a lot…

What exactly doesn’t work?

A random selection of things that really do not work as expected or advertised:

I could go on. How much time do you have?
Now, please do FIX the things that we report before you add more new features that work so-so.

I’m pretty sure the unity developer didn’t want a smattering of other bugs with other areas of the engine, but rather a bug report or detailed description of the problems encountered with the memory profiler.

@Foxxis : do we even have any open bug reports from you? Only one thread contains a case number from you, and that bug report was closed more than a year ago.

I usually log bugs for every issue I encounter. Why would I not, and why do you seem to imply I do not? What kind of strange defence is that?
I will have you know that out of the multitude of bugs I report I seldom get feedback and nor have the bugs been fixed in a timely manner. The substance problem is a year old or more. How do you think that affects the willingness to log bugs in the long term. I still log them, but when they are seldom fixed, I am starting to wonder why bother…?

I respect that you do not want OT posts in this topic, and I apologise for it. But is extremely frustrating to get a feature announcement when there are so many things that need fixing before you head on to the next shiny feature. You might want to forward that to your project manager as I am sure I am not alone. There is even a thread in the beta forum urging you to slow down and fix what is broken.

I appreciate it. You’d be surprised, but it’s often the case that people don’t file bugs, and instead just complain on forums.

I’m sorry you feel that way, but reported bugs are getting fixed. You might not always get a personal reply when they get resolved, but trust me, we do spend a lot of time fixing bugs.

As far as I can see, the bug in question was closed as “resolved” 6 days after you reported it.

Yeah, well. That goes to show how bug-fixing works, since it still did not work last time I tried. (Which was much later than the bug report date). I probably missed the closure/resolution message (if I even got one). But the sad part is that we actually ditched using substances since it was so unreliable in Unity.
So, a feature that you marketed very heavily a while back was dropped by a paying customer since it did and does not work well enough for production. Same goes with Speed Tree. I know a lot of devs who have reverted back to the old trees or other home-brew options. Because the advertised SpeedTree support is just a quick hack, and not usable in the present state.

How do you think that makes us feel? Paying for supposedly professional versions of the software and all too often learning that, oh no, the feature that looked as if it would elegantly solve a certain need does not, since it really does not work well enough or is buggy. Or both. Then you see new feature announcements while threads about problems and your bug reports go unanswered and not acted upon.

Think about it.

@Lucas-Meijer : THANK YOU! Seriously, memory management is one of the things that often gets put to the side as prototypes get promoted to projects and production schedules ask for features.

And as someone targeting WebGL for a significant chunk of business I’m really looking forward to using this.

@Lucas-Meijer : Thank you so much. Even in it’s current janky state, this has already helped me fix several extremely obscure problems in our game.

Did you know that Mono 2.0’s standard lib SortedList has a bug where it retains a reference to the last item in the list even after you remove everything from the list? I do now! (Check out RemoveAt line 462) Our code was completely correct by inspection, the ref chain was extremely obscure and the old memory profiler just reported “Referenced by some static. Not gonna tell ya which one lol.” Finding that leak would have been impossible before.

1 Like

Anything new on the subject? I can’t see the memory profiler anywhere on the roadmap :frowning:

5 Likes

Ey, such a great tool!

We are using it right now looking for a 100 MB memory leak we have in each menu->scene-> menu loop. The tool is very useful, but, is there any way to compare between snapshots? Because visually is very difficult to find any different.

Thank you

What’s the current status of this?

I’m using it to profile a windows standalone build made with Unity 5.5.0p1, and the information I’m seeing doesn’t appear to be accurate.

According to the snapshot, there’s a 2.7MB texture (splash-image) that’s always in memory. The profiler states that it’s referenced by a an object called ‘CharacterButton’, but that object should never reference that particular image.

The gameobject that should reference this image (SplashPage) is created at the start of the game and then destroyed shortly after.

Am I reading this wrong? Or is the info simply not correct?

Is there any way to use this on a PS4/X1/PC project?

Building for windows store has it’s own troubles converting and taking a sample on PS4 crashes the PS4 right away (even in our main menu). Anyone else have success on X1/PS4?

Update: We made a windows 10 store build and profiled using that. The memory tool helped us find a leak that we would’ve never found otherwise (leaking 100mb every scene load).
Thanks a lot for the tool, it’s reaaly promising. Can’t wait for il2cpp to be usable in normal standalone builds!

1 Like

Hello,

Is this project stopped? I say that because I am using it and I have seen this video

In it, @Lucas-Meijer uses a very interesting feature, Reference Chain, that I can not find in the bitbucket project. Moreover, I have seen interesting features in branches, like spreadsheet, but not merged.

So I do not know if this project is abandoned.

I hope not, because it is a great tool, but it feels like not completed.

Regards

This is exactly the kind of tool we need. Too bad it only works for IL2CPP platforms. Is there anything similar for mono backend?

Hello,
I am using 5.5.0f3. I assume this tool should still work?

I cannot get any data out of it. I get a couple of asserts, a lot, maybe thousands of warnings and end with with an index out of range error.

Asserts:

Assertion failed on expression: 'kSnapshotRuntimeInfoMagicBytes == magicBytes'

Sample Warnings:

Exception parsing object header. Skipping. System.ArgumentException: Unexpected pointersize: 0
  at MemoryProfilerWindow.BytesAndOffset.ReadPointer () [0x0005d] in /Projects/Unity-Technologies-memoryprofiler-40911eb35d1d/Assets/Editor/BytesAndOffset.cs:20
  at MemoryProfilerWindow.Crawler.ParseObjectHeader (MemoryProfilerWindow.StartIndices startIndices, UnityEditor.MemoryProfiler.MemorySection[] heap, UInt64 originalHeapAddress, System.UInt64& typeInfoAddress, System.Int32& indexOfObject, System.Boolean& wasAlreadyCrawled, System.Collections.Generic.List`1 outManagedObjects) [0x00011] in /Projects/Unity-Technologies-memoryprofiler-40911eb35d1d/Assets/Editor/Crawler.cs:231
  at MemoryProfilerWindow.Crawler.CrawlPointer (UnityEditor.MemoryProfiler.PackedMemorySnapshot packedMemorySnapshot, MemoryProfilerWindow.StartIndices startIndices, UInt64 pointer, Int32 indexOfFrom, System.Collections.Generic.List`1 out_connections, System.Collections.Generic.List`1 out_managedObjects) [0x00037] in /Projects/Unity-Technologies-memoryprofiler-40911eb35d1d/Assets/Editor/Crawler.cs:176
UnityEngine.Debug:LogWarningFormat(String, Object[])
MemoryProfilerWindow.Crawler:CrawlPointer(PackedMemorySnapshot, StartIndices, UInt64, Int32, List`1, List`1) (at Assets/Editor/Crawler.cs:180)
MemoryProfilerWindow.Crawler:Crawl(PackedMemorySnapshot) (at Assets/Editor/Crawler.cs:31)
MemoryProfilerWindow.MemoryProfilerWindow:IncomingSnapshot(PackedMemorySnapshot) (at Assets/Editor/MemoryProfilerWindow.cs:165)
UnityEditor.MemoryProfiler.MemorySnapshot:smile:ispatchSnapshot(PackedMemorySnapshot)
Skipping field Empty on type System.String
UnityEngine.Debug:LogWarningFormat(String, Object[])
MemoryProfilerWindow.Crawler:CrawlRawObjectData(PackedMemorySnapshot, StartIndices, BytesAndOffset, TypeDescription, Boolean, Int32, List`1, List`1) (at Assets/Editor/Crawler.cs:153)
MemoryProfilerWindow.Crawler:Crawl(PackedMemorySnapshot) (at Assets/Editor/Crawler.cs:36)
MemoryProfilerWindow.MemoryProfilerWindow:IncomingSnapshot(PackedMemorySnapshot) (at Assets/Editor/MemoryProfilerWindow.cs:165)
UnityEditor.MemoryProfiler.MemorySnapshot:smile:ispatchSnapshot(PackedMemorySnapshot)

Final Error:

IndexOutOfRangeException: Array index is out of range.
MemoryProfilerWindow.CrawlDataUnpacker.Unpack (MemoryProfilerWindow.PackedCrawlerData packedCrawlerData) (at Assets/Editor/CrawledDataUnpacker.cs:35)
MemoryProfilerWindow.MemoryProfilerWindow.Unpack () (at Assets/Editor/MemoryProfilerWindow.cs:154)
MemoryProfilerWindow.MemoryProfilerWindow.IncomingSnapshot (UnityEditor.MemoryProfiler.PackedMemorySnapshot snapshot) (at Assets/Editor/MemoryProfilerWindow.cs:166)
UnityEditor.MemoryProfiler.MemorySnapshot.DispatchSnapshot (UnityEditor.MemoryProfiler.PackedMemorySnapshot snapshot) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Profiler/MemorySnapshot.cs:24)

Is there something simple I am doing wrong? I’d cant package this project and send a bug. I will try it out on a smaller, sample/empty project for comparison.

Thanks!