OutOfMemoryError eventhough i increased memory size by -Xmx1024m also
posted 4 years ago
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.