I’m looking for some strategies/advice on how to handle garbage collection. I have a Tile-based game with procedurally generated tiles. Empty tile objects are created and stored in an ArrayList, and the tiles’ images are set when the tile is on screen.
My issue is, whenever I get about ~1000 tiles away from the starting position, I get an exception saying I’ve run out of GC overhead space. I’m thinking I don’t actually need access to anything other than what is on the screen, because I can regenerate/recalculate everything else I need dynamically - most of the tiles and chunks that are storing the tiles are created and used while they’re onscreen but I don’t need them anymore afterwards. I’m not very familiar with how Java actually handles garbage collection, does anybody have any tips/advice or know of any documentation I could read on Java Garbage Collection?