title: dalvikvm-heap grow heap (frag case) while upload video android
body: <p>I am facing problem whiel uploading the video from the 4x devices.I know that only 15 sec vedio recodring will create a 30 mb file in samsung S2 but while I am trying to upload the video on the php server first it shows the msg like 
       D/dalvikvm(7638): GC_FOR_ALLOC freed 263K, 9% free 12838K/14087K, paused 13ms, total 13ms
       I/dalvikvm-heap(7638): Grow heap (frag case) to 14.481MB for 1048592-byte allocation
       D/dalvikvm(7638): GC_FOR_ALLOC freed &lt;1K, 9% free 13861K/15175K, paused 22ms, total 22ms
       D/dalvikvm(7638): GC_CONCURRENT freed &lt;1K, 9% free 13862K/15175K, paused 12ms+2ms, total 27ms</p>
  
  <pre><code>I know it is the memory managment concept and device memory dependent but I want a real solution for it as I am stuck here from quite a few days.
  Below is my code to call and upload the video to server.
  
  public void newmethod( String Imageurl ) throws ClientProtocolException, IOException
  {
      byte[] data ; 
      int bytenumber,bufferSize,bytesRead;
      int maxBufferSize = 1*1024*1024;
        DataOutputStream dos = null;
       //File sourceFile =  searchForFileInExternalStorage("video.3gp");
  
       Log.e("in the method the path", ""+Imageurl);
  
        FileInputStream fileInputStream = new FileInputStream(Imageurl);
        bytenumber = fileInputStream.available();
        Log.e("in the method the the size of the file is", ""+bytenumber);
       // dos = new DataOutputStream(conn.getOutputStream());
        bufferSize = Math.min(bytenumber, maxBufferSize);
        data = new byte[bufferSize];
       //ProgressDialog pr = new ProgressDialog(getApplicationContext());
      // pr.addContentView(getCurrentFocus(), null);
         // read file and write it into form...
         bytesRead = fileInputStream.read(data, 0, bufferSize);
  
         while (bytesRead &gt; 0) {
         // dos.write(data, 0, bufferSize);
          bytenumber = fileInputStream.available();
           bufferSize = Math.min(bytenumber, maxBufferSize);
          bytesRead = fileInputStream.read(data, 0, bufferSize);
          }
  
       // pr.show();
  
  
      HttpClient httpClient = new DefaultHttpClient();
      HttpPost postRequest = new HttpPost("http://67.52.165.116/Kakz/mobiles/uploadvideo");
      ByteArrayBody bab = new ByteArrayBody( data, Imageurl);
      MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
      reqEntity.addPart("user_video", bab);
  
      FormBodyPart bodyPart=new FormBodyPart("title", new StringBody(title));
      reqEntity.addPart(bodyPart);
      bodyPart=new FormBodyPart("desc", new StringBody(description));
      reqEntity.addPart(bodyPart);
      bodyPart=new FormBodyPart("source", new StringBody("android"));
      reqEntity.addPart(bodyPart); 
      postRequest.setEntity(reqEntity);
      final HttpResponse response = httpClient.execute(postRequest);
      // FileInputStream fileInputStream = new FileInputStream(response.getEntity().getContent());
  
  
      runOnUiThread(new Runnable() {
           public void run() {
  
      //stuff that updates ui
  
               BufferedReader in = null;
              try {
                  in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
  
              } catch (IllegalStateException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
              } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
              }
                  String line = null;
  
      try {
          while((line = in.readLine()) != null) {
              System.out.println(line);
  
              titleText.setText("");
              descriptionText.setText("");
            //  Toast.makeText(getApplicationContext(), "Video Uploaded successfully", Toast.LENGTH_LONG).show();
  
              if (line.equalsIgnoreCase("Its too Heavy")) {
              //  pr.dismiss();
                  // titleText.setText("");
                  //descriptionText.setText("");
                  Toast.makeText(getApplicationContext(), "Video size is too heavy", Toast.LENGTH_LONG).show();
  
              }
  
              else if (line.equalsIgnoreCase("Error")) {
              //  pr.dismiss();
                  // titleText.setText("");
                  //descriptionText.setText("");
                  Toast.makeText(getApplicationContext(), "Error uploading video", Toast.LENGTH_LONG).show();
  
  
              }
  
              else  if (line.equalsIgnoreCase("Uploaded")) {
                  //pr.dismiss();
                   //titleText.setText("");
                  //descriptionText.setText("");
                  Toast.makeText(getApplicationContext(), "Video uploaded successfully", Toast.LENGTH_LONG).show();
  
              }
  
          }
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
           }
  });
  
  Please let me know that how I should manage the code to get it right.
  Any help would be appreciated ASAP`enter code here`
  </code></pre>