Version: 2019.4
LanguageEnglish
  • C#
Method group is Obsolete

Profiler.GetRuntimeMemorySize

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete GetRuntimeMemorySize has been deprecated since it is limited to 2GB. Please use GetRuntimeMemorySizeLong() instead.

Declaration

public static int GetRuntimeMemorySize(Object o);

Description

Returns the runtime memory usage of the resource.

This has been implemented for the following resource types: Mesh, Texture, Audio, Animation and Materials Only available in development players and editor.

using UnityEngine;
using UnityEngine.Profiling;

public class Example : MonoBehaviour { void Update() { Texture[] textures = Resources.FindObjectsOfTypeAll<Texture>(); foreach (Texture t in textures) { Debug.Log("Texture object " + t.name + " using: " + Profiler.GetRuntimeMemorySize(t) + "Bytes"); } } }