Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
d77d215c
Commit
d77d215c
authored
Nov 17, 2010
by
graham
Browse files
ENH: memSize and memSizePeak functions, reading /proc/<pid>/status.
parent
8f0a5ff1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/OSspecific/POSIX/POSIX.C
View file @
d77d215c
...
...
@@ -36,6 +36,7 @@ Description
#include
"fileName.H"
#include
"fileStat.H"
#include
"timer.H"
#include
"IFstream.H"
#include
<fstream>
#include
<cstdlib>
...
...
@@ -1037,4 +1038,58 @@ int Foam::system(const string& command)
}
int
Foam
::
memSize
()
{
IFstream
is
(
"/proc/"
+
name
(
pid
())
+
"/status"
);
int
VmSize
=
0
;
while
(
is
.
good
())
{
string
line
;
is
.
getLine
(
line
);
char
tag
[
32
];
int
value
;
if
(
sscanf
(
line
.
c_str
(),
"%30s %d"
,
tag
,
&
value
)
==
2
)
{
if
(
!
strcmp
(
tag
,
"VmSize:"
))
{
VmSize
=
value
;
break
;
}
}
}
return
VmSize
;
}
int
Foam
::
memPeakSize
()
{
IFstream
is
(
"/proc/"
+
name
(
pid
())
+
"/status"
);
int
VmPeak
=
0
;
while
(
is
.
good
())
{
string
line
;
is
.
getLine
(
line
);
char
tag
[
32
];
int
value
;
if
(
sscanf
(
line
.
c_str
(),
"%30s %d"
,
tag
,
&
value
)
==
2
)
{
if
(
!
strcmp
(
tag
,
"VmPeak:"
))
{
VmPeak
=
value
;
break
;
}
}
}
return
VmPeak
;
}
// ************************************************************************* //
src/OpenFOAM/include/OSspecific.H
View file @
d77d215c
...
...
@@ -176,6 +176,12 @@ bool ping(const word&, const label timeOut=10);
//- Execute the specified command
int
system
(
const
string
&
command
);
//- Return the size in memory of the current process
int
memSize
();
//- Return the peak size in memory of the current process
int
memPeakSize
();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment