Search Unity

Profiler memory size issues in Editor (2018 LTS)

Discussion in 'Editor & General Support' started by andyz, Jul 30, 2019.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    Could the profiler not be made more accurate in the editor?
    For instance for all Texture2Ds it shows double the memory size to runtime (due to having 1 write enabled and one not I believe) - perhaps it can know final will be half?
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,457
    Hi,
    If your Textures are Read/Write enabled in the import settings, they will be in memory twice. At least on most platforms, though there might be exceptions.
    The reason for this is, that the memory needs to be in CPU accessible RAM for reading or writing to it. Once a modification is made, the changed data is then uploaded to the GPU. Showing it as consuming double it's size in memory is therefore accurate.

    The Profiler can't really guess what you are planing to do with the data on the device and there are other device and platform specific implications that are maybe not that easy to foresee either (e.g. 64bit vs 32bit). When optimizing, performance related data should always be verified on a built players running on target devices, nothing else can be totally accurate. Profiling in the Editor should be considered as a clutch for a faster iteration cycle while optimizing.

    That said, we can try to give more hints about this in the tooling and maybe provide a more fuzzy "preview it as it would be on device" kind of view but I'm not sure how I'd prioritize that over making the data we have right now more actionable and the connection to devices more stable.

    Maybe if you could describe the problem you are trying to solve or that you would want us to help you solve in more detail, I could put this onto our roadmap. What would you expect the Memory Profiler to know about the final build data and why? Would you be comfortable to see guesstimated data in the tools for this purpose? Is it just texture data or also model/mesh data, animation data, sound... what other data would you expect to have displayed as such?
     
    andyz likes this.
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,457
  4. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    ah ok thanks. When profiling the runtime version it has half the memory - once I understood that it's easier, it is just a little confusing having double memory in editor's profiler.
     
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,457
    Please note, that that should not be the general case. If the Import settings have read/write enabled, it should to my knowledge take double the memory on ... most platforms?
    Just out of curiosity, do you happen to have different import settings per platform? And what platform did you profile?
     
  6. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    Just to be clear. I have a lot of textures showing as Texture2D in profiler.
    They are NOT marked as read/write enabled.
    In the editor their memory size is shown as double actual size it would take to store.
    At runtime (say webgl) the profiler shows actual normal 1x memory use.
    So a 1024x1024 DXT1 texture may show as 4mb in editor, then the more correct 2mb when profiling webgl
    edit: could be compressed textures shown in their pre-compressed size in editor...
     
    Last edited: Jul 31, 2019
  7. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,457
    ok, thank you for clarifying :)

    One more thing you could maybe help clarify for me: Are those textures sprites or sprite atlases?
     
  8. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    no straightforward textures - compressed DXT1. They are actually 2048x2048 so 2mb is compressed size as at runtime, 4mb in editor which is... I do not know what!

    edit: But if you look at a font atlas or a button atlas it is always shown as double the memory size in editor - seems like just a general rule for Texture2Ds, or possibly DXTs
     
    Last edited: Jul 31, 2019
  9. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,457
    right, there might be something on the Editor side that needs to keep them read enabled, e.g. the Editor Process in which the Playmode player is running, Inspectors or other tools. I'll add it to the list of things to investigate if we can figure out why it is read/write enabled (the likely reason for this). I asked about Sprite sheets because those are actually twice in memory when profiling in the editor, but iirc as two separate assets, the editor one and the "built/packed" one.

    So, the general advice still holds, profiling in the Editor is always to be taken with a grain of salt, because the playmode player is not cleanly isolated from the Editor process.
     
    Last edited: Aug 12, 2019