var gc_watcher = {
	show_heap_num : 0,

	last_heap_ele : null,

	show_h_list : [],

	show_cell_max : 20,

	add_show_heap : function(num) {
		for(var i=this.show_heap_num,len=this.show_heap_num+num; i<len; i++) {
			var r = document.getElementById("heap_table").rows;
			if(!r.length || this.last_heap_ele.parentNode.cells.length >= this.show_cell_max) {
				r = document.getElementById("heap_table").insertRow(r.length);
			}
			else {
				r = r[r.length-1];
			}
			var cell = r.insertCell(r.cells.length);
			cell.id = "obj_"+i;
			cell.textContent = "object";
			this.last_heap_ele = cell;
			this.show_h_list.push({ele_id : cell.id, heap_ele : gc.heap[i]});
		}
		this.show_heap_num+=num;
		document.getElementById("heap_table").style.border = "1";
	},

	paint : function() {
		for(var i=0,len=this.show_h_list.length; i<len; i++) {
			if(this.show_h_list[i].heap_ele.is_use) document.getElementById(this.show_h_list[i].ele_id).style.backgroundColor = "blue";
			else document.getElementById(this.show_h_list[i].ele_id).style.backgroundColor = "white";
		}
	},

	watch : function() {
		if(gc_watcher.show_heap_num < gc.heap.length) gc_watcher.add_show_heap(gc.heap.length - gc_watcher.show_heap_num);
		gc_watcher.paint();
		setTimeout(arguments.callee, 5000);
	}
};

gc_watcher.watch();

