1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 Foam::memInfo::memInfo()
40 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
42 Foam::memInfo::~memInfo()
46 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
48 const Foam::memInfo& Foam::memInfo::update()
50 // reset to invalid values first
51 peak_ = size_ = rss_ = -1;
52 IFstream is("/proc/" + name(pid()) + "/status");
61 if (sscanf(line.c_str(), "%30s %d", tag, &value) == 2)
63 if (!strcmp(tag, "VmPeak:"))
67 else if (!strcmp(tag, "VmSize:"))
71 else if (!strcmp(tag, "VmRSS:"))
82 bool Foam::memInfo::valid() const
88 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
90 Foam::Istream& Foam::operator>>(Istream& is, memInfo& m)
92 is.readBegin("memInfo");
94 is >> m.peak_ >> m.size_ >> m.rss_;
96 is.readEnd("memInfo");
98 // Check state of Istream
101 "Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::memInfo&)"
108 Foam::Ostream& Foam::operator<<(Ostream& os, const memInfo& m)
110 os << token::BEGIN_LIST
111 << m.peak_ << token::SPACE << m.size_ << token::SPACE << m.rss_
114 // Check state of Ostream
117 "Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
118 "const Foam::memInfo&)"
125 // ************************************************************************* //