Dispose() public method

public Dispose ( ) : void
return void
コード例 #1
0
        //jfcomment: This is never called, so pools are not maintained. I tried calling it before every use of new Voronoi, but it only slowed things down.
        //Some of the _pools are used during voronoi computation, but the _sites._sites pool is only pushed into on _sites.Dispose.
        //_pools are statics. Since I now maintain pointers to sites in Engine.nodes, there is no need to pool sites, and calling _sites.Dispose
        //would fill up the _sites pool, and make a memory leak.
        //I think the coder of Voronoi made a mistake to abuse iDispose and dispose to frustrate the gc (keep pools), it's the exact opposite of their normal usage.
        //It would have been better to name them "recycle" or something.
        public void Dispose()
        {
            if (Debug.isDebugBuild)
            {
                Debug.Log("ERROR, Voronoi.Dispose!!");                             //jf
            }
            int i, n;

            if (_sites != null)
            {
                _sites.Dispose();
                _sites = null;
            }
            if (_triangles != null)
            {
                n = _triangles.Count;
                for (i = 0; i < n; ++i)
                {
                    _triangles [i].Dispose();
                }
                _triangles.Clear();
                _triangles = null;
            }
            if (_edges != null)
            {
                n = _edges.Count;
                for (i = 0; i < n; ++i)
                {
                    _edges [i].Dispose();
                }
                _edges.Clear();
                _edges = null;
            }
//			_plotBounds = null;
            _sitesIndexedByLocation = null;
        }