摘要
空气质量实时监测系统要求每5 min从数据库中取出监测数据,并将数据动态显示在Google地图标记的信息窗口中.直接使用封装谷歌地图的控件及在脚本中定义局部谷歌地图实例对象,都会发生内存泄漏,原因是脚本语言没有提供回收对象实例的方法,所有局部对象实例的回收都由系统内置的垃圾回收机制自动完成.而垃圾回收机制何时运行,完全由操作系统决定,程序无法控制.提出将地图对象及相关的标记、信息窗体对象全局化定义,使得相关对象只定义及实例化一次,避免实例对象的重复定义,解决了系统内存的泄漏问题.
Air quality monitoring system gets data from database every 5 minutes and displays data in the information window of Google map marker dynamically. A memory leak occurs directly using map controls and defining local Google map object instances in Javascript, because Javascript doesn' t provide the method to recycle object instances. All local object instances are recycled by garbage collection mechanism within operation system. But when and how the garbage collection mechanism to run is decided entirely by operation system, programmer can't control. We propose that map objects and tags, information windows are defined only once as global object to avoid duplicate definition of instance objects, so as to solve the memory leak problems.
出处
《武汉工程大学学报》
CAS
2012年第6期74-78,共5页
Journal of Wuhan Institute of Technology
基金
武汉工程大学智能机器人湖北省重点实验室开放基金(HBIR201006)
关键词
内存泄漏
谷歌地图
异步脚本及标记语言
实时监测
memory leak
goggle map
asynchronous javascript and XML
real- time monitoring