Significant sprite packing memory leak fixes
additional thanks to GlFolker for reporting issues with undisposed content icon pixmaps
This commit is contained in:
@@ -115,6 +115,7 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
var result = Pixmaps.outline(base, outlineColor, outlineRadius);
|
var result = Pixmaps.outline(base, outlineColor, outlineRadius);
|
||||||
Drawf.checkBleed(result);
|
Drawf.checkBleed(result);
|
||||||
packer.add(page, regName, result);
|
packer.add(page, regName, result);
|
||||||
|
result.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,6 +127,7 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
var result = Pixmaps.outline(base, outlineColor, outlineRadius);
|
var result = Pixmaps.outline(base, outlineColor, outlineRadius);
|
||||||
Drawf.checkBleed(result);
|
Drawf.checkBleed(result);
|
||||||
packer.add(PageType.main, name, result);
|
packer.add(PageType.main, name, result);
|
||||||
|
result.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,8 +97,12 @@ public class MultiPacker implements Disposable{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
for(PixmapPacker packer : packers){
|
for(int i = 0; i < PageType.all.length; i ++){
|
||||||
packer.dispose();
|
var packer = packers[i];
|
||||||
|
//the UI packer's image is later used when merging with the font, don't dispose it
|
||||||
|
if(i != PageType.ui.ordinal()){
|
||||||
|
packer.forceDispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -969,6 +969,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
Drawf.checkBleed(outlined);
|
Drawf.checkBleed(outlined);
|
||||||
|
|
||||||
packer.add(PageType.main, regionName + "-outline", outlined);
|
packer.add(PageType.main, regionName + "-outline", outlined);
|
||||||
|
outlined.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1021,7 +1022,9 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
packer.add(PageType.main, name + "-treads" + r + "-" + i, frame);
|
packer.add(PageType.main, name + "-treads" + r + "-" + i, frame);
|
||||||
|
frame.dispose();
|
||||||
}
|
}
|
||||||
|
slice.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1294,6 +1294,8 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Seq<Pixmap> toDispose = new Seq<>();
|
||||||
|
|
||||||
//generate paletted team regions
|
//generate paletted team regions
|
||||||
if(teamRegion != null && teamRegion.found()){
|
if(teamRegion != null && teamRegion.found()){
|
||||||
for(Team team : Team.all){
|
for(Team team : Team.all){
|
||||||
@@ -1318,6 +1320,7 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
Drawf.checkBleed(out);
|
Drawf.checkBleed(out);
|
||||||
|
|
||||||
packer.add(PageType.main, name + "-team-" + team.name, out);
|
packer.add(PageType.main, name + "-team-" + team.name, out);
|
||||||
|
toDispose.add(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1337,6 +1340,7 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
Pixmap out = last = Pixmaps.outline(region, outlineColor, outlineRadius);
|
Pixmap out = last = Pixmaps.outline(region, outlineColor, outlineRadius);
|
||||||
Drawf.checkBleed(out);
|
Drawf.checkBleed(out);
|
||||||
packer.add(PageType.main, atlasRegion.name, out);
|
packer.add(PageType.main, atlasRegion.name, out);
|
||||||
|
toDispose.add(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
var toOutline = new Seq<TextureRegion>();
|
var toOutline = new Seq<TextureRegion>();
|
||||||
@@ -1350,6 +1354,7 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
Drawf.checkBleed(outlined);
|
Drawf.checkBleed(outlined);
|
||||||
|
|
||||||
packer.add(PageType.main, regionName + "-outline", outlined);
|
packer.add(PageType.main, regionName + "-outline", outlined);
|
||||||
|
toDispose.add(outlined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1367,12 +1372,15 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
packer.add(PageType.main, "block-" + name + "-full", base);
|
packer.add(PageType.main, "block-" + name + "-full", base);
|
||||||
|
|
||||||
editorBase = new PixmapRegion(base);
|
editorBase = new PixmapRegion(base);
|
||||||
|
toDispose.add(base);
|
||||||
}else{
|
}else{
|
||||||
if(gen[0] != null) packer.add(PageType.main, "block-" + name + "-full", Core.atlas.getPixmap(gen[0]));
|
if(gen[0] != null) packer.add(PageType.main, "block-" + name + "-full", Core.atlas.getPixmap(gen[0]));
|
||||||
editorBase = gen[0] == null ? Core.atlas.getPixmap(fullIcon) : Core.atlas.getPixmap(gen[0]);
|
editorBase = gen[0] == null ? Core.atlas.getPixmap(fullIcon) : Core.atlas.getPixmap(gen[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
packer.add(PageType.editor, name + "-icon-editor", editorBase);
|
packer.add(PageType.editor, name + "-icon-editor", editorBase);
|
||||||
|
|
||||||
|
toDispose.each(Pixmap::dispose);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int planRotation(int rot){
|
public int planRotation(int rot){
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ public class Floor extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
packer.add(PageType.environment, name + "-edge", result);
|
packer.add(PageType.environment, name + "-edge", result);
|
||||||
|
result.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ public class OreBlock extends OverlayFloor{
|
|||||||
packer.add(PageType.editor, "editor-block-" + name + "-full", image);
|
packer.add(PageType.editor, "editor-block-" + name + "-full", image);
|
||||||
packer.add(PageType.main, "block-" + name + "-full", image);
|
packer.add(PageType.main, "block-" + name + "-full", image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
image.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -25,4 +25,4 @@ org.gradle.caching=true
|
|||||||
#used for slow jitpack builds; TODO see if this actually works
|
#used for slow jitpack builds; TODO see if this actually works
|
||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
archash=580916ccfd
|
archash=8d5651a6ad
|
||||||
|
|||||||
Reference in New Issue
Block a user