[FFmpeg-devel] [PATCH] print memory usage with -benchmark
Ramiro Polla
ramiro.polla
Sun Feb 21 00:56:04 CET 2010
On Sat, Feb 20, 2010 at 9:45 PM, Reimar D?ffinger
<Reimar.Doeffinger at gmx.de> wrote:
> On Sun, Feb 21, 2010 at 12:13:21AM +0100, Reimar D?ffinger wrote:
>> I fear it is untested, the Windows part because I don't have Windows at hand,
>> and the Linux/BSD/... part because it seems my kernel is too old, it always
>> returns 0.
>> I hope someone else can confirm its usefulness...
>
> And already the first fix.
> I think it needs a 2.6.32 or later kernel for Linux.
> Index: configure
> ===================================================================
> --- configure (revision 21924)
> +++ configure (working copy)
> @@ -1026,8 +1026,10 @@
> fork
> getaddrinfo
> gethrtime
> + GetProcessMemoryInfo
> GetProcessTimes
> getrusage
> + struct_rusage_ru_maxrss
> inet_aton
> inline_asm
> isatty
> @@ -2491,6 +2493,7 @@
> check_func getaddrinfo $network_extralibs
> check_func gethrtime
> check_func getrusage
> +check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> check_func inet_aton $network_extralibs
> check_func isatty
> check_func ${malloc_prefix}memalign && enable memalign
> @@ -2499,6 +2502,7 @@
> check_func setrlimit
> check_func_headers io.h setmode
> check_func_headers lzo/lzo1x.h lzo1x_999_compress
> +check_func_headers windows.h GetProcessMemoryInfo
It needs to include windows.h first, then psapi.h, and must link to -lpsapi.
So it's either
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
or (untested but just a duplicate of check_lib2)
check_func_headers "windows.h psapi.h" GetProcessMemoryInfo -lpsapi &&
add_extralibs -lpsapi
> check_func_headers windows.h GetProcessTimes
> check_func_headers windows.h VirtualAlloc
>
> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c (revision 21924)
> +++ ffmpeg.c (working copy)
Needs
#if HAVE_GETPROCESSMEMORYINFO
#include <psapi.h>
#endif
before the function.
> @@ -3535,6 +3535,23 @@
> #endif
> }
>
> +static int64_t getmaxrss(void)
> +{
> +#if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
> + struct rusage rusage;
> + getrusage(RUSAGE_SELF, &rusage);
> + return rusage.ru_maxrss * 1024;
> +#elif HAVE_GETPROCESSMEMORYINFO
> + HANDLE proc;
> + PROCESS_MEMORY_COUNTERS memcounters;
> + proc = GetCurrentProcess();
> + GetProcessMemoryInfo(proc, &memcounters);
GetProcessMemoryInfo(proc, &memcounters, sizeof(memcounters));
> + return memcounters.PeakPagefileUsage;
> +#else
> + return 0;
> +#endif
> +}
> +
With these changes it seems to work fine on Windows.
More information about the ffmpeg-devel
mailing list