本文整理汇总了TypeScript中tns-core-modules/utils/utils.GC函数的典型用法代码示例。如果您正苦于以下问题:TypeScript GC函数的具体用法?TypeScript GC怎么用?TypeScript GC使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GC函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: clearPage
export function buildUIWithWeakRefAndInteract<T extends View>(createFunc: () => T, interactWithViewFunc?: (view: T) => void, done?) {
clearPage();
const page = getCurrentPage();
const weakRef = new WeakRef(createFunc());
page.content = weakRef.get();
if (interactWithViewFunc) {
interactWithViewFunc(weakRef.get());
}
page.content = null;
// Give a change for native cleanup (e.g. keyboard close, etc.).
TKUnit.wait(0.001);
if (page.ios) {
/* tslint:disable:no-unused-expression */
// Could cause GC on the next call.
// NOTE: Don't replace this with forceGC();
new ArrayBuffer(4 * 1024 * 1024);
// An additional GC and wait are needed since WebKit upgrade to version 12.0
// (TEXT-FIELD.testMemoryLeak test started failing sporadically)
utils.GC();
TKUnit.wait(0.1);
}
utils.GC();
try {
TKUnit.assert(!weakRef.get(), weakRef.get() + " leaked!");
done(null);
}
catch (ex) {
done(ex);
}
}
示例2: forceGC
export function forceGC() {
if (isIOS) {
/* tslint:disable:no-unused-expression */
// Could cause GC on the next call.
new ArrayBuffer(4 * 1024 * 1024);
}
utils.GC();
TKUnit.wait(0.001);
}
示例3: clear
export function clear(args) {
repeaterIds
.map(name => args.object.page.getViewById(name))
.forEach(repeater => {
repeater.bindingContext = null;
});
args.object.page.getViewById("title").text = "---";
utils.GC();
}