Out of Memory Exception during playing movie in Exoplayer
Hi , I take a update today for exoplayer dev-hls Branch. And I am getting crash after 3 second video play.
11-27 20:18:43.785: I/ACodec(19352): [OMX.SEC.avc.dec] Now Executing
11-27 20:18:43.860: D/dalvikvm(19352): GC_FOR_ALLOC freed 6342K, 31% free 24532K/35108K, paused 26ms, total 26ms
11-27 20:18:43.960: D/dalvikvm(19352): GC_FOR_ALLOC freed 718K, 17% free 29214K/35108K, paused 29ms, total 29ms
11-27 20:18:43.975: D/EventLogger(19352): videoSizeChanged [640, 304, 1.0]
11-27 20:18:44.020: D/dalvikvm(19352): GC_FOR_ALLOC freed 3K, 16% free 32354K/38168K, paused 27ms, total 27ms
11-27 20:18:44.040: D/EventLogger(19352): state [0.68, true, R]
11-27 20:18:44.085: D/dalvikvm(19352): GC_FOR_ALLOC freed 2K, 14% free 37545K/43336K, paused 25ms, total 25ms
11-27 20:18:44.190: D/dalvikvm(19352): GC_FOR_ALLOC freed 820K, 12% free 44792K/50612K, paused 26ms, total 27ms
11-27 20:18:44.330: I/dalvikvm-heap(19352): Clamp target GC heap from 69.583MB to 64.000MB
11-27 20:18:44.330: D/dalvikvm(19352): GC_FOR_ALLOC freed 98K, 10% free 54086K/59860K, paused 29ms, total 29ms
11-27 20:18:44.435: I/dalvikvm-heap(19352): Clamp target GC heap from 75.091MB to 64.000MB
11-27 20:18:44.435: D/dalvikvm(19352): GC_FOR_ALLOC freed 97K, 9% free 59726K/65504K, paused 36ms, total 36ms
11-27 20:18:44.435: I/dalvikvm-heap(19352): Forcing collection of SoftReferences for 65552-byte allocation
11-27 20:18:44.475: I/dalvikvm-heap(19352): Clamp target GC heap from 75.083MB to 64.000MB
11-27 20:18:44.475: D/dalvikvm(19352): GC_BEFORE_OOM freed 74K, 9% free 59652K/65504K, paused 42ms, total 42ms
11-27 20:18:44.475: E/dalvikvm-heap(19352): Out of memory on a 65552-byte allocation.
11-27 20:18:44.475: I/dalvikvm(19352): "Loader:HLS" prio=5 tid=37 RUNNABLE
11-27 20:18:44.475: I/dalvikvm(19352): | group="main" sCount=0 dsCount=0 obj=0x43630c98 self=0x621f82b0
11-27 20:18:44.475: I/dalvikvm(19352): | sysTid=19474 nice=0 sched=0/0 cgrp=apps handle=1696367616
11-27 20:18:44.475: I/dalvikvm(19352): | state=R schedstat=( 699007350 155348609 1888 ) utm=51 stm=18 core=3
11-27 20:18:44.475: I/dalvikvm(19352): at com.google.android.exoplayer.hls.TsExtractor$Sample.
Add android:largeHeap="true" to your application's manifest.
Alternatively, you can pass a smaller target buffer duration into the HlsChunkSource constructor. The default changed from 20 seconds to 40 seconds, which is why you're seeing this now when you weren't seeing it previously. Setting it back down to 20 seconds again will probably also solve the problem.
Here is code , Can you please tell me , where I have to changed the target buffer duration DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
DataSource dataSource = new UriDataSource(userAgent, bandwidthMeter);
boolean adaptiveDecoder = MediaCodecUtil.getDecoderInfo(MimeTypes.VIDEO_H264, true).adaptive;
HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter, null,
adaptiveDecoder ? HlsChunkSource.ADAPTIVE_MODE_SPLICE : HlsChunkSource.ADAPTIVE_MODE_NONE);
HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, true, 3);
HlsChunkSource has a constructor that takes three more arguments. Use that one if you want to change the values.
Make sure you have the latest version. This came in yesterday.
On 27 Nov 2014, at 16:13, ojw28 [email protected] wrote:
HlsChunkSource has a constructor that takes three more arguments. Use that one if you want to change the values.
— Reply to this email directly or view it on GitHub https://github.com/google/ExoPlayer/issues/174#issuecomment-64801386.
samek
yeah , we took update today .
ojw28, if i increase the large heap true , then video is playing for some time. definitely its playing more then before but still getting out of memory When I passed 20,5,5 into construction .the video is stuck .. and here log is: 11-27 20:59:31.040: D/EventLogger(28154): state [0.58, true, R] 11-27 20:59:31.050: I/ACodec(28154): [] Now uninitialized 11-27 20:59:31.050: I/OMXClient(28154): Using client-side OMX mux. 11-27 20:59:31.055: I/ACodec(28154): [OMX.SEC.avc.dec] Now Loaded 11-27 20:59:31.060: E/ACodec(28154): [OMX.SEC.avc.dec] storeMetaDataInBuffers failed w/ err -2147483648 11-27 20:59:31.060: W/ACodec(28154): [OMX.SEC.avc.dec] prepareForAdaptivePlayback failed w/ err -2147483648 11-27 20:59:31.060: I/ACodec(28154): [OMX.SEC.avc.dec] Now Loaded->Idle 11-27 20:59:31.065: E/ACodec(28154): ## 3d, eNativeColorFormat 0x15 11-27 20:59:31.065: E/ACodec(28154): ## 3d, eNativeColorFormat 0x105 11-27 20:59:31.065: I/ACodec(28154): [OMX.SEC.avc.dec] Allocating 5 buffers from a native window of size 299008 on output port 11-27 20:59:31.065: D/EventLogger(28154): state [0.61, true, B] 11-27 20:59:31.085: I/ACodec(28154): [OMX.SEC.avc.dec] Now Idle->Executing 11-27 20:59:31.090: I/ACodec(28154): [OMX.SEC.avc.dec] Now Executing 11-27 20:59:31.265: D/EventLogger(28154): videoSizeChanged [640, 304, 1.0]
You need to pass values in milliseconds. Try 20000, 5000, 10000. Although really you're better off leaving the values at their defaults and using largeHeap. 20 seconds of buffer isn't a huge amount if you're ever expecting variable network connectivity.
yeah ojw28, we tried to use the large Heap as well. and we tried both scenario sending the parameters or not. but still facing issues :(
How large is the heap when it crashes when you have largeHeap enabled?
@sachinbhanot you resolved this problem?
@crossle Still I am facing the problem, there is some issue in TsExtractor Class .The video is stuck and heap memory will increasing continuously. then out of memory exception come.
12-03 15:13:35.552: W/(20256): int32_t type = 0 12-03 15:13:35.552: W/(20256): void *node = 0x5e 12-03 15:13:35.552: W/(20256): int32_t event = 3 12-03 15:13:35.552: W/(20256): int32_t data1 = 1 12-03 15:13:35.552: W/(20256): int32_t data2 = 117440527 12-03 15:13:35.552: W/(20256): } unhandled in root state. 12-03 15:13:35.638: D/EventJioLogger(20256): end [8.11] 12-03 15:13:35.693: W/MessageQueue(20256): Handler (com.google.android.exoplayer.upstream.Loader$LoadTask) {429ee7b0} sending message to a Handler on a dead thread 12-03 15:13:35.693: W/MessageQueue(20256): java.lang.RuntimeException: Handler (com.google.android.exoplayer.upstream.Loader$LoadTask) {429ee7b0} sending message to a Handler on a dead thread 12-03 15:13:35.693: W/MessageQueue(20256): at android.os.MessageQueue.enqueueMessage(MessageQueue.java:294) 12-03 15:13:35.693: W/MessageQueue(20256): at android.os.Handler.sendMessageAtTime(Handler.java:473) 12-03 15:13:35.693: W/MessageQueue(20256): at android.os.Handler.sendMessageDelayed(Handler.java:446) 12-03 15:13:35.693: W/MessageQueue(20256): at android.os.Handler.sendEmptyMessageDelayed(Handler.java:410) 12-03 15:13:35.693: W/MessageQueue(20256): at android.os.Handler.sendEmptyMessage(Handler.java:395) 12-03 15:13:35.693: W/MessageQueue(20256): at com.google.android.exoplayer.upstream.Loader$LoadTask.run(Loader.java:208) 12-03 15:13:35.693: W/MessageQueue(20256): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442) 12-03 15:13:35.693: W/MessageQueue(20256): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 12-03 15:13:35.693: W/MessageQueue(20256): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 12-03 15:13:35.693: W/MessageQueue(20256): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 12-03 15:13:35.693: W/MessageQueue(20256): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 12-03 15:13:35.693: W/MessageQueue(20256): at java.lang.Thread.run(Thread.java:856) 12-03 15:13:35.693: I/Choreographer(20256): Skipped 41 frames! The application may be doing too much work on its main thread. 12-03 15:13:35.857: W/SurfaceView(20256): CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=false left=false top=false 12-03 15:13:35.920: E/SpannableStringBuilder(20256): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length 12-03 15:13:35.920: E/SpannableStringBuilder(20256): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length 12-03 15:13:36.326: D/dalvikvm(20256): GC_FOR_ALLOC freed 1400K, 11% free 34420K/38535K, paused 100ms, total 100ms 12-03 15:13:36.443: D/dalvikvm(20256): GC_FOR_ALLOC freed 1022K, 12% free 33938K/38535K, paused 86ms, total 86ms 12-03 15:13:36.443: I/dalvikvm-heap(20256): Grow heap (frag case) to 33.939MB for 362416-byte allocation 12-03 15:13:36.537: D/dalvikvm(20256): GC_FOR_ALLOC freed 1K, 12% free 34291K/38919K, paused 90ms, total 90ms 12-03 15:13:36.599: D/dalvikvm(20256): GC_FOR_ALLOC freed 184K, 12% free 34362K/38919K, paused 49ms, total 49ms 12-03 15:13:36.599: I/dalvikvm-heap(20256): Grow heap (frag case) to 34.276MB for 281792-byte allocation 12-03 15:13:36.677: D/dalvikvm(20256): GC_FOR_ALLOC freed 137K, 13% free 34500K/39239K, paused 72ms, total 72ms 12-03 15:13:36.748: D/dalvikvm(20256): GC_FOR_ALLOC freed 279K, 13% free 34371K/39239K, paused 71ms, total 71ms 12-03 15:13:36.841: D/dalvikvm(20256): GC_FOR_ALLOC freed 226K, 11% free 35019K/39239K, paused 58ms, total 58ms 12-03 15:13:36.841: I/dalvikvm-heap(20256): Grow heap (frag case) to 34.995MB for 362416-byte allocation 12-03 15:13:36.920: D/dalvikvm(20256): GC_FOR_ALLOC freed 1K, 11% free 35372K/39623K, paused 75ms, total 75ms 12-03 15:13:36.982: D/dalvikvm(20256): GC_FOR_ALLOC freed 71K, 11% free 35440K/39623K, paused 51ms, total 52ms 12-03 15:13:36.982: I/dalvikvm-heap(20256): Grow heap (frag case) to 35.403MB for 360016-byte allocation 12-03 15:13:37.037: D/dalvikvm(20256): GC_FOR_ALLOC freed <1K, 11% free 35791K/40007K, paused 51ms, total 51ms 12-03 15:13:37.123: D/dalvikvm(20256): GC_FOR_ALLOC freed 205K, 11% free 35764K/40007K, paused 64ms, total 65ms 12-03 15:13:37.131: I/dalvikvm-heap(20256): Grow heap (frag case) to 35.891MB for 540016-byte allocation 12-03 15:13:37.177: D/dalvikvm(20256): GC_FOR_ALLOC freed <1K, 11% free 36290K/40583K, paused 49ms, total 49ms 12-03 15:13:37.263: D/dalvikvm(20256): GC_FOR_ALLOC freed 78K, 11% free 36394K/40583K, paused 53ms, total 54ms 12-03 15:13:37.263: I/dalvikvm-heap(20256): Grow heap (frag case) to 36.506MB for 540016-byte allocation 12-03 15:13:37.341: D/dalvikvm(20256): GC_FOR_ALLOC freed <1K, 11% free 36921K/41159K, paused 76ms, total 76ms 12-03 15:13:37.427: D/dalvikvm(20256): GC_FOR_ALLOC freed 239K, 11% free 36910K/41159K, paused 60ms, total 60ms 12-03 15:13:37.427: I/dalvikvm-heap(20256): Grow heap (frag case) to 37.010MB for 540016-byte allocation 12-03 15:13:37.474: D/dalvikvm(20256): GC_FOR_ALLOC freed <1K, 11% free 37437K/41735K, paused 49ms, total 49ms 12-03 15:13:37.545: D/dalvikvm(20256): GC_FOR_ALLOC freed 35K, 11% free 37478K/41735K, paused 58ms, total 63ms 12-03 15:13:37.545: I/dalvikvm-heap(20256): Grow heap (frag case) to 37.566MB for 540016-byte allocation 12-03 15:13:37.599: D/dalvikvm(20256): GC_FOR_ALLOC freed <1K, 11% free 38006K/42311K, paused 54ms, total 54ms 12-03 15:13:37.701: D/dalvikvm(20256): GC_FOR_ALLOC freed 205K, 11% free 37964K/42311K, paused 74ms, total 74ms 12-03 15:13:37.709: I/dalvikvm-heap(20256): Grow heap (frag case) to 38.040MB for 540016-byte allocation 12-03 15:13:37.779: D/dalvikvm(20256): GC_FOR_ALLOC freed <1K, 11% free 38491K/42887K, paused 70ms, total 70ms 12-03 15:13:38.529: D/dalvikvm(20256): GC_CONCURRENT freed 19115K, 51% free 21329K/42887K, paused 13ms+20ms, total 126ms 12-03 15:13:39.006: D/dalvikvm(20256): GC_CONCURRENT freed 1472K, 50% free 21850K/42887K, paused 13ms+10ms, total 111ms 12-03 15:13:40.068: D/dalvikvm(20256): GC_CONCURRENT freed 2134K, 50% free 21656K/42887K, paused 13ms+11ms, total 117ms 12-03 15:13:41.615: D/dalvikvm(20256): GC_CONCURRENT freed 3107K, 53% free 20566K/42887K, paused 17ms+6ms, total 104ms 12-03 15:13:42.115: D/dalvikvm(20256): GC_CONCURRENT freed 1196K, 51% free 21417K/42887K, paused 3ms+11ms, total 72ms 12-03 15:13:42.115: D/dalvikvm(20256): WAIT_FOR_CONCURRENT_GC blocked 54ms 12-03 15:13:42.123: D/dalvikvm(20256): WAIT_FOR_CONCURRENT_GC blocked 62ms 12-03 15:13:42.123: D/dalvikvm(20256): WAIT_FOR_CONCURRENT_GC blocked 63ms 12-03 15:13:42.256: D/dalvikvm(20256): GC_FOR_ALLOC freed 889K, 49% free 22199K/42887K, paused 71ms, total 71ms 12-03 15:13:42.373: D/dalvikvm(20256): GC_FOR_ALLOC freed 417K, 45% free 23783K/42887K, paused 59ms, total 63ms 12-03 15:13:42.474: D/dalvikvm(20256): GC_CONCURRENT freed 172K, 43% free 24816K/42887K, paused 3ms+20ms, total 98ms
We can't investigate this without more information (e.g. a test stream that reproduces the problem).
@ojw28 I think it should when invoke release, not free the memory, when playback again, it's will occur.
@ojw28 I used demo playback Apple single media playlist, when press back key, invoke releasePlayer(), but the memory not free, the playback again, the memory release. but I used in my project, why not free? the only different is I used TextureView not SurfaceView
What points in graph correspond to doing what? There isn't a releasePlayer() method in ExoPlayer.

This is ExoPlayer releasePlayer() on FullPlayActivity.java. It's only on Galaxy nexus, I found on Nexus 7 2013, it have been growing.
It looks like the memory is being correctly released to me (which is why the blue area drops down). Although the fact it gets up to 190MB is a bit concerning. That seems excessive.
I also used Nexus 7 2013, it gets up to 210MB, you can test on your phone, when close the player, when press back key, the memory still not release...
I really don't understand. Your own graph shows the memory being de-allocated. The fact that the process is still allocated a large heap (most of which is unused) isn't relevant.
What version of Android are you running? I'll try and reproduce on a Nexus 7. It doesn't reproduce on the devices I have.
Android 5.0, Nexus 7 2013.