本文整理汇总了C++中TMultiMap::ValueSort方法的典型用法代码示例。如果您正苦于以下问题:C++ TMultiMap::ValueSort方法的具体用法?C++ TMultiMap::ValueSort怎么用?C++ TMultiMap::ValueSort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMultiMap
的用法示例。
在下文中一共展示了TMultiMap::ValueSort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessMemoryOperations
//.........这里部分代码省略.........
}
}
const FAllocationInfo& Alloc = SequenceAllocationArray[Index];
const EMemoryOperation MemOp = Alloc.Op;
const uint64 Ptr = Alloc.Ptr;
const int64 Size = Alloc.Size;
const uint32 SequenceTag = Alloc.SequenceTag;
if( MemOp == EMemoryOperation::Alloc )
{
const FAllocationInfo* Found = AllocationMap.Find( Ptr );
if( !Found )
{
AllocationMap.Add( Ptr, Alloc );
}
else
{
const FAllocationInfo* FoundAndFreed = FreeWithoutAllocMap.Find( Found->Ptr );
const FAllocationInfo* FoundAndAllocated = FreeWithoutAllocMap.Find( Alloc.Ptr );
#if _DEBUG
if( FoundAndFreed )
{
const FString FoundAndFreedCallstack = GetCallstack( FoundAndFreed->EncodedCallstack );
}
if( FoundAndAllocated )
{
const FString FoundAndAllocatedCallstack = GetCallstack( FoundAndAllocated->EncodedCallstack );
}
NumDuplicatedMemoryOperations++;
const FString FoundCallstack = GetCallstack( Found->EncodedCallstack );
const FString AllocCallstack = GetCallstack( Alloc.EncodedCallstack );
#endif // _DEBUG
// Replace pointer.
AllocationMap.Add( Ptr, Alloc );
// Store the old pointer.
DuplicatedAllocMap.Add( Ptr, *Found );
}
}
else if( MemOp == EMemoryOperation::Free )
{
const FAllocationInfo* Found = AllocationMap.Find( Ptr );
if( Found )
{
const bool bIsValid = Alloc.SequenceTag > Found->SequenceTag;
if( !bIsValid )
{
UE_LOG( LogStats, Warning, TEXT( "InvalidFree Ptr: %llu, Seq: %i/%i" ), Ptr, SequenceTag, Found->SequenceTag );
}
AllocationMap.Remove( Ptr );
}
else
{
FreeWithoutAllocMap.Add( Ptr, Alloc );
NumFWAMemoryOperations++;
}
}
}
UE_LOG( LogStats, Warning, TEXT( "NumDuplicatedMemoryOperations: %i" ), NumDuplicatedMemoryOperations );
UE_LOG( LogStats, Warning, TEXT( "NumFWAMemoryOperations: %i" ), NumFWAMemoryOperations );
// Dump problematic allocations
DuplicatedAllocMap.ValueSort( FAllocationInfoGreater() );
//FreeWithoutAllocMap
uint64 TotalDuplicatedMemory = 0;
for( const auto& It : DuplicatedAllocMap )
{
const FAllocationInfo& Alloc = It.Value;
TotalDuplicatedMemory += Alloc.Size;
}
UE_LOG( LogStats, Warning, TEXT( "Dumping duplicated alloc map" ) );
const float MaxPctDisplayed = 0.80f;
uint64 DisplayedSoFar = 0;
for( const auto& It : DuplicatedAllocMap )
{
const FAllocationInfo& Alloc = It.Value;
const FString AllocCallstack = GetCallstack( Alloc.EncodedCallstack );
UE_LOG( LogStats, Log, TEXT( "%lli (%.2f MB) %s" ), Alloc.Size, Alloc.Size / 1024.0f / 1024.0f, *AllocCallstack );
DisplayedSoFar += Alloc.Size;
const float CurrentPct = (float)DisplayedSoFar / (float)TotalDuplicatedMemory;
if( CurrentPct > MaxPctDisplayed )
{
break;
}
}
GenerateMemoryUsageReport( AllocationMap );
}