I have been going crazy with this android error and from browsing the previous posts about this error none of the solutions that were given helped me.
I am of course talking about the all powerful killer known as the 'android Out of memory on a (NUMBER)-byte allocation.' I am trying to create a photo uploader and after the 3rd maybe 4th image my app crashes. I know to stop the crash to use a catch exception however that is not my problem. I am here to ask the community is there any solution to fixing this byte allocation error ?
Here is a snippet of my code involving the bit map .
String post = editTextPost.getText().toString().trim(); // get the photo : Bitmap image = ((BitmapDrawable)postImage.getDrawable()).getBitmap(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); // compress the image to jpg format : image.compress(Bitmap.CompressFormat.JPEG, 45, byteArrayOutputStream); byte[] imageBytes = byteArrayOutputStream.toByteArray(); String encodeImage = Base64.encodeToString(imageBytes,Base64.DEFAULT); // Recycle bitmap : image.recycle(); image=null; // send data : sendPost p = new sendPost(this); p.execute(post, encodeImage); imageBytes=null; Im not using any libraries and would like to keep it that way however if using a library is the only option I will use one. Hopefully someone can help.