CBMC
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
c
d
e
f
g
j
l
m
r
t
w
Functions
a
c
d
f
g
r
t
w
Typedefs
Enumerations
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
i
k
l
m
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
h
i
k
l
m
n
o
p
q
r
s
t
u
v
Related Symbols
b
c
d
e
g
i
j
m
n
o
s
t
u
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
w
y
Typedefs
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerations
_
a
b
c
d
f
g
i
l
m
p
r
s
t
u
v
w
Enumerator
_
a
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Macros
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
memory_info.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include "
memory_info.h
"
10
11
#include "
invariant.h
"
12
13
#ifdef __GLIBC__
14
# include <malloc.h>
15
#elif defined(_WIN32)
16
# include <util/pragma_push.def>
17
# ifdef _MSC_VER
18
# pragma warning(disable : 4668)
19
// using #if/#elif on undefined macro
20
# pragma warning(disable : 5039)
21
// pointer or reference to potentially throwing function passed to extern C
22
# endif
23
# include <util/pragma_pop.def>
24
// windows.h must be included before psapi.h
25
// clang-format off
26
# include <windows.h>
27
# include <psapi.h>
28
// clang-format on
29
#elif defined(__APPLE__)
30
# include <mach/mach_init.h>
31
# include <mach/task.h>
32
# include <malloc/malloc.h>
33
#else
34
# include <sys/resource.h>
35
#endif
36
37
#include <ostream>
38
39
void
memory_info
(std::ostream &out)
40
{
41
#ifdef __GLIBC__
42
// NOLINTNEXTLINE(readability/identifiers)
43
struct
mallinfo
m =
mallinfo
();
44
out <<
" non-mmapped space allocated from system: "
<< m.arena <<
"\n"
;
45
out <<
" number of free chunks: "
<< m.ordblks <<
"\n"
;
46
out <<
" number of fastbin blocks: "
<< m.smblks <<
"\n"
;
47
out <<
" number of mmapped regions: "
<< m.hblks <<
"\n"
;
48
out <<
" space in mmapped regions: "
<< m.hblkhd <<
"\n"
;
49
out <<
" maximum total allocated space: "
<< m.usmblks <<
"\n"
;
50
out <<
" space available in freed fastbin blocks: "
<< m.fsmblks <<
"\n"
;
51
out <<
" total allocated space: "
<< m.uordblks <<
"\n"
;
52
out <<
" total free space: "
<< m.fordblks <<
"\n"
;
53
#elif defined(_WIN32)
54
PROCESS_MEMORY_COUNTERS
pmc
;
55
if
(
GetProcessMemoryInfo
(
GetCurrentProcess
(), &
pmc
,
sizeof
(
pmc
)))
56
{
57
out <<
" peak working set size [bytes]: "
<<
pmc
.PeakWorkingSetSize
58
<<
"\n"
;
59
out <<
" current working set size [bytes]: "
<<
pmc
.WorkingSetSize <<
"\n"
;
60
}
61
#elif defined(__APPLE__)
62
// NOLINTNEXTLINE(readability/identifiers)
63
struct
task_basic_info
t_info
;
64
mach_msg_type_number_t
t_info_count
=
TASK_BASIC_INFO_COUNT
;
65
task_info
(
66
current_task
(),
TASK_BASIC_INFO
, (
task_info_t
)&
t_info
, &
t_info_count
);
67
out <<
" virtual size: "
68
<<
static_cast<
double
>
(
t_info
.virtual_size)/1000000 <<
"m\n"
;
69
70
malloc_statistics_t
t;
71
malloc_zone_statistics
(
NULL
, &t);
72
out <<
" max_size_in_use: "
73
<<
static_cast<
double
>
(t.max_size_in_use)/1000000 <<
"m\n"
;
74
out <<
" size_allocated: "
75
<<
static_cast<
double
>
(t.size_allocated)/1000000 <<
"m\n"
;
76
#else
77
// NOLINTNEXTLINE(readability/identifiers)
78
struct
rusage
r_usage
;
79
int
result =
getrusage
(
RUSAGE_SELF
, &
r_usage
);
80
CHECK_RETURN
(result == 0);
81
out <<
" maximum resident set size [bytes]: "
<<
r_usage
.ru_maxrss <<
'\n'
;
82
#endif
83
}
39
void
memory_info
(std::ostream &out) {
…
}
ait
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition
ai.h:562
ait::ait
ait()
Definition
ai.h:565
memory_info
void memory_info(std::ostream &out)
Definition
memory_info.cpp:39
memory_info.h
CHECK_RETURN
#define CHECK_RETURN(CONDITION)
Definition
invariant.h:495
invariant.h
src
util
memory_info.cpp
Generated by
1.9.8