浏览代码

Bug fix for visualization memory leak

I was reallocating a texture2D each frame. Changed it to re-use a member Texture2D and properly clean up allocated texture at program complete
/aisv749_viz_mem_leak_bug
Steven Borkman 4 年前
当前提交
934cdfb4
共有 1 个文件被更改,包括 13 次插入4 次删除
  1. 17
      com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs

17
com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs


private GameObject segVisual = null;
private RawImage segImage = null;
private Texture2D m_CpuTexture = null;
/// <inheritdoc/>
protected override bool supportsVisualization => true;

m_TargetTextureOverride.Release();
m_TargetTextureOverride = null;
if (m_CpuTexture != null)
{
Object.Destroy(m_CpuTexture);
m_CpuTexture = null;
}
}
/// <inheritdoc/>

void VisualizeSegmentationTexture(NativeArray<Color32> data, RenderTexture texture)
{
var cpuTexture = new Texture2D(texture.width, texture.height, GraphicsFormat.R8G8B8A8_UNorm, TextureCreationFlags.None);
cpuTexture.LoadRawTextureData(data);
cpuTexture.Apply();
segImage.texture = cpuTexture;
if (m_CpuTexture == null)
m_CpuTexture = new Texture2D(texture.width, texture.height, GraphicsFormat.R8G8B8A8_UNorm, TextureCreationFlags.None);
m_CpuTexture.LoadRawTextureData(data);
m_CpuTexture.Apply();
segImage.texture = m_CpuTexture;
}
/// <inheritdoc/>

正在加载...
取消
保存