Well JGO, hoping somebody can help me further ‘memory optimize’ my latest project (not posted yet).
Alright, my question is:
How can I load around 100 - 125 .PNG’s without using up alot of memory?
Information:
I’m currently Loading 123 .PNG’s (ImageIcon) on start up.
(Added to a ‘LinkedList<ImageIcon>’)
I did notice that changing them from a ‘BufferedImage’ to a ‘ImageIcon’ while loading them reduced loading time and allocated memory, so i left them as ImageIcon’s, also the same for ArrayList<ImageIcon> Vs. LinkedList<ImageIcon>.
Pseudo code:
I’m currently loading them like so:
public void loadFrames() {
frames = new LinkedList<ImageIcon>();
while (totalFramesLoaded < totalFrames) {
if (frameLoadingComplete) break;
frames.add(new ImageIcon("res/frames/export "+totalFramesLoaded+".PNG"));
totalFramesLoaded++;
/* Repaint our UI since our other Thread for doing this is currently paused */
progressBar.setValue(totalFramesLoaded);
getGamePanel().renderLoadingScreen();
}
}
It’s just too much on my game though :-, not the loading process ;), but the actual allocated memory for those ImageIcon’s.
Eventually it will just crash my IDE or my Game.
(Constantly rendering, updating, creating/processing objects, playing a animated background)
All of the above ^ + the allocated memory of those ImageIcon’s just tortures my computer.
Any help would be appreciated, possibly a better way to store the Images I.E cache.