Skip to content
This repository has been archived by the owner on Mar 21, 2019. It is now read-only.

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

Open
altunyurt opened this issue Apr 29, 2018 · 1 comment
Open

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

altunyurt opened this issue Apr 29, 2018 · 1 comment

Comments

@altunyurt
Copy link

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?

  • iOS/Android/Both
    Android
  • iOS/Android versions
    7.1.1
  • emulator or device. What type of device?
    Device: General Mobile 4G Android One

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

  • CLI: 4.0.0
  • Cross-platform modules: 4.0.0
  • Runtime(s): tns-android 4.0.1
  • Plugin(s):
    "dependencies": {
    "nativescript": "^4.0.0",
    "nativescript-exoplayer": "^3.4.1",
    "nativescript-facebook": "^2.2.2",
    "nativescript-oauth": "^2.1.2",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-vue": "^1.3.2-rc.4",
    "tns-core-modules": "^4.0.0",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
    },
    "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.4",
    "babel-plugin-transform-async-to-generator": "^6.24.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "copy-webpack-plugin": "^4.5.1",
    "css-loader": "^0.28.11",
    "extract-text-webpack-plugin": "^3.0.2",
    "fs-extra": "^5.0.0",
    "lazy": "1.0.11",
    "nativescript-vue-externals": "^0.1.2",
    "nativescript-vue-loader": "^0.1.5",
    "nativescript-vue-target": "^0.1.0",
    "nativescript-vue-template-compiler": "^1.3.2-rc.4",
    "node-sass": "^4.7.2",
    "ns-vue-loader": "^0.1.2",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "rimraf": "^2.6.2",
    "sass-loader": "^6.0.7",
    "vue-template-compiler": "^2.5.16",
    "webpack": "^3.11.0",
    "webpack-synchronizable-shell-plugin": "0.0.7",
    "winston-color": "^1.0.0"
    },
    "nativescript": {
    "id": "com.sample.app",
    "tns-android": {
    "version": "4.0.1"
    }
    },
    "android": {
    "v8Flags": "--expose_gc --track_gc_object_stats"
    }

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants