#Leak detected, unknown objected deallocated error

1 messages · Page 1 of 1 (latest)

storm crane
#

I am getting this annoying bug but not sure why or how to fix it. I am trying to manipulate vertices with MeshDataArray.

This is what my code looks like:

//creates copy of mesh (apparently)
var data = Mesh.AllocateWritableMeshData(prefab); 
//original - readonly
var inputVerts = data[0].GetVertexData<float3>();
//buffer we will work with
var newVerts = new NativeArray<float3>(inputVerts, Allocator.TempJob);

for (int i = 0; i < path.Length; i++)
{
    //new mesh for each step along the path
    var m = new Mesh();

    //deform to conform to the path
    new DeformJob<T>(inputVerts, newVerts, path, i).Schedule(inputVerts.Length, 64).Complete();

    //set the changes and info to the new mesh we made
    Mesh.ApplyAndDisposeWritableMeshData(data, m);    
}

But i get this error:

Leak Detected : TempJob allocates 1 individual allocations.

InvalidOperationException: The UNKNOWN_OBJECT_TYPE DeformJob`1._input has been deallocated. All containers must be valid when scheduling a job.```

What am i getting wrong?
sullen prairie
#

A. it has been deallocated and the job cannot use that data.

storm crane
sullen prairie
#

Not that I can see. I'm sure they must have made the API like this for a reason though

#

Perhaps because the memory is literally used by the mesh once it's applied

#

so retaining it could be a leak or conflict of some sort

storm crane
#

Weird becusee you can get multiple data but not if you supply the mesh to copy the it only does it once

sullen prairie
#

I'm unfamiliar with the API's usage out of straight forward approaches, but both Allocate and Apply can take arrays of meshes.
As far as I can see you want to use a path.Length long array of prefab (weird name for a mesh), call data[i].GetVertexData, and write to it, and apply to your new mesh array at the end of the loop. Doing it all in parallel.
And never allocate your own array, because GetVertexData is writable, no? (not even sure what newVerts is for)

storm crane
#

The prefab isthe source mesh i'm copying from i just named it that to make sure i dont edit it's vertices