最小示例[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)