Przeglądaj źródła

minor memory fix

ncannasse 6 lat temu
rodzic
commit
ee7f00669f
1 zmienionych plików z 4 dodań i 1 usunięć
  1. 4 1
      h3d/scene/RenderContext.hx

+ 4 - 1
h3d/scene/RenderContext.hx

@@ -121,7 +121,7 @@ class RenderContext extends h3d.impl.RenderContext {
 		uploadParams = null;
 		uploadParams = null;
 		// move passes to pool, and erase data
 		// move passes to pool, and erase data
 		var p = allocFirst;
 		var p = allocFirst;
-		while( p != null ) {
+		while( p != null && p != allocPool ) {
 			p.obj = null;
 			p.obj = null;
 			p.pass = null;
 			p.pass = null;
 			p.shader = null;
 			p.shader = null;
@@ -131,6 +131,9 @@ class RenderContext extends h3d.impl.RenderContext {
 			p.texture = 0;
 			p.texture = 0;
 			p = @:privateAccess p.nextAlloc;
 			p = @:privateAccess p.nextAlloc;
 		}
 		}
+		// one pooled object was not used this frame, let's gc unused one by one
+		if( allocPool != null )
+			allocFirst = allocFirst.next;
 		allocPool = allocFirst;
 		allocPool = allocFirst;
 		for( c in cachedShaderList ) {
 		for( c in cachedShaderList ) {
 			c.s = null;
 			c.s = null;