Skip to content

Commit dd2a811

Browse files
author
Mihail Slavchev
committed
merge release branch
2 parents 1770aa5 + 113f130 commit dd2a811

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

build-artifacts/project-template-gradle/src/main/java/com/tns/RuntimeHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ public static Runtime initRuntime(Application app)
149149

150150
try {
151151
// put this call in a try/catch block because with the latest changes in the modules it is not granted that NativeScriptApplication is extended through JavaScript.
152-
Runtime.initInstance(app);
152+
JavaScriptImplementation jsImpl = app.getClass().getAnnotation(JavaScriptImplementation.class);
153+
if (jsImpl != null) {
154+
Runtime.initInstance(app);
155+
}
153156
}
154157
catch (Exception e) {
155158
if (logger.isEnabled()) {

test-app/app/src/main/assets/app/tests/tests.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,27 @@ describe("Tests ", function () {
622622
expect(file).toBe(file2);
623623
});
624624

625+
it("TestWorkingWithJavaArrayDoesNotMakeMemoryLeak", function () {
626+
__log("TEST: TestWorkingWithJavaArrayDoesNotMakeMemoryLeak");
627+
628+
var size = 10 * 1024 * 1024;
629+
630+
for (var i = 0; i < 100; i++) {
631+
632+
var arr = java.lang.reflect.Array.newInstance(java.lang.Byte.class.getField("TYPE").get(null), size);
633+
634+
var length = arr.length;
635+
636+
expect(length).toEqual(size);
637+
638+
arr[0] = 123;
639+
640+
var el = arr[0];
641+
642+
expect(el).toEqual(123);
643+
}
644+
});
645+
625646
it("TestConstructorOverride", function () {
626647

627648

0 commit comments

Comments
 (0)