Here is the following error when executing the program. How can I avoid it, please help?
W/art: Throwing OutOfMemoryError "Failed to allocate a 51916812 byte allocation with 16777216 free bytes and 39MB until OOM" E/AndroidRuntime: FATAL EXCEPTION: Thread-10 Process: com.example.work, PID: 25823 java.lang.OutOfMemoryError: Failed to allocate a 51916812 byte allocation with 16777216 free bytes and 39MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:650) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:626) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:664) at com.example.work.MainStudent$1.run(MainStudent.java:115) at java.lang.Thread.run(Thread.java:760) W/AndroidRuntime: finished raiseRlimit, rlim_cur:4096 rlim_max:4096 String sql2 = "SELECT photo1,photo2,photo3 FROM post where email ="+"'"+Login.User+"'"; try { rs = stmt.executeQuery(sql2); } catch (SQLException e) { e.printStackTrace(); } try { while (rs.next()) { if(rs.getBlob("photo1") != null) { Blob imageBlob = rs.getBlob("photo1"); binaryStream = imageBlob.getBinaryStream(1, imageBlob.length()); postImage.add(BitmapFactory.decodeStream(binaryStream)); } else{ postImage.add(null); } if(rs.getBlob("photo2") != null) { Blob imageBlob = rs.getBlob("photo2"); binaryStream = imageBlob.getBinaryStream(1, imageBlob.length()); postImage.add(BitmapFactory.decodeStream(binaryStream)); } else { postImage.add(null); } if(rs.getBlob("photo3") != null) { Blob imageBlob = rs.getBlob("photo3"); binaryStream = imageBlob.getBinaryStream(1, imageBlob.length()); postImage.add(BitmapFactory.decodeStream(binaryStream)); } else { postImage.add(null); } } } catch (SQLException e) { e.printStackTrace(); }