On 10/8/20 18:55, gga wrote:
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.

Oh, yes.  I should mention that the memory fragmentation happens after I run the allocation of a sequence of frames multiple times and with some frames being swapped out of memory at the same time, and with all frames being of the same size.

--
Gonzalo Garramuño

_______________________________________________
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to