On Wed, Mar 13, 2013 at 2:28 PM, Evalds Urtans <evalds.urta...@gmail.com> wrote:
> Hello,
>
> can anybody suggest a solution to avoid memory leak on linux using following
> code ?
>
> while(bRunning) {
>
> m_mltRepo = mlt_factory_init( NULL );
> m_mltProfile = mlt_profile_init( m_strProfile.c_str() );
> m_mltProducer = mlt_factory_producer( m_mltProfile, m_strProducer.c_str(),
> pClipCurrent->path().c_str());
>
> m_mltConsumer = mlt_factory_consumer(m_mltProfile, m_strConsumer.c_str(),
> chArg);
> mlt_properties mltPropertiesConsumer =
> MLT_SERVICE_PROPERTIES(MLT_CONSUMER_SERVICE(m_mltConsumer));
>
> mlt_properties_set_int( mltPropertiesConsumer, "buffer", m_iBufferSize );
> mlt_properties_set_int( mltPropertiesConsumer, "prefill", m_iPrefillSize);
> mlt_properties_set_int( mltPropertiesConsumer, "terminate_on_pause", 1 );
>
> mlt_consumer_connect( m_mltConsumer, MLT_PRODUCER_SERVICE( m_mltProducer )
> );
> mlt_consumer_start(m_mltConsumer);
>
> //wait while playing
> Sleep(....)
>
> mlt_consumer_stop( m_mltConsumer );
> mlt_consumer_close( m_mltConsumer );
> mlt_producer_close( m_mltProducer );
> mlt_profile_close(m_mltProfile);
> mlt_factory_close();
>
> }
>
> Without terminate_on_pause I cannot detect end of current clip if I have for
> example 20sec buffer, because
> mlt_producer_get_playtime(m_mltProducer); stops after buffer is filled, but
> it has not been shown fully.. Maybe there is better solution to this?

There is terminate_on_pause=1 on consumer or you can get a length in
frames and check the mlt_consumer_position() or
mlt_frame_get_position() within a consumer-frame-show event handler.

> But the main problem is that after mlt_factory_close does not clear out
> memory on linux. If I use mlt_pool_purge() it cleans out memory, but virtual
> memory still grows fast. The problem can be detected if you run 5-10 large
> video clips one by one. Does anyone has ideas about what is wrong with this
> code?

Your code is not a good strategy/solution to play a series or sequence
of clips. It is only expected that you call mlt_factory_init() once
per process, and you do not need to create-start-stop-close the
consumer for each clip.

> If I do not close consumer it makes decklink consumer to lag & twich after
> some while, but if I reset it every time then it is working fine, except
> memory leak of mlt.

You are supposed to close the consumer when you are done with it.

-- 
+-DRD-+

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to