Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

We've started work on a new memory profiler

Discussion in 'Editor & General Support' started by Lucas-Meijer, Oct 3, 2015.

  1. vtaware

    vtaware

    Joined:
    May 10, 2017
    Posts:
    1
    "Memory profiling" Menu under windows Menu. I am using 5.3.8.F1
     
  2. Dragonic8926

    Dragonic8926

    Joined:
    Mar 10, 2014
    Posts:
    28
    Unity 5.4.3p1, downloaded and loaded the project from the repo

    First got this issue :
    It was on some lines like this one :
    Code (CSharp):
    1. UnityEngine.Profiling.Profiler.BeginSample("PackedMemorySnapshotUtility.SaveToFile");
    I deleted the word and Unity seems to accept that
    Code (CSharp):
    1. UnityEngine.Profiler.BeginSample("PackedMemorySnapshotUtility.SaveToFile");
    Android IL2CPP build on a Galaxy S6 Edge, Development Build and Autoconnnect profiler.
    The app is open, USB debuging ON, I have the realtime data on the Profiler, but the "Take snapshot" on the Memory Management Windows does nothing.
     
    Last edited: May 17, 2017
    bagelcode likes this.
  3. npruehs

    npruehs

    Joined:
    Jul 20, 2012
    Posts:
    67
    @Dragonic8926 Are you sure it actually does "nothing"? I've just started using the tool yesterday (and already find it helpful). I've also created a pull request for showing progress bars: https://bitbucket.org/Unity-Technologies/memoryprofiler/pull-requests/21

    Maybe that helps you already? Have you tried a relatively small scene? I've noted that in our battle scenes, it might take up to several minutes before the actual results are there, whereas in the main menu the download finished in a few seconds.

    You might also want to check the log window, chances are that you are getting exceptions while crawling the snapshot.
     
  4. Dragonic8926

    Dragonic8926

    Joined:
    Mar 10, 2014
    Posts:
    28
    That was a Hello World scene, so yes a "relatively small scene" ^^ !
    Nothing in the debug console.
     
    Last edited: May 30, 2017
  5. npruehs

    npruehs

    Joined:
    Jul 20, 2012
    Posts:
    67
    There's been an update to the profiler, have you tried the most recent version? It contains bugfixes and progress bars. Are these progress bars shown?
     
  6. Wahooney

    Wahooney

    Joined:
    Mar 8, 2010
    Posts:
    275
    Last edited: Jun 15, 2017
  7. Tsuole

    Tsuole

    Joined:
    Feb 5, 2016
    Posts:
    11
    Hi, I'm trying to make the profiler run. After clicking "take snapshot" and my app freezing for a long while, nothing shows up in the window for the memory profiler like yours does. Might I be doing something wrong ?
     
  8. KnightRiderGuy

    KnightRiderGuy

    Joined:
    Nov 23, 2014
    Posts:
    463
    is there a way to display the profiler data to a UI Canvas text? For example if I want to display both the actual CPU usage as a percentage and the RAM as a percentage?
     
  9. tomzigza

    tomzigza

    Joined:
    Aug 4, 2017
    Posts:
    23
    Can somebody explain why its so heavily pushed that this tool is for IL2CPP? I can use it on a windows build(which only builds mono) and it seems to work fine out of the box.
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,754
    It doesn't display full information on non-IL2CPP builds.
     
  11. tomzigza

    tomzigza

    Joined:
    Aug 4, 2017
    Posts:
    23
    Can you elaborate on what you don't get to see? It looked pretty awesome and I was able to see all the references and amounts of memory used.
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,754
    Sure. Mono/.NET scripting backends currently do not capture managed heap, so you cannot see any C# objects or references between them.
     
  13. tomzigza

    tomzigza

    Joined:
    Aug 4, 2017
    Posts:
    23
    So I ran it on android built under IL2CPP and I can't seem to see any c# objects. Our code base has a decent amount of plain old c# objects that have to work outside of unity as well. I have attached a snapshot of my profiler memory capture if that helps. The screen looks just about the same as it did when I ran it connected to windows editor.
    Edit
    I tried to upload this but the thing errors out immediatly so I put the file on my site:
    http://master.dev.crest-fallen.net/MemorySnapshot.zip
     
  14. tomzigza

    tomzigza

    Joined:
    Aug 4, 2017
    Posts:
    23
    I have gone back to 5.6.3p2 and done this process and I do see all the c# objects so you can disregard that previous message. Either was a unity 2017 issue or somehow I didn't do something right.
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,754
    Perhaps you accidentally had the profiler attached to the editor instead of the player?
     
  16. fdanf

    fdanf

    Joined:
    Jul 3, 2017
    Posts:
    3
    Was this ever updated to support the Mono backend?
     
  17. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    523
    https://bitbucket.org/Unity-Technologies/memoryprofiler
    It's getting support in 2017.3 (apparently not for .net 4.6 yet though?)

    Apparently this was added by a commit from an hour ago :)
     
  18. The-Britain

    The-Britain

    Joined:
    Mar 31, 2015
    Posts:
    714
    Is the memory profiler only available in pro?
     
  19. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,250
    The tool is available as a separate project only, not included in Unity, and works with Unity Personal/Plus/Pro.

    You can download the Memory Profiler here:
    https://bitbucket.org/Unity-Technologies/memoryprofiler
     
  20. pkbis

    pkbis

    Joined:
    Aug 1, 2017
    Posts:
    18
  21. Threepwood

    Threepwood

    Joined:
    Jul 23, 2009
    Posts:
    87
    @Tautvydas-Zilys

    Any chance this ever works on Mono backend? On 2017.3+ and OSX build, the memory profiler causes the spp to crash as soon as you click Take Snapshot. I know above you mention that it's for il2cpp only, but I can't really make a mobile build.

    Would be nice to be able to see large memory allocations and track them. Critical, in fact.
     
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,754
    Report a bug if you see crashes. We'll look at them.
     
  23. TimoSchmechel

    TimoSchmechel

    Joined:
    May 9, 2016
    Posts:
    3
    I am also getting crashes with the memory snapshots. At first I thought it wasn't a crash as I had done a snapshot of my game while in the main menu and it froze for around 15 minutes until it produced the snapshot so I assumed a snapshot of the game running would take even longer (although this time was already absurd) but after several hours it never recovered.

    Do you know when or If you will support Mono for .NET 4.5?
     
  24. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,115
    Is this still active? I hope so. The bitbucket hasn't been updated since October, which is a bit worrying, but it's already very useful.
     
    Prodigga likes this.
  25. pkbis

    pkbis

    Joined:
    Aug 1, 2017
    Posts:
    18
    Hello, is there any progress on the profiler? The capture doesn't work for our game, both in-editor and in-build, with the bitbucket looking dead (apart from people submitting their issues).
     
  26. jchowdown-asla

    jchowdown-asla

    Joined:
    May 10, 2017
    Posts:
    15
    I guess no one is working on this any more? Snapshots are broken for device builds made with 2017.3
     
  27. Patrascu

    Patrascu

    Joined:
    Jan 20, 2016
    Posts:
    59
    Hi @Lucas-Meijer or @Tautvydas-Zilys

    Any idea why taking a snapshot from an Xbox build with Il2CPP scripting backend won't work?
    We get this warning in the console: Sending message header failed

    The Profiler can connect just fine and and I take memory samples, but taking a memory snapshots with the new memory profiler won't work at all.

    The game is built with Unity 2017.1.3.p1 and the memory profiler project from Bitbucket is on the same version.

    Cheers
     
  28. firsttype8

    firsttype8

    Joined:
    Oct 4, 2016
    Posts:
    1
    I also get a crash when snapshotting on iPhone 6S connecting with usb cable.
    I am using Unity 5.6.5p3. From Xcode console, I got the EXC_BAD_ACCESS error,
    and the callstack was:
    - GetName()
    - CaptureNativeObjects()

    Would be a great help if it could be fixed in the future.
     
  29. Zenix

    Zenix

    Joined:
    Nov 9, 2009
    Posts:
    207
    Some objects are never released, even though the profiler says they're no longer referenced by anything. I don't know if this is a bug with the profiler, or with Unity itself. I've called Resources.UnloadUnusedAssets multiple times and the objects still show up in the profiler.
     

    Attached Files:

  30. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,115
    So I'll ask again, is this abandoned? Are there any plan to finish and or improve it?

    Or is this another one of those "OMG IT'S STARTING TO GET USEFUL, LET'S SILENTLY ABANDON IT" Unity features that I see a lot these days?
     
  31. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,754
    It's not abandoned. Did you report bugs about the issues you're facing?
     
  32. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,250
    (Case 1034172) PackedMemorySnapshot: "typeDescriptions" array is empty
    (Case 993250) PackedMemorySnapshot: RequestNewSnapshot causes Player to crash
    (Case 987987) PackedMemorySnapshot: "managedHeapSections" do not match stats in Profiler
    (Case 987839) PackedMemorySnapshot: Unexpected connections between native objects
    (Case 984330) PackedMemorySnapshot: Type contains staticFieldBytes, but has no static field
    (Case 975832) 2017.3: PackedMemorySnapshot: Missing connections between native objects
     
  33. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,754
  34. NeonCubeStudio

    NeonCubeStudio

    Joined:
    Jun 25, 2018
    Posts:
    2
    Hello everyone,

    Our team has been modifying the tool to suit our needs. It doesn't contain bugfixes of any kind besides that the line endings are now consistent, but several nice features have been added.

    Changes compared to the official repository:
    - Added spreadsheet view (as alternative to the default treemap view)
    - Added filters (to find what you're looking for more quicky)
    - Added back & next button
    - Changes to the user interface slightly for consistency
    - Removed unused code
    - Removed dependency on Json.Net
    - Dropped support for memsnap3 (dependent on Json.Net)

    If someone is dependent on memsnap3 files, we can write a tutorial to help you convert the memsnap3 files to memsnap2. These memsnap2 files can also be opened with unity's official memory profiler.

    Our memory profiler modifications are available here:
    https://github.com/NeonCubeStudio/MemoryProfiler/releases

    We're still working on removing even more unused code, and refactoring the code to make it more consistent and understandable.
     
    Last edited: Jun 28, 2018
    YJack and AcidArrow like this.
  35. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,250
    Zenix, Patrascu and Prodigga like this.
  36. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    790
    Amazing work! Shame this feature is being developed at a glacial pace, happy that you've put together a feature packed alternative!
     
    Last edited: Aug 12, 2018
    Peter77 likes this.
  37. nukeustwo

    nukeustwo

    Joined:
    Sep 4, 2015
    Posts:
    43
    This tool is super useful, is there a chance it will get integrated into Unity anytime soon?
     
  38. Ludiq

    Ludiq

    Joined:
    Mar 6, 2015
    Posts:
    618
    Hi,
    Is the memory profiler supposed to capture editor-only static fields?
    I'm trying to use it to debug memory usage for my Asset Store tool, which in the Profiler shows 400 MB of managed memory in use, but in the Memory Profiler only shows about 30 MB.