Преглед изворни кода

[MEMORY] Dispose model cache libs.

clandrin пре 3 година
родитељ
комит
23e17de757
2 измењених фајлова са 11 додато и 2 уклоњено
  1. 4 2
      h3d/prim/ModelCache.hx
  2. 7 0
      hxd/fmt/hmd/Library.hx

+ 4 - 2
h3d/prim/ModelCache.hx

@@ -17,10 +17,12 @@ class ModelCache {
 	}
 
 	public function dispose() {
-		anims = new Map();
-		models = new Map();
+		for( m in models )
+			m.lib.dispose();
 		for( t in textures )
 			t.dispose();
+		anims = new Map();
+		models = new Map();
 		textures = new Map();
 	}
 

+ 7 - 0
hxd/fmt/hmd/Library.hx

@@ -260,6 +260,13 @@ class Library {
 		return p;
 	}
 
+	public function dispose() {
+		for( p in cachedPrimitives )
+			if( p != null )
+				p.decref();
+		cachedPrimitives = [];
+	}
+
 	function makeMaterial( model : Model, mid : Int, loadTexture : String -> h3d.mat.Texture ) {
 		var m = header.materials[mid];
 		var mat = h3d.mat.MaterialSetup.current.createMaterial();