Slowdown when rendering large images...

Hello… in my program i have a background (1000x700), it considerably lags my machine when my BufferedImage is this large, i even have it loaded into a HashMap cache, it works great when its 400x400 or less, is there any reason as to why it may be lagging, is there a way to speed it up? (ill post code if needed)

You probably run out of accelerated memory with a big image.
do this to find out the accel. memory available:
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getAvailableAcceleratedMemory()

and this to see if the back image is indeed accelerated:
image.getCapabilities().isAccelerated()

Also, on windows beware of it shifting the image out of accel. memory if you use transparencies (or anti-aliasing etc) on the image. When this happens, frame rate drops to about 2 fps.
Use the VM option -Dsun.java2d.ddforcevram=true to stop this.

I got plenty of memory, but acceleration is pushed off from anti-aliasing and transparency, so how do i do the VM option thingy?

Memory: 130243840
Memory: 130211072
Memory: 130211072


BufferedImage img = cache.getImage("Background", 1000, 700);// returns image from hashmap if exists, if not, creates a //compatible bufferedimage with 1000x700
		Graphics2D imageDrawer = img.createGraphics();
		if(!imgcreated){
			imageDrawer.setColor(Color.WHITE);
			imageDrawer.fillRect(0,0, img.getWidth(), img.getHeight());
			imgcreated = true;
		}
		System.out.println("Memory: "+GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getAvailableAcceleratedMemory());
		//System.out.println("Accellerated: "+img.getCapabilities(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()).isAccelerated());
		//draw stuff to the image

from the command line, do

…/bin/java -Dsun.java2d.ddforcevram=true -classpath mainClass

or edit the appropriate property in the IDE. In JCreator it is in ‘Build’ then ‘Runtime COnfiguration’.

it still has the lag, im guessing its mabye just the fact the comp only has 256mb ram and windows xp… but somehow i doubt thats the case… mabye painting it too many times

EDIT: i played around witht he settings a bit, and its defenently not my loop laggin it.

What are the results of this:
image.getCapabilities().isAccelerated()

Also, when you say lag is it a periodic lag or does is frame rate just get a lot worse?

well… its the frame rate

image.getCapabilities().isAccelerated() returns false

even when i launch through commandline with the forced ram, i even altered my program to use a volatile image instead of a buffered, still had performance loss…

BUT regardless of all that I have solved the problem ! W00T!!!, i went looking at my cache class that i was using, and noticed that before it returned the image to my main application, it decided to create a graphics class, and draw the image… then it passed the image to my program, i commented that out and there is no noticable performance loss now =D

I’m not sure how correct this is, but I heard once that on some machines, images won’t be acclerated unless their dimensions are in powers of 2. your dimension is 1000x700 soo, maybe try resizing the dimensions. the closest thing would be 1024x512