Skip to content

Commit 989f490

Browse files
authored
Merge pull request #1373 from joto/print-memory-usage
Print memory usage at the end of running osm2pgsql
2 parents 5203419 + aebdaad commit 989f490

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/osm2pgsql.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "util.hpp"
3636
#include "version.hpp"
3737

38+
#include <osmium/util/memory.hpp>
39+
3840
#include <exception>
3941
#include <memory>
4042

@@ -72,17 +74,26 @@ int main(int argc, char *argv[])
7274

7375
// Processing: In this phase the input file(s) are read and parsed,
7476
// populating some of the tables.
75-
process_files(files, osmdata, options.append, get_logger().show_progress());
77+
process_files(files, osmdata, options.append,
78+
get_logger().show_progress());
7679

7780
// Process pending ways and relations. Cluster database tables and
7881
// create indexes.
7982
osmdata.stop();
8083

84+
// Output overall memory usage. This only works on Linux.
85+
osmium::MemoryUsage mem;
86+
if (mem.peak() != 0) {
87+
log_debug("Overall memory usage: peak={}MByte current={}MByte",
88+
mem.peak(), mem.current());
89+
}
90+
8191
log_info("Osm2pgsql took {} overall.",
8292
util::human_readable_duration(timer_overall.stop()));
8393
} catch (std::exception const &e) {
8494
log_error("{}", e.what());
8595
return 1;
8696
}
97+
8798
return 0;
8899
}

0 commit comments

Comments
 (0)