NativeScript / tns-core-modules-widgets

Repo for widgets used in NativeScript modules
Apache License 2.0
12 stars 19 forks source link

Possible memory leak in widgets.Async.Http.MakeRequest #120

Open altunyurt opened 6 years ago

altunyurt commented 6 years ago

Make sure to check the existing issues in this repository

If there is no issue for your problem, tell us about it

I'm downloading small video files of 2-3mb in size, using http.getFile . After each download, i can see a significant increase in memory usage. In time, this results in OOM. I'm able to trace this problem back to widgets.Async.Http.MakeRequest, but lack of java skills stops me there.

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

I'm simply calling http.getFile.

== app/game_state.js ==
...
gmu("getVideoFile 1");
await $http.getFile(fileurl, filePath);
gmu("getVideoFile 2");
...

== tns-core-modules/http/http.js ==
function getFile(arg, destinationFilePath) {
    return new Promise(function (resolve, reject) {
        gmu("getfile 1")
        httpRequest.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg)
            .then(function (r) {
            try {
        gmu("getfile 2")

== tns-core-modules/http/http-request/http-request.android.js ==
function request(options) {
        ...
        gmu("request 8")
            org.nativescript.widgets.Async.Http.MakeRequest(javaOptions, completeCallback, new java.lang.Integer(requestIdCounter));
        gmu("request 9")
        ...
}

Memory usage logs are as follows. The significant jump happens upon widgets.Async.Http.MakeRequest resolves at "getfile 2"

'getVideoFile 1 - usedSize: 4773, freeSize: 2048, totalSize: 6821, maxHeapSize: 134217'
'getfile 1' '- usedSize:' 4776 'freeSize:' 2045 'totalSize:' 6821 'maxHeapSize:' 134217
'request 8' '- usedSize:' 4801 'freeSize:' 2020 'totalSize:' 6821 'maxHeapSize:' 134217
'request 9' '- usedSize:' 4804 'freeSize:' 2017 'totalSize:' 6821 'maxHeapSize:' 134217
'getfile 2' '- usedSize:' 11331 'freeSize:' 915 'totalSize:' 12246 'maxHeapSize:' 134217
'getVideoFile 2 - usedSize: 10409, freeSize: 1837, totalSize: 12246, maxHeapSize: 134217'

'getVideoFile 1 - usedSize: 10275, freeSize: 6019, totalSize: 16294, maxHeapSize: 134217'
'getfile 1' '- usedSize:' 10277 'freeSize:' 6017 'totalSize:' 16294 'maxHeapSize:' 134217
'request 8' '- usedSize:' 10305 'freeSize:' 5989 'totalSize:' 16294 'maxHeapSize:' 134217
'request 9' '- usedSize:' 10309 'freeSize:' 5985 'totalSize:' 16294 'maxHeapSize:' 134217
'getfile 2' '- usedSize:' 12443 'freeSize:' 3851 'totalSize:' 16294 'maxHeapSize:' 134217
'getVideoFile 2 - usedSize: 13335, freeSize: 2959, totalSize: 16294, maxHeapSize: 134217'

'getVideoFile 1 - usedSize: 15762, freeSize: 532, totalSize: 16294, maxHeapSize: 134217'
'getfile 1' '- usedSize:' 15769 'freeSize:' 525 'totalSize:' 16294 'maxHeapSize:' 134217
'request 8' '- usedSize:' 15803 'freeSize:' 491 'totalSize:' 16294 'maxHeapSize:' 134217
'request 9' '- usedSize:' 15846 'freeSize:' 448 'totalSize:' 16294 'maxHeapSize:' 134217
'getfile 2' '- usedSize:' 17530 'freeSize:' 5428 'totalSize:' 22958 'maxHeapSize:' 134217
'getVideoFile 2 - usedSize: 18199, freeSize: 4759, totalSize: 22958, maxHeapSize: 134217'

'getVideoFile 1 - usedSize: 40310, freeSize: 11389, totalSize: 51699, maxHeapSize: 134217'
'getfile 1' '- usedSize:' 40313 'freeSize:' 11386 'totalSize:' 51699 'maxHeapSize:' 134217
'request 8' '- usedSize:' 40343 'freeSize:' 11356 'totalSize:' 51699 'maxHeapSize:' 134217
'request 9' '- usedSize:' 40384 'freeSize:' 11315 'totalSize:' 51699 'maxHeapSize:' 134217
'getfile 2' '- usedSize:' 47767 'freeSize:' 3932 'totalSize:' 51699 'maxHeapSize:' 134217
'getVideoFile 2 - usedSize: 48840, freeSize: 2859, totalSize: 51699, maxHeapSize: 134217'
Serge-SDL commented 6 years ago

I have the same issue. Did you find a solution or a workaround?