Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

OutOfMemoryError eventhough i increased memory size by -Xmx1024m also  RSS feed

 
rama kammari
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It all depends on how many images you're retrieving from how many different URLs and how large those images are. You seem to be storing all of the BufferedImages in some reference called imageCache, which I guess is a Map of some sort. If you don't evict from that cache eventually all that image data is going to fill up the heap, and as image data usually has a relatively large memory foorprint that could happen quite fast. Also, you're using ImageIO to read from an InputStream, but you don't seem to be closing that InputStream anywhere in this code fragement. Make sure you do, because ImageIO won't do it for you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!