<div dir="ltr">My FFmpeg use version 4.3.1<div>While I'm using it to decode a rtmp stream from internet on iPad. It caused memory leak after a long time.</div><div><br></div><div>By the code check line by line, I found memory increased about 0.1Mb per 10sec~12sec.</div><div>After a few hours, the memory usage would become very huge.</div><div><br></div><div>And It caused by the function:</div><div>"avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame),<br></div><div>which is implement in decode.c</div><div><br></div><div>I still not really figure out what caused the problem.</div><div><br></div><div>there is my code using avcodec_receive_frame below, I use it to decode each frame.</div><div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,161,192);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)">- (</span><span class="gmail-s2" style="color:rgb(178,24,137)">BOOL</span><span class="gmail-s1" style="color:rgb(255,255,255)">)</span>stepFrame</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)">{</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">int</span> frameFinished=<span class="gmail-s3" style="color:rgb(120,109,196)">0</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>[<span class="gmail-s4" style="color:rgb(131,192,87)">lock</span> <span class="gmail-s5" style="color:rgb(0,160,190)">lock</span>];</p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span>[</span><span class="gmail-s2" style="color:rgb(178,24,137)">self</span><span class="gmail-s1" style="color:rgb(255,255,255)"> </span>cleanupFrame<span class="gmail-s1" style="color:rgb(255,255,255)">];</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span>[</span><span class="gmail-s2" style="color:rgb(178,24,137)">self</span><span class="gmail-s1" style="color:rgb(255,255,255)"> </span>cleanupPacket<span class="gmail-s1" style="color:rgb(255,255,255)">];</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>pFrame<span class="gmail-s1" style="color:rgb(255,255,255)"> = </span>av_frame_alloc<span class="gmail-s1" style="color:rgb(255,255,255)">();</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>packet<span class="gmail-s1" style="color:rgb(255,255,255)"> = </span>av_packet_alloc<span class="gmail-s1" style="color:rgb(255,255,255)">();</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">while</span> (</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">self</span> != <span class="gmail-s2" style="color:rgb(178,24,137)">nil</span> &&</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>!frameFinished &&</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s4" style="color:rgb(131,192,87)">pFormatCtx</span> != <span class="gmail-s2" style="color:rgb(178,24,137)">NULL</span> && <span class="gmail-s4" style="color:rgb(131,192,87)">pFormatCtx</span> != <span class="gmail-s2" style="color:rgb(178,24,137)">nil</span> &&</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s4" style="color:rgb(131,192,87)">pFormatCtx</span>-><span class="gmail-s4" style="color:rgb(131,192,87)">priv_data</span> != <span class="gmail-s2" style="color:rgb(178,24,137)">NULL</span> &&</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s4" style="color:rgb(131,192,87)">pFormatCtx</span>-><span class="gmail-s4" style="color:rgb(131,192,87)">priv_data</span> != <span class="gmail-s2" style="color:rgb(178,24,137)">nil</span> &&</p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>av_read_frame<span class="gmail-s1" style="color:rgb(255,255,255)">(</span>pFormatCtx<span class="gmail-s1" style="color:rgb(255,255,255)">, </span>packet<span class="gmail-s1" style="color:rgb(255,255,255)">) >= </span><span class="gmail-s3" style="color:rgb(120,109,196)">0</span><span class="gmail-s1" style="color:rgb(255,255,255)"> )</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>{</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span><span class="gmail-s2" style="color:rgb(178,24,137)">if</span><span class="gmail-s1" style="color:rgb(255,255,255)">(</span>packet<span class="gmail-s1" style="color:rgb(255,255,255)">-></span>stream_index<span class="gmail-s1" style="color:rgb(255,255,255)">==</span>videoStream_id<span class="gmail-s1" style="color:rgb(255,255,255)">)</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>{</p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span><span class="gmail-s2" style="color:rgb(178,24,137)">int</span><span class="gmail-s1" style="color:rgb(255,255,255)"> ret = </span>avcodec_send_packet<span class="gmail-s1" style="color:rgb(255,255,255)">(</span>videoCodecCtx<span class="gmail-s1" style="color:rgb(255,255,255)">, </span>packet<span class="gmail-s1" style="color:rgb(255,255,255)">);</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">if</span>( ret < <span class="gmail-s3" style="color:rgb(120,109,196)">0</span> )</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>{</p>
<p class="gmail-p5" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(219,44,56);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span>[</span><span class="gmail-s2" style="color:rgb(178,24,137)">self</span><span class="gmail-s1" style="color:rgb(255,255,255)"> </span><span class="gmail-s4" style="color:rgb(131,192,87)">phoenixFFmpegLog</span><span class="gmail-s1" style="color:rgb(255,255,255)">:</span>@"step frame send packet error"<span class="gmail-s1" style="color:rgb(255,255,255)">];</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">return</span> <span class="gmail-s2" style="color:rgb(178,24,137)">FALSE</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>}</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>ret = <span class="gmail-s3" style="color:rgb(120,109,196)">0</span>;</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">while</span>( ret >= <span class="gmail-s3" style="color:rgb(120,109,196)">0</span> )</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>{</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span>ret = </span>avcodec_receive_frame<span class="gmail-s1" style="color:rgb(255,255,255)">(</span>videoCodecCtx<span class="gmail-s1" style="color:rgb(255,255,255)">, </span>pFrame<span class="gmail-s1" style="color:rgb(255,255,255)">);</span></p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>av_image_copy(tmp_framedata, tmp_linesize, (const uint8_t**)pFrame->data , pFrame->linesize, videoCodecCtx->pix_fmt, self.outputWidth, self.outputHeight);</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>av_frame_unref(pFrame);</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>[<span class="gmail-s2" style="color:rgb(178,24,137)">self</span> <span class="gmail-s4" style="color:rgb(131,192,87)">cleanupFrame</span>];</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s4" style="color:rgb(131,192,87)">pFrame</span> = <span class="gmail-s4" style="color:rgb(131,192,87)">av_frame_alloc</span>();</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">if</span>( ret == <span class="gmail-s6" style="color:rgb(198,124,72)">AVERROR</span>(<span class="gmail-s6" style="color:rgb(198,124,72)">EAGAIN</span>) || ret == <span class="gmail-s6" style="color:rgb(198,124,72)">AVERROR_EOF</span> )</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>{</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>frameFinished = <span class="gmail-s3" style="color:rgb(120,109,196)">1</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>ret = <span class="gmail-s3" style="color:rgb(120,109,196)">0</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">break</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>}</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>}</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">if</span>( ret < <span class="gmail-s3" style="color:rgb(120,109,196)">0</span> )</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>{</p>
<p class="gmail-p5" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(219,44,56);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span>[</span><span class="gmail-s2" style="color:rgb(178,24,137)">self</span><span class="gmail-s1" style="color:rgb(255,255,255)"> </span><span class="gmail-s4" style="color:rgb(131,192,87)">phoenixFFmpegLog</span><span class="gmail-s1" style="color:rgb(255,255,255)">:</span>@"step frame received error"<span class="gmail-s1" style="color:rgb(255,255,255)">];</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">return</span> <span class="gmail-s2" style="color:rgb(178,24,137)">FALSE</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>}</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>}</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span><span class="gmail-s2" style="color:rgb(178,24,137)">if</span><span class="gmail-s1" style="color:rgb(255,255,255)"> (</span>packet<span class="gmail-s1" style="color:rgb(255,255,255)">-></span>stream_index<span class="gmail-s1" style="color:rgb(255,255,255)">==</span>audioStream_id<span class="gmail-s1" style="color:rgb(255,255,255)">) {</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span>[</span>_audioManager<span class="gmail-s1" style="color:rgb(255,255,255)"> </span>enqueuePacket<span class="gmail-s1" style="color:rgb(255,255,255)">:</span>packet<span class="gmail-s1" style="color:rgb(255,255,255)">];</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">if</span>( !<span class="gmail-s4" style="color:rgb(131,192,87)">primed</span> )</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>{</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s4" style="color:rgb(131,192,87)">primed</span> = <span class="gmail-s2" style="color:rgb(178,24,137)">YES</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>[<span class="gmail-s4" style="color:rgb(131,192,87)">_audioManager</span> <span class="gmail-s4" style="color:rgb(131,192,87)">play</span>];</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>}</p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>av_frame_unref(pFrame);</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>[<span class="gmail-s2" style="color:rgb(178,24,137)">self</span> <span class="gmail-s4" style="color:rgb(131,192,87)">cleanupFrame</span>];</p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>pFrame<span class="gmail-s1" style="color:rgb(255,255,255)"> = </span>av_frame_alloc<span class="gmail-s1" style="color:rgb(255,255,255)">();</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>}</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>}</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">if</span>(frameFinished)</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>{</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><br></p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>sws_scale(img_convert_ctx,</p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>(const uint8_t* const *)tmp_framedata,</p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>tmp_linesize,</p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>0,</p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>self.outputHeight,</p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>picture_data,</p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>picture_linesize);</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><br></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>av_freep<span class="gmail-s1" style="color:rgb(255,255,255)">(&</span>tmp_framedata<span class="gmail-s1" style="color:rgb(255,255,255)">[</span><span class="gmail-s3" style="color:rgb(120,109,196)">0</span><span class="gmail-s1" style="color:rgb(255,255,255)">]);</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s4" style="color:rgb(131,192,87)">tmp_framedata</span>[<span class="gmail-s3" style="color:rgb(120,109,196)">0</span>] = <span class="gmail-s2" style="color:rgb(178,24,137)">nil</span>;</p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>av_image_alloc<span class="gmail-s1" style="color:rgb(255,255,255)">(</span>tmp_framedata<span class="gmail-s1" style="color:rgb(255,255,255)">, </span>tmp_linesize<span class="gmail-s1" style="color:rgb(255,255,255)">, </span><span class="gmail-s2" style="color:rgb(178,24,137)">self</span><span class="gmail-s1" style="color:rgb(255,255,255)">.</span>outputWidth<span class="gmail-s1" style="color:rgb(255,255,255)">, </span><span class="gmail-s2" style="color:rgb(178,24,137)">self</span><span class="gmail-s1" style="color:rgb(255,255,255)">.</span>outputHeight<span class="gmail-s1" style="color:rgb(255,255,255)">, </span>AV_PIX_FMT_YUV420P<span class="gmail-s1" style="color:rgb(255,255,255)">, </span><span class="gmail-s3" style="color:rgb(120,109,196)">1</span><span class="gmail-s1" style="color:rgb(255,255,255)">);</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>}</p>
<p class="gmail-p6" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,182,69);background-color:rgb(30,32,40)">//<span class="gmail-Apple-converted-space"> </span>av_frame_unref(pFrame);</p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span>[</span><span class="gmail-s2" style="color:rgb(178,24,137)">self</span><span class="gmail-s1" style="color:rgb(255,255,255)"> </span>cleanupFrame<span class="gmail-s1" style="color:rgb(255,255,255)">];</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>pFrame<span class="gmail-s1" style="color:rgb(255,255,255)"> = </span>av_frame_alloc<span class="gmail-s1" style="color:rgb(255,255,255)">();</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span>[</span><span class="gmail-s2" style="color:rgb(178,24,137)">self</span><span class="gmail-s1" style="color:rgb(255,255,255)"> </span>cleanupPacket<span class="gmail-s1" style="color:rgb(255,255,255)">];</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>packet<span class="gmail-s1" style="color:rgb(255,255,255)"> = </span>av_packet_alloc<span class="gmail-s1" style="color:rgb(255,255,255)">();</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span>[<span class="gmail-s4" style="color:rgb(131,192,87)">lock</span> <span class="gmail-s5" style="color:rgb(0,160,190)">unlock</span>];</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s2" style="color:rgb(178,24,137)">return</span> frameFinished!=<span class="gmail-s3" style="color:rgb(120,109,196)">0</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)">}</p></div><div><br></div><div>I use object-c with ffmpeg library to decode, I hope that could be help.</div><div>Besides, I had used av_frame_free in [self cleanupFrame], and av_package_free in [self cleanupPackage]. but still happened the same memory problem, although it increased 0.1Mb for abount each 10~12sec.</div><div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,161,192);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)">-(</span><span class="gmail-s2" style="color:rgb(178,24,137)">void</span><span class="gmail-s1" style="color:rgb(255,255,255)">) </span>cleanupPacket</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)">{</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>av_packet_free<span class="gmail-s1" style="color:rgb(255,255,255)">(&</span>packet<span class="gmail-s1" style="color:rgb(255,255,255)">);</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s3" style="color:rgb(131,192,87)">packet</span> = <span class="gmail-s2" style="color:rgb(178,24,137)">nil</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)">}</p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40);min-height:16px"><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(65,161,192);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)">-(</span><span class="gmail-s2" style="color:rgb(178,24,137)">void</span><span class="gmail-s1" style="color:rgb(255,255,255)">) </span>cleanupFrame</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)">{</p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>av_frame_free<span class="gmail-s1" style="color:rgb(255,255,255)">(&</span>pFrame<span class="gmail-s1" style="color:rgb(255,255,255)">);</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(131,192,87);background-color:rgb(30,32,40)"><span class="gmail-s1" style="color:rgb(255,255,255)"><span class="gmail-Apple-converted-space"> </span></span>av_free<span class="gmail-s1" style="color:rgb(255,255,255)">(</span>pFrame<span class="gmail-s1" style="color:rgb(255,255,255)">);</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s3" style="color:rgb(131,192,87)">pFrame</span> = <span class="gmail-s2" style="color:rgb(178,24,137)">nil</span>;</p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(255,255,255);background-color:rgb(30,32,40)">}</p></div><div><br></div><div>Otherwise, I had thought if the problem caused by audio, but even I tried not to include audio package and release the package of audio. the problem is the same. It didn't work</div><div><br></div><div><br></div><div>The memory problem caused by the function "avcodec_receive_frame", I hope there is some one to solve it.</div><div><br></div><div><br></div></div>