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 - 我如何避免这种情况发生?
其次 - 有谁能告诉我如何让这个程序更优雅吗?
预先感谢咨询