1
我以前從未使用過actionscript,但爲了使地圖正常工作,我只好深入其中。Actionscript + Google Maps API內存泄漏
我用下面的代碼添加地圖標記,更換如果存在前一個:
public var tracer:Array = new Array();
public var tracerLng:Number = 0;
for (var i : Number=1 ; i<64000 ; i++)
{
//Check if there is already a marker, if so get rid of it
if(tracerLng > 0) {
map.removeOverlay(tracer[0]);
tracer[0] = null;
tracer.pop();
}
// Set up a marker
var trackMrk:Marker = new Marker(
new LatLng(_lat, _lng),
new MarkerOptions({
strokeStyle: new StrokeStyle({color: 0x987654}),
fillStyle: new FillStyle({color: 0x223344, alpha: 0.8}),
radius: 12,
hasShadow: true
})
);
//Add the marker to the array and show it on the map
tracerLng = tracer.push(trackMrk);
map.addOverlay(tracer[0]);
}
我的第一個問題是,運行此代碼(64000次重複的測試,最終應用程序將不需要運行很多次)。無論哪種方式,內存使用量增加約4kB/s - 我如何避免這種情況發生?
其次 - 有誰能告訴我如何讓這個程序更優雅嗎?
預先感謝諮詢