1

IE 9 でのリークを示すサンプル コードが含まれています (数分で 1 Gb)。V3.8 を V3.7 に変更すると、このメモリ リークは発生しません!!! 私の推測では、v3.8 で導入されました。コードは Chrome/Firefox で動作するようですが、私は C# Winform アプリで作業しており、IE の COM ラッパーである組み込みの .NET Web コントロールを使用しています。すでに gecko .NET コンポーネントを試しましたが、それは私にとって代替手段ではありません。

私はここで立ち往生していて必死なので、誰かが親切に解決策を提供してくれたら...

サンクス・ロブ

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <title>Memoryleak in IE</title>

      <style type="text/css">
            html
            {
            }
            body
            {
                margin: 0px;
                padding: 0px;
            }

        </style>
        <style type="text/css">
            .context
            {
                font-family: Arial, sans-serif;
                text-decoration: none;
                color: #4444ff;
                font-size: small;
            }
            a:hover div
            {
                background: #00eeee;
            }
        </style>

      <script src="https://maps.googleapis.com/maps/api/js?sensor=false&amp;v=3.8" type="text/javascript"></script>
      <script type="text/javascript">

         var coords = [
    -115.821139332819,51.2247937004413,
    -115.821139332819,51.2247937004413,
    -115.820783024602,51.2247102926052,
    -115.820783024602,51.2247102926052,
    -115.820327685708,51.2246117850904,
    -115.820327685708,51.2246117850904,
    -115.819759388578,51.2244962798047,
    -115.819759388578,51.2244962798047,
    -115.819290270032,51.2244074438906,
    -115.819290270032,51.2244074438906,
    -115.818926957722,51.2243299769159,
    -115.818926957722,51.2243299769159,
    -115.818338387318,51.2242059504634,
    -115.818338387318,51.2242059504634,
    -115.817977304212,51.2241249042188,
    -115.817977304212,51.2241249042188,
    -115.817599143301,51.224042310143,
    -115.817599143301,51.224042310143,
    -115.817134937747,51.2239589216431,
    -115.817134937747,51.2239589216431,
    -115.816536085049,51.2238583513406,
    -115.816536085049,51.2238583513406,
    -115.816082549208,51.2237586568853,
    -115.816082549208,51.2237586568853,
    -115.815700862212,51.2236505400057,
    -115.815700862212,51.2236505400057,
    -115.815357631111,51.223555251529,
    -115.815357631111,51.223555251529,
    -115.814809515585,51.2234021852219,
    -115.814809515585,51.2234021852219,
    -115.814355814815,51.2232968327074,
    -115.814355814815,51.2232968327074,
    -115.813999142875,51.2231965005283,
    -115.813999142875,51.2231965005283,
    -115.813647699181,51.2230910623849,
    -115.813647699181,51.2230910623849,
    -115.813026822773,51.2229353329219,
    -115.813026822773,51.2229353329219,
    -115.812582641159,51.2228335929039,
    -115.812582641159,51.2228335929039,
    -115.812013680777,51.2226994808324,
    -115.812013680777,51.2226994808324,
    -115.811661976828,51.2225955792611,
    -115.811661976828,51.2225955792611,
    -115.811254131518,51.2224819086399,
    -115.811254131518,51.2224819086399,
    -115.810894380211,51.2223965803553,
    -115.810894380211,51.2223965803553,
    -115.810314308135,51.2222515485398,
    -115.810314308135,51.2222515485398,
    -115.809965253975,51.2221524009482];


        var myPano = null;
        var mySVC  = null;
        var sv     = new google.maps.StreetViewService();
        var teller = 0;
        var tmr    = null;

        function startStreetviewMode(lat, lon)
        {
            try
            {
                var svPanoramaOptions = {
                    visible:          true,
                    disableDoubleClickZoom: true,
                    linksControl:     true,
                    addressControl:   true,
                    panControl:       true,
                    zoomControl:      false,
                    imageDateControl: false,
                    position:         new google.maps.LatLng(lat, lon),
                    pov: {
                         heading: 180,
                         pitch:   0,
                         zoom:    1
                         }
                    };

                myPano = new google.maps.StreetViewPanorama(document.getElementById("pano"), svPanoramaOptions);
                myPano.setVisible(true);

                svPanoramaOptions = null;
            }
            catch (err)
            {
                alert("startStreetviewMode, " + err.source + ':' + err.message);
            }
       }

       function SVPanoInitialized(SVLocation)
       {
       }

       function handleSVError(errorCode)
       {
       }


       function showStreet(lat, lng)
       {
           try
           {
               sv.getPanoramaByLocation(new google.maps.LatLng(lat, lng), 50, function (data, status)
               {
                   if (status == google.maps.StreetViewStatus.OK)
                   {
                       myPano.setPov({
                           heading: 180,
                           pitch:   10,
                           zoom:    1
                       });
                       myPano.setPano(data.location.pano);
                       myPano.setVisible(true);
                       data   = null;
                       status = null;
                   }
                   else
                   {
                       handleSVError(status);
                   }
               });
            }
            catch (err)
            {
                alert("showStreet, " + err.source + ':' + err.message);
            }
        }

        function showit()
        {
            // Keep looping through array
            teller = teller + 2;
            if (teller > 80) teller = 0;

            // Show streetview to demonstrate leak
            showStreet(coords[teller + 1], coords[teller]);
        }

        function init()
        {
            startStreetviewMode(coords[teller + 1], coords[teller]);
          window.setInterval(this.showit, 750);
     }
    </script>
    </head>
    <body onload="init()">
        <div id="pano" style="width: 1024px; height: 768px" />
    </body>
    </html>
4

1 に答える 1

0

スコープ外 (およびグローバル スコープ) の変数は、メモリ リークを引き起こすことが知られています。すべての変数が関数ローカルに正しくスコープされていることを確認することをお勧めします。

于 2012-05-18T09:09:21.903 に答える