title: Put String result from Encode Base64 to JSONObject Out Of Memory
body: <p>I read many question about <code>OOM</code> but I am still stuck. I can not use <code>jsonObject.toString</code> to get array <code>bytes</code> at all. I have an Image taken by Camera and I want to send it into a service. I send it with HTTP POST with format :</p>
  
  <pre><code>{
   request : {
              image : encodedImageWithBase64
             }
  }
  </code></pre>
  
  <p>But I can't make a JSONObject cause <code>OOM</code>. Here String example from result Encoded Image : <a href="https://pastebin.com/RUXae9VU" rel="nofollow noreferrer">https://pastebin.com/RUXae9VU</a></p>
  
  <p>Here my snippet code : </p>
  
  <pre><code>JSONObject requestDict = new JSONObject();
              try {
                  JSONArray tempRequestDic = new JSONArray();
                  JSONObject obj = new JSONObject();
                  obj.put("imagedata", strEncode64);
                  tempRequestDic.put(obj);
  
                  obj.put("image", tempRequestDic);
                  requestDict.put("request", obj); /* Here I get the Exception*/
  
  //                    String strReqDict = String.valueOf(requestDict);
  //                    File x = new File(String.valueOf(requestDict));
                  byte[] byteBitmapDecoded = requestDict.toString().getBytes(); /* Here my apps force stop cause OOM */
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  </code></pre>
  
  <p>And the log is:</p>
  
  <blockquote>
    <p>Throwing OutOfMemoryError "Failed to allocate a 301989896 byte allocation with 16777216 free bytes and 283MB until OOM"</p>
  </blockquote>
  
  <p>I need a <code>byte[]</code> from this JSONObject but I can't build the JSONObject itself.</p>