Look, I’m sorry for blaming Java, but now you are insulting me, and I find that very rude. I will definitely admit I got pretty hotheaded, but I did not direct it at any of you, I was ranting about Java itself. Then for you to come back at me with personal insults I think is very uncalled for. Singal out what I was doing and I will stop it, but there is no reason for you to push the conflict. I did not even realize I was doing what I was doing, as many people do. I’m sorry, but don’t throw out any more insults, please. I have generally liked this community a lot up until now, but I am sure we can put this aside…
In any case –
- I meant heap size when I said stack size, sorry for the confusion. I’ve never had to worry about either before so I’m not an expert on the terminology.
- I just started using OpenGL very recently, and no, I don’t have much knowledge of it. That’s why I was asking if it would work.
- I was not using JLabels at all, I was asking if this might work better. I was using ImageIcons.
- I know very well how to use Java2D, enough to take a bunch of images and save new ones of different formats and size… I’m not incompetent.
- I have self-taught myself a lot of what I know, including BufferedImage’s, so anything I do wrong is because I was never taught it right. Maybe you can teach me instead of trying to put me down.
- I hadn’t encountered -Xss, etc. until now, so you’re right when you say I don’t understand it. However, I did read somewhere that -Xss isn’t supported on OS X, and indeed when I tried to use it saw no apparent changes at all. The function is there, but as far as I can see it does nothing.
- I was guessing when I said that Mac OS X can allocate memory. I wasn’t saying that’s how it is.
Phew. Hopefully I didn’t sound like a dick again. Again, I am very sorry about that.
I switched everything over to BufferedImage’s, then I resize the images as they are loaded into my image buffer. This takes some images as big as 3000x3000 and resizes them to about 500x500. I haven’t tested this method en masse yet, but I haven’t had any OutOfMemory errors so far.
My question now is whether or not this is worth doing. In order to resize the images, first I am loading in the whole image, creating scales of its width and height, creating a new buffered image with that scale, drawing the old image into the new one, then setting this new resized image as the new one. This makes it so that the images drawn to screen are much smaller, so no huge images are drawn, and I save memory between the currentImage and the buffer. However, I end up instantiating more memory for a short period of time.
Here’s an example. Say with the old method I have two 1mb images. There will theoretically be only 2mb of images in memory at a time. New method:
currentImage = 600k, buffer = 600k
That’s about half size most of the time, but while loading in another image:
currentImage = 600k, buffer = 1mb (temporary full size image loaded in) + 600k (resized image)
Is actually more memory at once. With lower numbers the new way would work better, with higher the old way. I’m not sure exactly how much memory I save when they are resized, but probably a good amount.
So, will this make a difference? Is it worth it? Should I change back? Is there possibly a better way?