Ok, I had a memory leak in my texture loading code. I could fix it and the big textures are now no more problem I think.
But I think my texture loading code could still need improvement. Right now I basically load a BufferedImage with ImageIO.read(File). The problem is, that I still need to copy that buffered image to another buffered image so that I can manually set the correct color model. If I directly use the image returned by ImageIO.read(File) everything looks blueish.
Basically the copy is not a huge problem but it causes the memory consumption to go pretty high in the beginning (to about 120 meg with my app now) and then all of a sudden it drops to 70 megs. I think it's also not so fast.
Here is the piece of code:
... Setup texture environment
// Create an appropriate color model and raster.
ColorModel glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[] { 8, 8,
8, 0 }, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
int rasterBands = 3;
if (image.getColorModel().hasAlpha()) {
rasterBands = 4;
glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
new int[] { 8, 8, 8, 8 }, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
}
WritableRaster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, textureWidth, textureHeight,
rasterBands, null);
// Copy the source image into a new image with the created color model and raster.
BufferedImage texImage = new BufferedImage(glColorModel, raster, false, new Hashtable<String, Object>());
texImage.setData(image.getData());
... Create buffer and pass it to OpenGL
If anybody knows how to possibly improve this please let me know.