コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】System.InvalidOperationException: Jobs can only create Temp memory

概要

public struct Example : IJob
{
    void IJob.Execute()
    {
        var list = new NativeList<int>( Allocator.Persistent );
    }
}

上記のように IJob.Execute の中で Allocator.Persistent を指定して
NativeList を生成したら

System.InvalidOperationException: Jobs can only create Temp memory
This Exception was thrown from a job compiled with Burst, which has limited exception support.

上記の例外が発生する現象に遭遇した

public struct Example : IJob
{
    void IJob.Execute()
    {
        var list = new NativeList<int>( Allocator.Temp );
    }
}

Allocator.Temp を指定したら例外が発生しなくなった