[Libav-user] av_malloc_array fragmentation on Linux
gga
ggarra13 at gmail.com
Tue Aug 11 00:55:45 EEST 2020
I modified my code to rely on ffmpeg's av_malloc's functions and I am
now seeing what appears to be memory fragmentation on the Linux platform.
My code is C++ using operator new[], like the following:
struct aligned16_uint8_t
{
uint8_t x;
inline void* operator new(size_t size)
{
void* ptr = av_malloc( size );
if (!ptr) throw std::bad_alloc();
return ptr;
}
inline void operator delete( void* ptr )
{
av_free( ptr );
}
inline void* operator new[](size_t size)
{
void* ptr = av_malloc_array( size, sizeof(aligned16_uint8_t) );
if (!ptr) throw std::bad_alloc();
return ptr;
}
inline void operator delete[]( void* ptr )
{
av_free( ptr );
}
};
The above works fine on Windows and Mac, but on Linux it seems like it
leaks memory / fragments it. Looking at the av_malloc implementation
for Linux, I saw it relies on posix_memalign, but nothing else seems
differently.
--
Gonzalo Garramuño
More information about the Libav-user
mailing list