Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-7642

iOS: Memory Leak when local html file is used in a WebView

    Details

    • Story Points:
      2

      Description

      Memory is not being released when a webview, with a local HTML file, is added to a window and then removed from it. But this does not happen when a remote URL is used. Below is the sample code and the local HTML file has been attached.

      Sample Code

      var win = Ti.UI.createWindow({
          backgroundColor : 'white'
      });
       
      var webview = null;
       
      var btnAdd = Ti.UI.createButton({
          title : 'Add',
          top : 0,
          left : 0,
          height : 50,
          width : 100
      });
       
      btnAdd.addEventListener('click', function() {
          webview = Ti.UI.createWebView({
              url : 'local_webview.html',
              // url : 'http://www.google.com',
              height : 200,
              bottom : 10
          });
          
          win.add(webview);
      });
       
      var btnRemove = Ti.UI.createButton({
          title : 'Remove',
          top : 0,
          right : 0,
          height : 50,
          width : 100
      });
       
      btnRemove.addEventListener('click', function() {
          win.remove(webview);
          webview = null;
      });
      win.add(btnAdd);
      win.add(btnRemove);
      win.open();
      

      STEPS TO REPRODUCE

      • Drop the above sample code into app.js and copy the attached 'local_webview.html' to Resources folder.
      • Start the application and open Instruments to profile it.
      • Click the 'Add' button and then the 'Remove' button.
      • Search for 'proxy' in instruments and it can be seen that webview proxies are not released even if memory warnings are simulated.

      EXPECTED BEHAVIOR
      Proxies related to webview should be released.

      OBSERVED BEHAVIOR
      Memory is not being freed.

      OTHER OBSERVATIONS
      Memory is being freed when a remote URL (uncomment the line with google.com and comment out the line with local_webview.html) is used.

        Attachments

          Activity

            People

            • Assignee:
              mstepanov Max Stepanov
              Reporter:
              sbhimavarapu Sandeep Bhimavarapu
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Git Source Code