我一直在阅读文档和各种示例,我的所有代码似乎都应该是这样。
然而,我遇到了一个我似乎无法插入的内存泄漏。这就是我所知道的:
.done
或.then
附加到WinJS.Promise时会发生这种情况。Windows.Foundation.IAsyncOperation<T>
,AsyncOpPromise
(第一次调用异步方法时动态创建?)和最重要的,结果为操作(T)可以是一个非常大的对象。例如:
//This one leaks
document.getImageSourceAsync().done(function(source) {
//The intention is to do something with the image, but it doesn't really matter what does or does not happen here.
});
//This one doesn't leak
document.getImageSourceAsync();
我在这里创建了一个示例项目:http://sdrv.ms/12TvPOa
提前感谢您的帮助。 亚当