Hey guys,
I have a pick and place system for a robot arm. The objects to pick are spawned on a conveyor and are moved by physics, but will be set to kinematic childs of the robot arm while picked. My memory consumption is slowly increasing when doing the (un-)parenting until it might crash at some time. If I comment those lines (11 & 27) out, the memory consumption is fine.
Hopefully you have an idea, what I am doing wrong here. Thank you very much.
[BurstCompile]
public partial struct PickTargetJob : IJobEntity {
public void Execute(Entity entity, ref RobotToolComponent tool)
{
// pick
if (tool.GripperIsActive && tool.CarriedEntity == Entity.Null)
{
// [...] Raycast stuff to get a reference to the correct entity
{
Ecb.AddComponent(hit.Entity, new PhysicsMassOverride() { IsKinematic = 1, SetVelocityToZero = 1 });
Ecb.AddComponent(hit.Entity, new Parent { Value = entity }); // This seems to cause the memory leak
Ecb.SetComponent(hit.Entity, LocalTransform.FromMatrix(matrix));
tool.CarriedEntity = hit.Entity;
}
}
}
// place
else if (tool.GripperIsActive == false)
{
// [...]
if (tool.CarriedEntity != Entity.Null)
{
// [...]
Ecb.RemoveComponent<Parent>(tool.CarriedEntity); // This seems to cause the memory leak
Ecb.SetComponent(tool.CarriedEntity, LocalTransform.FromMatrix(matrix));
Ecb.SetComponent(tool.CarriedEntity, new PhysicsMassOverride() { IsKinematic = 0, SetVelocityToZero = 0 });
Ecb.SetComponent(tool.CarriedEntity, new PhysicsVelocity { Linear = velocity});
tool.CarriedEntity = Entity.Null;
}
}
}
