facebook twitter hatena line email

Unity/Csharp/OutOfMemory

提供: 初心者エンジニアの簡易メモ
2021年7月7日 (水) 17:35時点におけるAdmin (トーク | 投稿記録)による版

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

サンプル

try
{
    try
    {
        string s = "This";
        s = s.Insert(2, "is ");
        throw new OutOfMemoryException();
    }
    catch (ArgumentException)
    {
        Console.WriteLine("ArgumentException in String.Insert");
    }
}
catch (OutOfMemoryException e)
{
    Debug.Log("e.message=" + e.Message); // Out of memory
}

throw new OutOfMemoryExceptionを投げると、OutOfMemoryExceptionでcatchできることを確認。

参考:https://docs.microsoft.com/ja-jp/dotnet/api/system.outofmemoryexception?view=net-5.0


unityでOutOfMemoryが起こったことを検知

Unity/負荷軽減/WebGL [ショートカット]