ドキュメントでは900MBまでね、と書かれているのですがやっぱり事象を確認しないとすっきりしないので確認 t.co
検証用コード
using System; using System.Collections; using System.Collections.Generic; using System.Text; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public Text m_text; private string limit; private byte[] M100; private byte[] M200; private byte[] M300; private byte[] M400; private byte[] M500; private byte[] M600; private byte[] M700; private byte[] M800; private byte[] M900; private List<byte[]> bytes = new List<byte[]>(); private WaitForSeconds time = new WaitForSeconds(1); private StringBuilder sb = new StringBuilder(); private bool IsCatchedOutOfMemory = false; private void Start() { StartCoroutine(Alloc()); } //ヒープ領域を100MBずつ確保していく private IEnumerator Alloc() { M100 = new byte[104857600]; yield return time; M200 = new byte[104857600]; yield return time; M300 = new byte[104857600]; yield return time; M400 = new byte[104857600]; yield return time; M500 = new byte[104857600]; yield return time; M600 = new byte[104857600]; yield return time; M700 = new byte[104857600]; yield return time; M800 = new byte[104857600]; yield return time; M900 = new byte[104857600]; //ここでException yield return time; } private void Update() { var memory = GC.GetTotalMemory(false) * 0.00000095367432; var limit = #if WINDOWS_UWP Windows.System.MemoryManager.AppMemoryUsageLimit * 0.00000095367432; #else SystemInfo.systemMemorySize / 1024; #endif sb.Clear(); sb.AppendFormat("UsageLimit: {0:f3} MB", limit).AppendLine(); sb.AppendFormat("TotalMemory: {0:f3} MB", memory).AppendLine(); m_text.text = sb.ToString(); } }
900MB以上メモリを確保しようとすると怒られる様子 #HoloLens pic.twitter.com/F1lyQmwC7a
— デコシ (@Ash_Yin) January 9, 2019
本当はGC止めて,ボクシングとかでごみを増やしまくって殺そうと思ったのですが安定のUWPってやつです。
(^ν^)ピキ
— デコシ (@Ash_Yin) January 8, 2019
Getting garbage collector mode is not supported on this platform