Question about memory use in JAI

S

syg6

Hello all.

I have a general question about memory usage in JAI. When I issue a
JAI.create() command, like the following:

PlanarImage image = (PlanarImage) JAI.create("fileload", path);

I notice that the javaw.exe process jumps up to something like 50 Mb.
(The image weighs about 3Mb). I have tried everything I know to free up
memory after having processed the image, and nothing seems to work. I
have tried:

cache.flush()
image.dispose()
JAI.disableDefaultTileCache();
image.removeSinks()

No matter what I do the memory doesn't drop. I have read that the JAI
cache frees up space automatically (by deleting images) when more space
is needed. But from what I have seen the cache is not the problem; I do
a cache.flush() and it is emptied out but the memory used by the JVM
remains the same.

Any ideas on what could be happening here?

Thanks in advance,
syg
 
A

Andrew Thompson

syg6 said:
...But from what I have seen the cache is not the problem; I do
a cache.flush() and it is emptied out but the memory used by the JVM
remains the same.

Any ideas on what could be happening here?

It might be you are getting over anxious. Have there been
any OutOfMemoryErrors in this application? It might just be
the 'JVM remains the same' simply because it sees no reason
to perform Garbage Collection.
 
S

syg6

True enough, I am a pretty anxious guy. :)

But from what I've read the JVM assigns 16Mb of memory to JAI, and when
I create the image the JVM memory jumps to 50! The second image makes
it jump to 100, etc. So far with 4 images, all of which are more or
less the same size, it jumps up to 170Mb. Well beyond 16Mb. And when I
try to force garbage collection by calling dispose() and setting the
image to null, AND calling garbage collection by hand, and nothing
happens.

Even if I am being anxious, shouldn't some kind of garbage collection
be going on here?

Confused ...
syg
 
R

Roedy Green

Even if I am being anxious, shouldn't some kind of garbage collection
be going on here?

Like an energy-conserving (lazy) husband, by default, Java does not
handle the garbage until it has to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,113
Latest member
Vinay KumarNevatia
Top