[mythtv] Mythtv pes_malloc and pes_free
Roger James
roger at beardandsandals.co.uk
Sun May 7 10:53:38 UTC 2017
The libmythtv implementation of mpeg2 uses its own simple heap management
overlayed on top of the standard heap allocator (malloc/free). This is
implemented by two functions in pespacket.cpp, pes_alloc and pes_free. The
reason for doing this is given in the code as "avoiding the global malloc
lock". The global malloc lock has not existed in glibc malloc for a number
of years now. Glibc malloc is based on pthreads malloc a.k.a. ptmalloc2.
This is a multithreading friendly allocator using a sophisticated multi
arena allocation algorithm.
The simple algorithm in pes_alloc does not play well in a mixed short/long
term allocation environment causing large amounts of virtual memory space
to used unnecessarily.
I would like to propose that we consider reverting to the default heap
allocator. There are also a number of alternatives to the ptmalloc
allocator that could be consider, for example tcmalloc from Google.
The topic is open to debate!
Roger
More information about the mythtv-dev
mailing list