void RefreshMemInfo()
{
int binWidth;
List<Color> colors;
int i;
int segments;
Color color;
bool free;
GATMemDebugInfo info;
_allocator = GATManager.DefaultDataAllocator;
if( _allocator == null )
return;
binWidth = _allocator.BinWidth;
_memInfo = _allocator.GetDebugInfo();
_fixedMemInfo = _allocator.GetFixedDebugInfo();
colors = new List< Color >( 1000 );
_nbOfFragmentedChunks = 0;
_totalFragmentedSize = 0;
_nbOfAllocatedChunks = 0;
_totalAllocatedSize = 0;
_totalUnusedAllocated = 0;
for( i = 0; i < _memInfo.Count; i++ )
{
info = _memInfo[ i ];
segments = info.MaxSize / binWidth;
free = info.AllocatedSize == 0;
color = free ? FREE_COLOR : USED_COLOR;
if( free )
{
_nbOfFragmentedChunks++;
_totalFragmentedSize += info.MaxSize;
}
else
{
_nbOfAllocatedChunks++;
_totalAllocatedSize += info.MaxSize;
_totalUnusedAllocated += info.MaxSize - info.AllocatedSize;
}
for( int j = 0; j < segments; j++ )
{
colors.Add ( color );
}
colors.Add ( SEPERATOR_COLOR );
}
segments = _allocator.UnfragmentedSize / binWidth;
for( i = 0; i < segments; i++ )
{
colors.Add ( FREE_COLOR );
}
int totalFixed = 0;
foreach( GATFixedMemDebugInfo fInfo in _fixedMemInfo )
{
totalFixed += fInfo.AllocatedSize;
}
segments = totalFixed / binWidth;
if( segments == 0 && totalFixed > 0 )
{
segments = 2;
}
for( i = 0; i < segments; i++ )
{
colors.Add ( FIXED_COLOR );
}
if( _memTexture != null )
{
DestroyImmediate( _memTexture );
}
_memTexture = new Texture2D( colors.Count, TEXTURE_HEIGHT, TextureFormat.RGB24, false );
Color[] colorArray = colors.ToArray();
for( i = 0; i < TEXTURE_HEIGHT; i++ )
{
_memTexture.SetPixels( 0, i, colorArray.Length, 1, colorArray );
}
_memTexture.Apply( false, false );
_maxAllocStop = new Vector3( _maxAllocStart.x + _allocator.NbOfBins, _maxAllocStart.y );
_maxAllocString = string.Format( "Largest Allocatable Chunk( {0} samples )", ( _allocator.BinWidth * _allocator.NbOfBins ).ToString( "N0") );
_maxAllocRect = new Rect( _maxAllocStop.x + 5f, _maxAllocStop.y - 8f, 300f, 20f );
}