From 0a17e0719df7665765260018a782f9a7555d70d7 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 26 Nov 2010 13:29:34 +0100 Subject: [PATCH] ENH: use memInfo instead of parsing meminfo ourselves --- .../vtkPV3Foam/vtkPV3FoamUtils.C | 38 ++----------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C index 673aeccffd..989c2dcf80 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C @@ -33,6 +33,7 @@ Description #include "fvMesh.H" #include "Time.H" #include "IFstream.H" +#include "memInfo.H" // VTK includes #include "vtkDataArraySelection.h" @@ -325,44 +326,13 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// parse these bits of info from /proc/meminfo (Linux) -// -// MemTotal: 2062660 kB -// MemFree: 1124400 kB -// -// used = MemTotal - MemFree is what the free(1) uses. -// void Foam::vtkPV3Foam::printMemory() { - const char* meminfo = "/proc/meminfo"; + memInfo mem; - if (exists(meminfo)) + if (mem.valid()) { - IFstream is(meminfo); - label memTotal = 0; - label memFree = 0; - - string line; - - while (is.getLine(line).good()) - { - char tag[32]; - int value; - - if (sscanf(line.c_str(), "%30s %d", tag, &value) == 2) - { - if (!strcmp(tag, "MemTotal:")) - { - memTotal = value; - } - else if (!strcmp(tag, "MemFree:")) - { - memFree = value; - } - } - } - - Info<< "memUsed: " << (memTotal - memFree) << " kB\n"; + Info<< "mem peak/size/rss: " << mem << "\n"; } }