[402] | 1 | //////////////////////////////////////////////////////////// |
---|
| 2 | // Copyright (C) Roman Ryltsov, 2015 |
---|
| 3 | // Created by Roman Ryltsov roman@alax.info |
---|
| 4 | // |
---|
| 5 | // A permission to use the source code is granted as long as reference to |
---|
| 6 | // source website http://alax.info is retained. |
---|
| 7 | |
---|
| 8 | #include "stdafx.h" |
---|
| 9 | #include <psapi.h> |
---|
| 10 | |
---|
| 11 | #pragma warning(disable: 4192) // warning C4192: automatically excluding 'tagRECT' while importing type library 'D864517A-EDD5-466D-867D-C819F1C052BB' |
---|
| 12 | #import "libid:D864517A-EDD5-466D-867D-C819F1C052BB" raw_interfaces_only named_guids // DeckLinkAPI |
---|
| 13 | #pragma warning(default: 4192) |
---|
| 14 | |
---|
| 15 | using namespace DeckLinkAPI; |
---|
| 16 | |
---|
| 17 | VOID PrintMemory() |
---|
| 18 | { |
---|
| 19 | PROCESS_MEMORY_COUNTERS_EX Counters = { sizeof Counters }; |
---|
| 20 | ATLVERIFY(GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*) &Counters, sizeof Counters)); |
---|
| 21 | _tprintf(_T("Private Bytes %d MB\n"), Counters.PrivateUsage >> 20); |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | int _tmain(int argc, _TCHAR* argv[]) |
---|
| 25 | { |
---|
| 26 | ATLVERIFY(SUCCEEDED(CoInitialize(NULL))); |
---|
| 27 | _ATLTRY |
---|
| 28 | { |
---|
| 29 | CComPtr<IDeckLinkIterator> pDeckLinkIterator; |
---|
| 30 | const HRESULT nCoCreateInstanceResult = pDeckLinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator); |
---|
| 31 | CComPtr<IDeckLink> pDeckLink; |
---|
| 32 | for(; pDeckLinkIterator->Next(&pDeckLink) == S_OK; ) |
---|
| 33 | break; |
---|
| 34 | ATLENSURE_THROW(pDeckLink, E_NOINTERFACE); |
---|
| 35 | for(; ; ) |
---|
| 36 | { |
---|
| 37 | PrintMemory(); |
---|
| 38 | const CComQIPtr<IDeckLinkInput> pDeckLinkInput = pDeckLink; |
---|
| 39 | ATLENSURE_THROW(pDeckLinkInput, E_NOINTERFACE); |
---|
| 40 | // NOTE: EnableVideoInput allocates memory which is never freed |
---|
| 41 | // The problem does not happen if/when pDeckLinkInput is reused between loops |
---|
| 42 | ATLENSURE_SUCCEEDED(pDeckLinkInput->EnableVideoInput(bmdModeNTSC, bmdFormat8BitYUV, bmdVideoInputFlagDefault)); |
---|
| 43 | ATLENSURE_SUCCEEDED(pDeckLinkInput->DisableVideoInput()); |
---|
| 44 | } |
---|
| 45 | /* |
---|
| 46 | Private Bytes 1 MB |
---|
| 47 | Private Bytes 29 MB |
---|
| 48 | Private Bytes 57 MB |
---|
| 49 | Private Bytes 84 MB |
---|
| 50 | Private Bytes 112 MB |
---|
| 51 | Private Bytes 139 MB |
---|
| 52 | Private Bytes 167 MB |
---|
| 53 | Private Bytes 195 MB |
---|
| 54 | Private Bytes 222 MB |
---|
| 55 | Private Bytes 250 MB |
---|
| 56 | Private Bytes 277 MB |
---|
| 57 | Private Bytes 305 MB |
---|
| 58 | Private Bytes 333 MB |
---|
| 59 | Private Bytes 360 MB |
---|
| 60 | Private Bytes 388 MB |
---|
| 61 | Private Bytes 415 MB |
---|
| 62 | Private Bytes 443 MB |
---|
| 63 | Private Bytes 471 MB |
---|
| 64 | Private Bytes 498 MB |
---|
| 65 | Private Bytes 526 MB |
---|
| 66 | ... |
---|
| 67 | */ |
---|
| 68 | } |
---|
| 69 | _ATLCATCH(Exception) |
---|
| 70 | { |
---|
| 71 | _tprintf(_T("Fatal Error 0x%08X\n"), (HRESULT) Exception); |
---|
| 72 | } |
---|
| 73 | _ATLCATCHALL() |
---|
| 74 | { |
---|
| 75 | _tprintf(_T("Fatal Error\n")); |
---|
| 76 | } |
---|
| 77 | CoUninitialize(); |
---|
| 78 | return 0; |
---|
| 79 | } |
---|
| 80 | |
---|