g**********y 发帖数: 14569 | 1 In my application, I draw a sequence of JPEG images on a component:
(1) Read image file from hard-disk, use MediaTracker to guarantee it's fully
loaded before drawing
(2) Pass the Image object to component, and in paint() method, draw the Image
Program runs fine until around 200 times loop, OutOfMemoryError pops up.
I searched FAQ and newgroups, find people suggesting calling Image.flush()
after drawing. I add this after drawImage() call, still, it doesn't help.
Anyone has suggestions?
Thanks! | xt 发帖数: 17532 | 2
When you run java, add sth like "-mx512m" to define the maximum
memory for JVM. You can define up to 2048m.
【在 g**********y 的大作中提到】 : In my application, I draw a sequence of JPEG images on a component: : (1) Read image file from hard-disk, use MediaTracker to guarantee it's fully : loaded before drawing : (2) Pass the Image object to component, and in paint() method, draw the Image : Program runs fine until around 200 times loop, OutOfMemoryError pops up. : I searched FAQ and newgroups, find people suggesting calling Image.flush() : after drawing. I add this after drawImage() call, still, it doesn't help. : Anyone has suggestions? : Thanks!
| g**********y 发帖数: 14569 | 3 That can only relieve the symptom instead of solving the problem. I set it to
512M, it just runs out of memory in longer time.
Why JVM holds the graphics memory so long? Is it a design bug or just because
I didn't find the right way to force the releasing of memory? | KG 发帖数: 515 | 4 do you load the image everytime paint() is called? Does it have to be an AWT
app?
【在 g**********y 的大作中提到】 : In my application, I draw a sequence of JPEG images on a component: : (1) Read image file from hard-disk, use MediaTracker to guarantee it's fully : loaded before drawing : (2) Pass the Image object to component, and in paint() method, draw the Image : Program runs fine until around 200 times loop, OutOfMemoryError pops up. : I searched FAQ and newgroups, find people suggesting calling Image.flush() : after drawing. I add this after drawImage() call, still, it doesn't help. : Anyone has suggestions? : Thanks!
|
|