2012-05-18 24 views
1

我有工作示例代码,包括显示IE 9泄漏(几Gb在几分钟内)。当您将V3.8更改为V3.7时,此内存泄漏不会发生!所以我的猜测是它在v3.8中推出! 该代码似乎在Chrome/Firefox中工作,但我正在研究C#Winform应用程序 并使用嵌入式.NET webcontrol(一种围绕IE的COM包装器)。 已经尝试过gecko .NET组件,但那对我来说是不可替代的。谷歌地图Javascript V3.8中引入的内存泄露(在IE 9中观察)

我在这里和绝望的坚持,所以如果有人会这么好心提供一个解决方案...

日Thnx 罗布

<!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> 

回答

0

无作用域(和全局范围)变量知道引起内存泄漏。 我建议你确保所有变量的范围都是正确的。

+0

Thnx为您的答案。我做了更多的研究,并得出结论它与V3.8相关! –