[pjsip] Problem with new version of media clock (clock_thread.c) PJSIP 2.0
derfler.michael at gmail.com
Sat May 26 10:35:17 EDT 2012
I think I have found a problem with the new version of the media clock
(used by the master port)
* in pjmedia_clock_create2( ... ) a memory pool
is passed as an argument.
* from this pool's factory an other pool is created
(let's call it new_pool for now)
* from new_pool the memory for the pjmedia_clock "instance"
is "allocated" and a pointer to new_pool is stored to the instance.
so far everything looks good.
in pjmedia_clock_start the clock thread is created from
new_pool (and started)
Part3: this is the point where the error occures
in pjmedia_clock_stop the quitting flag is set to true
and the thread is joined.
* after joining pj_thread_destroy should be called to destroy the
* the memory allocated from new_pool is lost now because if you restart
clock (by calling pjmedia_clock_start) again new memory is
new_pool --> new_pool is growing on each restart.
If the MasterPort is enabled and disabled very often (don't know if this
happens that often) this behaviour can lead to
high memory consumption)
1)in pjmedia_clock_create2 use the pool passed as an argument
to allocate memory for the pjmedia_clock instance
but also create new_pool and store the pointer (new_pool) to the
2) in pjmedia_clock_start create the thread from new_pool
3) in pjmedia_clock_stop:
join the thread (like it is done now)
but after that call pj_thread_destroy
==> so the thread's mutex is destroyed + new_pool's memory usage is
not growing (when restarting) !!!
I hope this was understandable.
If you have any questions,
I will try to answer them.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pjsip