Redian新闻
>
Wrap up -Re: Question: OutOfMemoryError
avatar
Wrap up -Re: Question: OutOfMemoryError# Java - 爪哇娇娃
g*y
1
Thanks all your guys' help!
Finally I dig it out: in MediaTracker.addImage(Image, int), I add a constant 0
as image ID, and waitForID(0) every time.
Somehow, JVM messed up there and can't release the resources even I request
Image.flush().
Now I change it to addImage(image, m_counter), and waitForID(m_counter), plus
that Image.flush(). JVM release graphics resources now.
avatar
KG
2
If u use ImageIcon, u don't have to bother MediaTracker.

【在 g**********y 的大作中提到】
: Thanks all your guys' help!
: Finally I dig it out: in MediaTracker.addImage(Image, int), I add a constant 0
: as image ID, and waitForID(0) every time.
: Somehow, JVM messed up there and can't release the resources even I request
: Image.flush().
: Now I change it to addImage(image, m_counter), and waitForID(m_counter), plus
: that Image.flush(). JVM release graphics resources now.

avatar
xt
3

It is not surprising that after you call addImage() it will add
that image onto the component without removing others. To my
understanding addImage means you add the image to a list of
the images the compnent holds. Therefore the component still keeps
the references to other images you no longer need after you add a
new image into it. You need to remove the images from that list
to save memory.
As for me, I would use a single Image object and dynamically change the
Graphics object associated wi

【在 g**********y 的大作中提到】
: Thanks all your guys' help!
: Finally I dig it out: in MediaTracker.addImage(Image, int), I add a constant 0
: as image ID, and waitForID(0) every time.
: Somehow, JVM messed up there and can't release the resources even I request
: Image.flush().
: Now I change it to addImage(image, m_counter), and waitForID(m_counter), plus
: that Image.flush(). JVM release graphics resources now.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。