GetThumbnailsAsync的内存问题

时间:2018-07-11 23:53:31

标签: uwp c++-winrt

最小示例[C ++ / WinRT]:

#include "winrt/Windows.Storage.Streams.h"
#include "winrt/Windows.Media.Editing.h"

using namespace std::literals;
using namespace winrt;
using namespace Windows::Media::Editing;
using namespace Windows::Storage;

int main()
{
    init_apartment();
    StorageFile file = StorageFile::GetFileFromPathAsync(L"video.mp4").get();
    MediaClip clip = MediaClip::CreateFromFileAsync(file).get();
    MediaComposition composition = MediaComposition();
    composition.Clips().Append(clip);

    while (true)
    {
        auto stream = composition.GetThumbnailAsync(0s, 10, 10, VideoFramePrecision::NearestFrame).get();
        printf("%lld\n", stream.Size());
    }
}

问题:运行此代码时,内存使用量迅速增加,最终程序失败。理想情况下,我假设如果获得操作的结果,该操作将停止消耗内存,但是在这种情况下,GetThumbnailAsync会继续使用内存。关闭操作或关闭操作结果无济于事。我如何让GetThumbnailAsync操作在完成后释放所有分配的内存?

平台:Microsoft Windows 10 Insider预览版(内部版本17682)

0 个答案:

没有答案