Updating a View

Hi,

I am designing a web application, and I have troubles when I update a view in the 50th time.

I put the 3D object in the view using:


document.getElementById(0).appendChild(Viewer( 3D_Object, 250, 250, 5).gl.canvas);

And when I want to update the view, because I manipulate this 3D object, I use:


document.getElementById(0).removeChild(3D_Object.gl.canvas);
document.getElementById(0).appendChild(Viewer( 3D_Object_new, 250, 250, 5).gl.canvas);
3D_Object = 3D_Object_new

The updates work well in the firts 49 times, but in the time 50 the program hangs.

The view is here:


  		<style>
			body {
  				font: 14px/20px 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  				max-width: 800px;
  				margin: 0 auto;
  				padding: 50px 50px 200px 50px;
			}

			pre, code {
  				font: 12px/20px Monaco, monospace;
  				border: 1px solid #CCC;
  				border-radius: 3px;
  				background: #F9F9F9;
  				padding: 0 3px;
  				color: #555;
				}
				
			pre { padding: 10px; }

			h1, h2 { font: bold 50px/50px 'Helvetica Neue', Helvetica, Arial; }
			h2 { font-size: 30px; margin: 100px 0 0 0; }
			a { color: inherit; }
			.viewer { width: 250px; height: 250px; background: #EEE; }
			table { border-collapse: collapse; margin: 0 auto; }
			td { padding: 5px; text-align: center; }
			td code { background: none; border: none; color: inherit; }
			canvas { cursor: move; }
  		</style>

What is wrong with this?

Thanks

The firts 1-49 times (all is correct):

The 50th time (exist an error in the update):

Thanks