本文整理汇总了C#中Log.GetMemoryUsage方法的典型用法代码示例。如果您正苦于以下问题:C# Log.GetMemoryUsage方法的具体用法?C# Log.GetMemoryUsage怎么用?C# Log.GetMemoryUsage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log.GetMemoryUsage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddLog
void AddLog( string condition, string stacktrace, LogType type )
{
float memUsage = 0f ;
string _condition = "";
if( cachedString.ContainsKey( condition ) )
{
_condition = cachedString[ condition ];
}
else
{
_condition = condition ;
cachedString.Add( _condition , _condition );
memUsage += (string.IsNullOrEmpty(_condition)?0:_condition.Length*sizeof(char));
memUsage += System.IntPtr.Size ;
}
string _stacktrace = "";
if( cachedString.ContainsKey( stacktrace ) )
{
_stacktrace = cachedString[ stacktrace ];
}
else
{
_stacktrace = stacktrace ;
cachedString.Add( _stacktrace , _stacktrace );
memUsage += (string.IsNullOrEmpty(_stacktrace)?0:_stacktrace.Length*sizeof(char));
memUsage += System.IntPtr.Size ;
}
bool newLogAdded = false ;
addSample();
Log log = new Log(){ logType = (_LogType)type , condition = _condition , stacktrace = _stacktrace , sampleId = samples.Count -1 };
memUsage += log.GetMemoryUsage() ;
//memUsage += samples.Count * 13 ;
logsMemUsage += memUsage/1024/1024;
if( TotalMemUsage > maxSize )
{
clear();
Debug.Log( "Memory Usage Reach" + maxSize +" mb So It is Cleared");
return;
}
bool isNew = false ;
//string key = _condition;// + "_!_" + _stacktrace ;
if( logsDic.ContainsKey( _condition ,stacktrace) )
{
isNew = false ;
logsDic[ _condition ][stacktrace].count ++;
}
else
{
isNew = true ;
collapsedLogs.Add( log );
logsDic[_condition][stacktrace] = log ;
if( type == LogType.Log )
numOfCollapsedLogs++;
else if( type == LogType.Warning )
numOfCollapsedLogsWarning++;
else
numOfCollapsedLogsError++;
}
if( type == LogType.Log )
numOfLogs++;
else if( type == LogType.Warning )
numOfLogsWarning++;
else
numOfLogsError++;
logs.Add( log );
if( !collapse || isNew )
{
bool skip = false ;
if( log.logType == _LogType.Log && !showLog )
skip = true;
if( log.logType == _LogType.Warning && !showWarning )
skip = true;
if( log.logType == _LogType.Error && !showError )
skip = true;
if( log.logType == _LogType.Assert && !showError )
skip = true;
if( log.logType == _LogType.Exception && !showError )
skip = true;
if( !skip)
{
if( string.IsNullOrEmpty(filterText ) || log.condition.ToLower().Contains( filterText.ToLower() ))
{
currentLog.Add( log );
newLogAdded=true;
}
}
}
if( newLogAdded )
{
calculateStartIndex();
//.........这里部分代码省略.........