Opened 6 years ago

Closed 6 years ago

#5740 closed defect (needs_more_info)

Memory leak on Windows, when unloading FFmpeg dlls

Reported by: seveneleven Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: leak
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I built a dll (VC++, Win32), that uses FFmpeg for video processing and is used by several applications.

Each time this dll is loaded/freed (using Windows API: LoadLibrary/FreeLibrary), it leaks around 20KB (given that, in this way, FFmpeg dlls are also loaded/unloaded):

'Demo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avcodec-57.dll'. Module was built without symbols.
'Demo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avutil-55.dll'. Module was built without symbols.
'Demo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\swresample-2.dll'. Module was built without symbols.
'Demo.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\avcodec-57.dll'
'Demo.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\swresample-2.dll'
'Demo.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\avutil-55.dll'

On a Windows 7 Machine, I observed leaks of ~20KB each "load/unload". On Windows 10 it ranges from 4KB to 20KB (16KB at the most).

Except for the latest build, this issue can be reproduced with 3.0.1, 3.0, 2.8.6, 2.8.3.
In 0.8.7 it worked fine.

This is all the 'dll code' to reproduce it.

extern "C" 
{
    #include <libavcodec\avcodec.h>
    #pragma comment(lib, "avcodec.lib")
}

void __stdcall proveIssue()
{
    int v = avcodec_version();
}

Removing the line with avcodec_version would fix it, because no FFmpeg dlls would be linked.

Change History (4)

comment:1 by Carl Eugen Hoyos, 6 years ago

Keywords: leak added
Resolution: needs_more_info
Status: newclosed

A leak report would need valgrind output (or an equivalent report like DrMemory) but I think this is a duplicate of several tickets including #3194.

comment:2 by seveneleven, 6 years ago

Resolution: needs_more_info
Status: closedreopened

I don't think this is a duplicate (at least not of #3194): This leak occurs by only loading and unloading FFmpeg dlls during runtime. There is nothing else to do, like calling avcodec_*() functions for example.

Demo.exe loads Demo.dll (LoadLibrary("Demo.dll")), thus loading avcodec-57.dll etc.
When Demo.dll gets freed (FreeLibrary()) immediately thereafter, it will cause the leak.

comment:3 by Carl Eugen Hoyos, 6 years ago

Then please provide the output of a memory debugger as required for every leak report.

comment:4 by Carl Eugen Hoyos, 6 years ago

Resolution: needs_more_info
Status: reopenedclosed

Please reopen this ticket if you can provide the necessary information.

Note: See TracTickets for help on using tickets.