Unity Jobs Error - "Job can only create Temp memory"

Hello, I am trying to create the following struct inside a job and get the above error.

public struct JobSafeHeightMap {
	//Convert 2D array into 1D, we will have to convert back.
	public NativeArray<float> array;
	public readonly int size1;
	public readonly int size2;
	public readonly bool complete;

	public JobSafeHeightMap(float[,] array, int size1, int size2, bool complete) {
		this.array = new NativeArray<float>(size1 * size2, Allocator.TempJob);
		for(int i = 0; i < size1; i++) {
			for(int j = 0; j < size2; j++) {
				this.array[i * size1 + j] = array[i, j];
            }
        }
		this.size1 = size1;
		this.size2 = size2;
		this.complete = complete;
	}

	public float[,] GetArray() {
		float[,] returnFloat = new float[size1, size2];
		for(int i = 0; i < size1; i++) {
			for (int j = 0; j < size2; j++) {
				returnFloat[i, j] = array[i * size1 + j];
            }
        }
		return returnFloat;
    }
}

The line the error points to is:

this.array = new NativeArray<float>(size1 * size2, Allocator.TempJob);

Anyone know why this doesn’t work?
Thanks!

Key words are:

I am trying to create the following (job) struct inside a job
_

  1. Mid-execution Jobs can allocate Allocator.Temp only. That’s it. But before you even change that, read points 2 and 3.
  2. Scheduling a Job is possible from main application thread only and impossible from a Job.
  3. Jobs cannot access managed allocation such as float[,], so this approach makes no sense either way.