0

How can we handle out of memory error?

One of our customers contacted us and said when he uploads images, face with this error

out of memory

I asked about size of images he said 4MB, but I could upload even a 7 MB image successfully.

So I tried to upload big images until I faced the error, most of them uploaded successfully but I faced the same error when uploading some of them

I found that error was not related in size of image, it's related to width and height of image

You can understand better by look at this link

memory error

but I don't know what exactly max-width and max-height are, that I can validate to prevent this error.

I forgot to say, also I resize images dynamically.

But I can't say to users resize your images because them take large pictures with their phone but maybe some of them didn't know how can resize images with photoshop.

please help

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user3250818
  • 239
  • 3
  • 16

1 Answers1

0

Ideally you should restructure your code to use less memory.

There are ways to decrease the memory overflow for any JVM process.

  • just give the JVM more memory with the -Xmx option.
  • You should decode with inSampleSize option to reduce memory consumption.
  • Another option inJustDecodeBounds can help you to find correct inSampleSize value
  • Also have a look over this article
Community
  • 1
  • 1