#3050 Add memory count to progress dialog.

This commit is contained in:
Gaute Lindkvist 2018-06-15 13:28:43 +02:00
parent ef2f8087dc
commit 8f0fb820a5
5 changed files with 30 additions and 4 deletions

View File

@ -42,9 +42,6 @@ add_library( ${PROJECT_NAME}
cafVecIjk.cpp
cafVecIjk.h
cafMemoryInspector.cpp
cafMemoryInspector.h
${MOC_FILES_CPP}
)

View File

@ -136,6 +136,8 @@ set( PROJECT_FILES
QMinimizePanel.h
cafQTreeViewStateSerializer.h
cafQTreeViewStateSerializer.cpp
cafMemoryInspector.h
cafMemoryInspector.cpp
)
add_library( ${PROJECT_NAME}

View File

@ -37,6 +37,7 @@
#include "cafProgressInfo.h"
#include "cafAssert.h"
#include "cafMemoryInspector.h"
#include "cafProgressState.h"
#include <QPointer>
@ -45,6 +46,8 @@
#include <QApplication>
#include <QThread>
#include <algorithm>
namespace caf {
//==================================================================================================
@ -181,6 +184,30 @@ namespace caf {
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString createMemoryLabelText()
{
uint64_t currentUsage = caf::MemoryInspector::getApplicationPhysicalMemoryUsageMiB();
uint64_t totalPhysicalMemory = caf::MemoryInspector::getTotalPhysicalMemoryMiB();
float currentUsageFraction = 0.0f;
float availVirtualFraction = 1.0f;
if (currentUsage > 0u && totalPhysicalMemory > 0u)
{
currentUsageFraction = std::min(1.0f, static_cast<float>(currentUsage) / totalPhysicalMemory);
}
QString labelText("\n ");
if (currentUsageFraction > 0.5)
{
labelText = QString("Memory Used: %1 MiB, Total Physical Memory: %2 MiB\n").arg(currentUsage).arg(totalPhysicalMemory);
}
return labelText;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -301,7 +328,7 @@ namespace caf {
if (!descriptionStack()[i].isEmpty()) labelText += descriptionStack()[i];
if (!(titleStack()[i].isEmpty() && descriptionStack()[i].isEmpty())) labelText += "\n";
}
labelText += "\n ";
labelText += createMemoryLabelText();
return labelText;
}