error uploading video to youtube in android
<p>i am uploading a video file to youtube.but it gives the outofmemory exception.For this i have to follow the below code.</p>

<pre><code> String youtubeUrl = "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
                    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

                    conn.setDoInput(true);
                    conn.setDoOutput(true);
                    conn.setRequestMethod("POST");
                    conn.setUseCaches(false);

                    conn.setRequestProperty("Host", "uploads.gdata.youtube.com");
                    conn.setRequestProperty("Authorization", "GoogleLogin auth=\""
                            + token + "\"");
                    conn.setRequestProperty("GData-Version", "2");
                    conn.setRequestProperty("X-GData-Client", clientID);
                    conn.setRequestProperty("X-GData-Key", "key=" + developerKey);
                    conn.setRequestProperty("Slug", file.getName());
                    // conn.setFixedLengthStreamingMode((int)file.length());
                    conn.setRequestProperty("Content-Type",
                            "multipart/related;boundary=\"" + boundary + "\"");
                    conn.setRequestProperty("Content-Length", getLength());


                    conn.setRequestProperty("Connection", "close");
    System.out.println("before dataoutput");
</code></pre>

<p>it executes fine upto here.it prints before dataoutput in logcat.whenever i am calling the</p>

<pre><code>DataOutputStream writer = new DataOutputStream(conn.getOutputStream());
</code></pre>

<p>throws the following error in logcat.</p>

<pre><code> before dataoutput
W/dalvikvm-heap( 5986): dvmMalloc(53947864/0x03372dd8): someone's allocating a huge buffer
I/dalvikvm-heap( 5986): Forcing collection of SoftReferences for 53947864-byte allocation
D/dalvikvm( 5986): GC_FOR_MALLOC freed 576K, 30% free 7805K/11079K, external 6716K/7596K, paused 67ms
E/dalvikvm-heap( 5986): Out of memory on a 53947864-byte allocation.
I/dalvikvm( 5986): "main" prio=5 tid=1 RUNNABLE
I/dalvikvm( 5986):   | group="main" sCount=0 dsCount=0 obj=0x40286180 self=0xce60
I/dalvikvm( 5986):   | sysTid=5986 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=-1345006528
I/dalvikvm( 5986):   at java.io.ByteArrayOutputStream.&lt;init&gt;(ByteArrayOutputStream.java:~63)
I/dalvikvm( 5986):   at org.apache.harmony.luni.internal.net.www.protocol.http.RetryableOutputStream.&lt;init&gt;(RetryableOutputStream.java:34)
I/dalvikvm( 5986):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:632)
I/dalvikvm( 5986):   at com.youtube.YoutubeUpload.upload(YoutubeUpload.java:83)
I/dalvikvm( 5986):   at com.youtube.YoutubeActivity$2.onItemClick(YoutubeActivity.java:270)
I/dalvikvm( 5986):   at android.widget.AdapterView.performItemClick(AdapterView.java:284)
I/dalvikvm( 5986):   at android.widget.ListView.performItemClick(ListView.java:3513)
I/dalvikvm( 5986):   at android.widget.AbsListView.onKeyUp(AbsListView.java:1929)
I/dalvikvm( 5986):   at android.widget.ListView.commonKey(ListView.java:2137)
I/dalvikvm( 5986):   at android.widget.ListView.onKeyUp(ListView.java:2046)
I/dalvikvm( 5986):   at android.view.KeyEvent.dispatch(KeyEvent.java:1280)
I/dalvikvm( 5986):   at android.view.View.dispatchKeyEvent(View.java:3855)
I/dalvikvm( 5986):   at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:787)
I/dalvikvm( 5986):   at android.widget.ListView.dispatchKeyEvent(ListView.java:2021)
I/dalvikvm( 5986):   at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
I/dalvikvm( 5986):   at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
I/dalvikvm( 5986):   at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
I/dalvikvm( 5986):   at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
I/dalvikvm( 5986):   at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
I/dalvikvm( 5986):   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1687)
I/dalvikvm( 5986):   at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1120)
I/dalvikvm( 5986):   at android.app.Activity.dispatchKeyEvent(Activity.java:2073)
I/dalvikvm( 5986):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1663)
I/dalvikvm( 5986):   at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2560)
I/dalvikvm( 5986):   at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2535)
I/dalvikvm( 5986):   at android.view.ViewRoot.handleMessage(ViewRoot.java:1867)
I/dalvikvm( 5986):   at android.os.Handler.dispatchMessage(Handler.java:99)
I/dalvikvm( 5986):   at android.os.Looper.loop(Looper.java:130)
I/dalvikvm( 5986):   at android.app.ActivityThread.main(ActivityThread.java:3683)
I/dalvikvm( 5986):   at java.lang.reflect.Method.invokeNative(Native Method)
I/dalvikvm( 5986):   at java.lang.reflect.Method.invoke(Method.java:507)
I/dalvikvm( 5986):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
I/dalvikvm( 5986):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
I/dalvikvm( 5986):   at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm( 5986):
D/AndroidRuntime( 5986): Shutting down VM
W/dalvikvm( 5986): threadid=1: thread exiting with uncaught exception (group=0x4027c560)
E/AndroidRuntime( 5986): FATAL EXCEPTION: main
E/AndroidRuntime( 5986): java.lang.OutOfMemoryError
E/AndroidRuntime( 5986):        at java.io.ByteArrayOutputStream.&lt;init&gt;(ByteArrayOutputStream.java:63)
E/AndroidRuntime( 5986):        at org.apache.harmony.luni.internal.net.www.protocol.http.RetryableOutputStream.&lt;init&gt;(RetryableOutputStream.java:34)
E/AndroidRuntime( 5986):        at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:632)
E/AndroidRuntime( 5986):        at com.youtube.YoutubeUpload.upload(YoutubeUpload.java:83)
E/AndroidRuntime( 5986):        at com.youtube.YoutubeActivity$2.onItemClick(YoutubeActivity.java:270)
E/AndroidRuntime( 5986):        at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime( 5986):        at android.widget.ListView.performItemClick(ListView.java:3513)
E/AndroidRuntime( 5986):        at android.widget.AbsListView.onKeyUp(AbsListView.java:1929)
E/AndroidRuntime( 5986):        at android.widget.ListView.commonKey(ListView.java:2137)
E/AndroidRuntime( 5986):        at android.widget.ListView.onKeyUp(ListView.java:2046)
E/AndroidRuntime( 5986):        at android.view.KeyEvent.dispatch(KeyEvent.java:1280)
E/AndroidRuntime( 5986):        at android.view.View.dispatchKeyEvent(View.java:3855)
E/AndroidRuntime( 5986):        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:787)
E/AndroidRuntime( 5986):
W/ActivityManager( 1222):   Force finishing activity com.youtube/.YoutubeActivity
W/ActivityManager( 1222): Activity pause timeout for HistoryRecord{40a1e588 com.youtube/.YoutubeActivity}
</code></pre>

<p>please help me..
thanks in advance..</p>
