Skip to content

Commit b697346

Browse files
authored
Merge pull request #3694 from tautschnig/memory_info
Enable memory_info on Windows
2 parents 673ecd3 + 4d6fd7f commit b697346

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

src/util/memory_info.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,15 @@ void memory_info(std::ostream &out)
4747
out << " space available in freed fastbin blocks: " << m.fsmblks << "\n";
4848
out << " total allocated space: " << m.uordblks << "\n";
4949
out << " total free space: " << m.fordblks << "\n";
50-
#endif
51-
52-
#ifdef _WIN32
53-
(void)out; // unused parameter
54-
#if 0
50+
#elif defined(_WIN32)
5551
PROCESS_MEMORY_COUNTERS pmc;
5652
if(GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
5753
{
58-
out << " PeakWorkingSetSize: " << pmc.PeakWorkingSetSize << "\n";
59-
out << " WorkingSetSize: " << pmc.WorkingSetSize << "\n";
54+
out << " peak working set size [bytes]: " << pmc.PeakWorkingSetSize
55+
<< "\n";
56+
out << " current working set size [bytes]: " << pmc.WorkingSetSize << "\n";
6057
}
61-
#endif
62-
#endif
63-
64-
#ifdef __APPLE__
58+
#elif defined(__APPLE__)
6559
// NOLINTNEXTLINE(readability/identifiers)
6660
struct task_basic_info t_info;
6761
mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;

unit/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ SRC += analyses/ai/ai.cpp \
4949
util/graph.cpp \
5050
util/irep.cpp \
5151
util/irep_sharing.cpp \
52+
util/memory_info.cpp \
5253
util/message.cpp \
5354
util/optional.cpp \
5455
util/optional_utils.cpp \

unit/util/memory_info.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*******************************************************************\
2+
3+
Module: Unit tests for memory_info.h
4+
5+
Author: Michael Tautschnig
6+
7+
\*******************************************************************/
8+
9+
#include <testing-utils/catch.hpp>
10+
11+
#include <util/memory_info.h>
12+
13+
#include <sstream>
14+
15+
TEST_CASE("memory_info returns some output", "[core][util][memory_info]")
16+
{
17+
std::ostringstream oss;
18+
memory_info(oss);
19+
20+
REQUIRE(!oss.str().empty());
21+
}

0 commit comments

Comments
 (0)