Fix LodRenderSection memory leak
This commit is contained in:
@@ -481,7 +481,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements AutoClose
|
||||
QuadNode<LodRenderSection> quadNode = nodeIterator.next();
|
||||
if (quadNode.value != null)
|
||||
{
|
||||
quadNode.value.disposeRenderData();
|
||||
quadNode.value.dispose();
|
||||
quadNode.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ public class LodRenderSection implements IDebugRenderable
|
||||
public boolean canSwapBuffer() { return this.buildRenderBufferFuture != null && this.buildRenderBufferFuture.isDone(); }
|
||||
|
||||
|
||||
private void cancelBuildBuffer()
|
||||
public synchronized void disposeRenderData() // synchronized is a band-aid solution to prevent a rare bug where the future isn't canceled in the right order
|
||||
{
|
||||
if (this.buildRenderBufferFuture != null)
|
||||
{
|
||||
@@ -287,12 +287,8 @@ public class LodRenderSection implements IDebugRenderable
|
||||
this.buildRenderBufferFuture.cancel(true);
|
||||
this.buildRenderBufferFuture = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized void disposeRenderData() // synchronized is a band-aid solution to prevent a rare bug where the future isn't canceled in the right order
|
||||
{
|
||||
this.disposeRenderBuffer();
|
||||
this.disposeActiveBuffer = true;
|
||||
|
||||
this.renderSource = null;
|
||||
if (this.renderSourceLoadFuture != null)
|
||||
{
|
||||
@@ -301,12 +297,6 @@ public class LodRenderSection implements IDebugRenderable
|
||||
}
|
||||
}
|
||||
|
||||
public void disposeRenderBuffer()
|
||||
{
|
||||
this.cancelBuildBuffer();
|
||||
this.disposeActiveBuffer = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try and swap in new render buffer for this section. Note that before this call, there should be no other
|
||||
@@ -387,6 +377,7 @@ public class LodRenderSection implements IDebugRenderable
|
||||
{
|
||||
// the old buffer is now considered unloaded, it will need to be freshly re-loaded
|
||||
oldBuffer.buffersUploaded = false;
|
||||
oldBuffer.close();
|
||||
}
|
||||
ColumnRenderBuffer swapped = this.inactiveRenderBufferRef.swap(oldBuffer);
|
||||
didSwapped = true;
|
||||
@@ -431,10 +422,14 @@ public class LodRenderSection implements IDebugRenderable
|
||||
{
|
||||
this.disposeRenderData();
|
||||
DebugRenderer.unregister(this, Config.Client.Advanced.Debugging.DebugWireframe.showRenderSectionStatus);
|
||||
if (this.disposeActiveBuffer && this.activeRenderBufferRef.get() != null)
|
||||
if (this.activeRenderBufferRef.get() != null)
|
||||
{
|
||||
this.activeRenderBufferRef.get().close();
|
||||
}
|
||||
if (this.inactiveRenderBufferRef.value != null)
|
||||
{
|
||||
this.inactiveRenderBufferRef.value.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -583,7 +583,6 @@ public class LodRenderer
|
||||
try
|
||||
{
|
||||
this.setupLock.lock();
|
||||
this.isSetupComplete = false;
|
||||
|
||||
GLProxy.getInstance().recordOpenGlCall(() ->
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user