Search Unity

Why my texture consumes double memory than it should be in Profiler

Discussion in 'Editor & General Support' started by mituba, Dec 30, 2015.

  1. mituba

    mituba

    Joined:
    Oct 8, 2012
    Posts:
    2
    IMG_04992.jpg

    Sorry I can't provide a clear image because my company didn't allow that.
    I am running my Game in UnityEditor(Unity 4.6.1), the texture 'loading002' was compressed as ETC2, so far as my understood it's size should be 0.5mb(As the inspector shown at the left). But in the profiler it shows the texture consume 1mb memory.
    On the other hand, there's another texture named 'Loading' behaved normal.(2.7mb plus mips = 3.3mb)

    Import settings of my texture are:
    Read/Write Enabled = disabled
    ImportType = Default
    Generate Mip Maps = disabled

    Please anyone can explain me what is exactly the reason that this happens?
    Thanks !
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Not sure this is the case here, but you can check out the release notes for Unity 5.3 (here: https://unity3d.com/unity/whats-new/unity-5.3)

    It mentions this behaviour as a bug that was fixed:
    • OpenGL: Fixed texture memory usage reporting in profiler, was twice the actual size for most textures
     
    doggan likes this.
  3. mituba

    mituba

    Joined:
    Oct 8, 2012
    Posts:
    2
    Thank you.

    It's probably not my case, since my editor is running in directx9.

    However, if my problem has anything relevant to this bug, it will really shock me.
    How can unity leave such a bug unfixed from 4.x until 5.3
     
  4. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Unity stores double textures in memory this allows for instance the selection of /2 /4 /8 quality textures under the quality tab. It seems to do the same for meshes as well(no idea why?). Its a huge issue for me as i am using 32 bit system if memory is a issue you can switch to /8 texture quality to reduce the one set of textures unfortunalety it does not effect the 2nd set.In the build only the one set of textures is saved so you can double check it that way.
     
  5. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    It would be good if we could disable this double memory usage.
     
  6. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Actually, @Aras replied to a similar question i asked:
     
  7. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Yep and seems to do the same for meshes.
     
  8. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    But for me it's even worse in the player (iOS).

    I have a 512x512 RGB with mipmaps (created from jpg bytes) that should take 1Mb. According to the profiler, in editor it takes 2Mb, and in player 2.3Mb.

    And please, can you direct me to this other thread. Thanks.

    EDIT:

    Actually I've just noticed that LoadImage has a second parameter called markNonReadable - presumably setting this to true will fix the issue on device? Unfortunately I can't try it right now as the parameter is not available on 5.2.4 and I don't want to update to 5.3 yet.
     
    Last edited: Feb 1, 2016
  9. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    What version of Unity are you on ?
     
  10. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    5.2.4
     
  11. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Same here
     
  12. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    And what happens on device for you?
     
  13. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Same - it shows double the amount i expect it to be :(
     
  14. DarkCooker

    DarkCooker

    Joined:
    Jan 7, 2015
    Posts:
    119
    Any solution or simply upgrade to Unity 5.3 to fix it?
    Is it the real memory usage? if not it is no harm
     
  15. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I am on 5.3.2p3 (latest available version). The profiler still shows double the amount of memory for textures... I submitted a bug for this today (along with exact repro and a sample project). Hopefully someone will have a look at it to say whats going on.
     
  16. DarkCooker

    DarkCooker

    Joined:
    Jan 7, 2015
    Posts:
    119
    I wonder if it is the bug because I use 3rd party test platform to run the game.
    This really should the ram usage as in profiler. This seems not a bug for profiler but something related to texture settings.
    My concern is how to tune down that double issue.
     
  17. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    In my case, i am concerned whether this is a real bug with textures (somehow they occupy twice the memory that is needed), or just a bug in the profiler, or maybe just a bug in the profiler but only when profiling the editor.

    In any case, it is not clear and should be examined by Devs at Unity...
     
  18. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    @liortal, could you try something as you have 5.3? Use Texture2D.LoadImage to create a new texture from a jpg or png file but set the new markNonReadable flag to true (not available in 5.2). I'm really interested to know if setting non-readable means that the texture will not use double the memory on device.

    I can't test it myself as I'm still on 5.2 at this time.

    Thanks.
     
  19. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I already did this test and it made no difference.

    I reported this as a bug. They saidthey were able to reproduce it. Waiting to hear back.
     
  20. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Ok, thanks.

    Can you post their response here once you get it?
     
  21. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Sure, i will.
     
  22. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Finally upgraded to 5.3 (5.3.3) and tried it. Found that it doesn't use double memory on device.

    I'm reading in the bytes for a 512x512 jpg. My texture is RGB24 non-mipmapped (0.75Mb) and in the editor takes 1.5Mb which is double what it should take. On device it takes 1Mb which is still more than it should be but at least it's not double.

    I'll just add that it's 1Mb with the markNonReadable flag set to true and it's 1.8Mb with the flag set to false. On device.
     
    liortal likes this.
  23. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I am on 5.3.2p3, can't upgade at the moment. I need to profile on device to see the results. Haven't heard any updates on the bug i opened...
     
  24. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Got this reply.

    Hey,

    We have been able to reproduce this bug and have sent it for resolution with our developers.

    We highly appreciate your contribution. If you have further questions, feel free to contact us.

    Regards,
    Laurynas
     
  25. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Which bug is that? i also reported it as a bug but no updates yet on whats going on... :/
     
  26. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    I reported this recently. I waited until I had 5.3.3 as I know they are more likely to look at bugs for the latest version.

    My texture is RGB24 non-mipmapped (0.75Mb) ... On device it takes 1Mb which is still more than it should be but at least it's not double.
     
  27. theFrenchDutch

    theFrenchDutch

    Joined:
    May 5, 2014
    Posts:
    25
    Hi ! Have you guys found answers on this issue yet ? I am generating heavy terrain data and storing it in floating point textures which take 4mb each... The Unity profiler reports them as using 8mb each. Thus we're talking 2Gb of data in RAM instead of the 1Gb i should be seeing, so this is very important for my project :/

    A standalone build seems to use less RAM, but not twice less. I don' treally get this, any status updates ?
     
  28. romangaina

    romangaina

    Joined:
    Feb 8, 2020
    Posts:
    2
    finally figured it out, it's only in the editor. I plugged in my device and build the game connected to the Profiler and turns on device assets occupy the same space in memory as the file

    But in editor it's like double or sometimes triple