mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
Trying to prevent memory leaks.
This commit is contained in:
@ -24,6 +24,14 @@ function waitUntilNavigatedFrom(oldPage: Page) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function androidGC() {
|
||||||
|
let topmost = topmostFrame();
|
||||||
|
if (topmost.android) {
|
||||||
|
gc();
|
||||||
|
java.lang.System.gc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function _test_backstackVisible(transition?: NavigationTransition) {
|
function _test_backstackVisible(transition?: NavigationTransition) {
|
||||||
let topmost = topmostFrame();
|
let topmost = topmostFrame();
|
||||||
let mainTestPage = topmost.currentPage;
|
let mainTestPage = topmost.currentPage;
|
||||||
@ -52,10 +60,12 @@ function _test_backstackVisible(transition?: NavigationTransition) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export var test_backstackVisible = function () {
|
export var test_backstackVisible = function () {
|
||||||
|
androidGC();
|
||||||
_test_backstackVisible();
|
_test_backstackVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_backstackVisible_WithTransition = function () {
|
export var test_backstackVisible_WithTransition = function () {
|
||||||
|
androidGC();
|
||||||
_test_backstackVisible({name: "fade"});
|
_test_backstackVisible({name: "fade"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,10 +117,12 @@ function _test_backToEntry(transition?: NavigationTransition) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export var test_backToEntry = function () {
|
export var test_backToEntry = function () {
|
||||||
|
androidGC();
|
||||||
_test_backToEntry();
|
_test_backToEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_backToEntry_WithTransition = function () {
|
export var test_backToEntry_WithTransition = function () {
|
||||||
|
androidGC();
|
||||||
_test_backToEntry({name: "flip"});
|
_test_backToEntry({name: "flip"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,14 +171,17 @@ function _test_ClearHistory(transition?: NavigationTransition) {
|
|||||||
|
|
||||||
// Clearing the history messes up the tests app.
|
// Clearing the history messes up the tests app.
|
||||||
export var test_ClearHistory = function () {
|
export var test_ClearHistory = function () {
|
||||||
|
androidGC();
|
||||||
_test_ClearHistory();
|
_test_ClearHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_ClearHistory_WithTransition = function () {
|
export var test_ClearHistory_WithTransition = function () {
|
||||||
|
androidGC();
|
||||||
_test_ClearHistory({ name: "fade" });
|
_test_ClearHistory({ name: "fade" });
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_ClearHistory_WithTransition_WithCachePagesOnNavigate = function () {
|
export var test_ClearHistory_WithTransition_WithCachePagesOnNavigate = function () {
|
||||||
|
androidGC();
|
||||||
let topmost = topmostFrame();
|
let topmost = topmostFrame();
|
||||||
if (!topmost.android) {
|
if (!topmost.android) {
|
||||||
return;
|
return;
|
||||||
@ -180,6 +195,7 @@ export var test_ClearHistory_WithTransition_WithCachePagesOnNavigate = function
|
|||||||
|
|
||||||
// Test case for https://github.com/NativeScript/NativeScript/issues/1948
|
// Test case for https://github.com/NativeScript/NativeScript/issues/1948
|
||||||
export var test_ClearHistoryWithTransitionDoesNotBreakNavigation = function () {
|
export var test_ClearHistoryWithTransitionDoesNotBreakNavigation = function () {
|
||||||
|
androidGC();
|
||||||
let topmost = topmostFrame();
|
let topmost = topmostFrame();
|
||||||
let mainTestPage = topmost.currentPage;
|
let mainTestPage = topmost.currentPage;
|
||||||
let mainPageFactory = function (): Page {
|
let mainPageFactory = function (): Page {
|
||||||
@ -215,6 +231,7 @@ export var test_ClearHistoryWithTransitionDoesNotBreakNavigation = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export var test_ClearHistoryWithTransitionDoesNotBreakNavigation_WithLocalTransition = function () {
|
export var test_ClearHistoryWithTransitionDoesNotBreakNavigation_WithLocalTransition = function () {
|
||||||
|
androidGC();
|
||||||
let topmost = topmostFrame();
|
let topmost = topmostFrame();
|
||||||
let originalCachePagesOnNavigate: boolean;
|
let originalCachePagesOnNavigate: boolean;
|
||||||
if (topmost.android) {
|
if (topmost.android) {
|
||||||
@ -314,9 +331,11 @@ function _test_NavigationEvents(transition?: NavigationTransition) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export var test_NavigationEvents = function () {
|
export var test_NavigationEvents = function () {
|
||||||
|
androidGC();
|
||||||
_test_NavigationEvents();
|
_test_NavigationEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_NavigationEvents_WithTransition = function () {
|
export var test_NavigationEvents_WithTransition = function () {
|
||||||
|
androidGC();
|
||||||
_test_NavigationEvents({ name: "fade" });
|
_test_NavigationEvents({ name: "fade" });
|
||||||
}
|
}
|
@ -696,7 +696,13 @@ class FragmentClass extends android.app.Fragment {
|
|||||||
trace.write(`${this}.onDestroy()`, trace.categories.NativeLifecycle);
|
trace.write(`${this}.onDestroy()`, trace.categories.NativeLifecycle);
|
||||||
}
|
}
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
this.entry.fragmentTag = undefined;
|
this.entry.fragmentTag = undefined;
|
||||||
|
this.entry = undefined;
|
||||||
|
this.frame = undefined;
|
||||||
|
this.clearHistory = undefined;
|
||||||
|
transitionModule._clearBackwardTransitions(this);
|
||||||
|
transitionModule._clearForwardTransitions(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public toString(): string {
|
public toString(): string {
|
||||||
|
Reference in New Issue
Block a user