Search Unity

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:
    34
    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:
    34
    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:
    281
    Last edited: Jun 15, 2017
  7. Tsuole

    Tsuole

    Joined:
    Feb 5, 2016
    Posts:
    12
    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:
    515
    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:
    31
    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:
    10,674
    It doesn't display full information on non-IL2CPP builds.
     
  11. tomzigza

    tomzigza

    Joined:
    Aug 4, 2017
    Posts:
    31
    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:
    10,674
    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:
    31
    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:
    31
    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:
    10,674
    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:
    612
    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. boxhallowed

    boxhallowed

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

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    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:
    95
    @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:
    10,674
    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:
    11,735
    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:
    26
    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:
    213
    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:
    11,735
    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:
    10,674
    It's not abandoned. Did you report bugs about the issues you're facing?
     
  32. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    (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:
    10,674
  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

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    Zenix, Patrascu and Prodigga like this.
  36. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    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:
    51
    This tool is super useful, is there a chance it will get integrated into Unity anytime soon?
     
  38. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    812
    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.
     
  39. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,451
    This thread relates to a version of the Memory Profiler we usually refer to as the "Bitbucket Memory Profiler" because that was the chosen path for distributing it and we needed a way to differentiate it from the Memory Profiler Module and now the Memory Profiler Package. Work on the Bitbucket Memory Profiler post its original release slowly died off and for a long while it was only maintained. From 2018.3 on-wards I'd strongly encourage you to use the packaged Memory Profiler instead which is under active development and will eventually be released as a verified package. The continuous work on the native back-end and the packaged front-end has by now cause the Bitbucket Memory Profiler to no longer be compatible with newer Unity versions.

    To avoid confusing matters more, could you please check that out with the latest version of the packaged Memory Profiler and start a thread in the Profiler Previews subforum about this if it still seems confusing with that?