Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Question How is the long size calculated from Profiler.GetRuntimeMemorySizeLong

Discussion in 'Scripting' started by AurelienChab, Mar 30, 2023.

  1. AurelienChab


    Dec 1, 2022

    I am building a tool to verify my materials and textures. In my script I am using the method
    UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong to get the size of all the textures used by the selected material.
    This method returns exactly 2x the size displayed in the editor when you preview your texture.

    How is this size calculated, what does it represent exactly ?
    If I want to get the texture memory usage, do I have to divide the result by 2 manually or is this returned size accurate ?
  2. GrahamHuws


    Unity Technologies

    Mar 14, 2022
    Hi @AurelienChab! GetRuntimeMemorySizeLong will include the impact on the CPU side and GPU side, so may appear to be double what you might expect.
    In Editor, both CPU and GPU copies are always loaded, but in players, marking the texture as Read-Only should mean you only have the GPU copy.
    MartinTilo and Bunny83 like this.