Andrew Lee - HESE S/W wrote:
>
> Has anyone here encountered really poor memory usage when using multiple texture
> maps in a scene? I'm writing a visualization tool that requires several texture
> maps to be rendered on quadrilateral surfaces. The problem is that the VM's
> memory usage shoots up 4 or 5 megabytes with each texture added, independent of
> texture size or color depth.
What I believe you are seeing is a function of extremely poor image
loading that Sun provides as default with the JDK.
The basic problem is this: If your image is 128x128 pixels at 4 bytes
per pixel, this requires 65K of memory. Due to Sun's design, the Image
object created as a result consumes just over 4 times this amount of
memory (ie 262K) which is exactly four copies of the image plus a little
for overheads. If you check the source, you will see that copies are
kept all over the place in what is an _extremely_ messy and poor
implementation.
Now, to compound the problem, inside the TextureLoader utility class (I
guess that is what you are using to load the textures) you are also
probably creating a scaled version of the image to fit on the object.
The code actually creates a new instance of the image with calls to
getScaledImage, which creates a completely new instance of the Image
doubling your memory usage again. (now at just over half a meg). Other
things are also done like creating ImageComponent2Ds, but I have no idea
what is happening internally with that class. However, I suspect it is
also copying the image internally as well. Finally, do you have
mipmapping enabled? This could also add to memory usage. However, I
couldn't really see this going over the 1M5 bytes mark - not the 4-5MB
you are talking
These numbers don't add up to what you are seeing. Are your images
greater in size than 128 square that you are quoting these numbers on?
--
Justin Couch Author, Java Hacker
Snr Software Engineer [EMAIL PROTECTED]
ADI Ltd, Systems Group http://www.vlc.com.au/~justin/
Java3D FAQ: http://tintoy.ncsa.uiuc.edu/~srp/java3d/faq.html
-------------------------------------------------------------------
"Look through the lens, and the light breaks down into many lights.
Turn it or move it, and a new set of arrangements appears... is it
a single light or many lights, lights that one must know how to
distinguish, recognise and appreciate? Is it one light with many
frames or one frame for many lights?" -Subcomandante Marcos
-------------------------------------------------------------------
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".