Skip to content

Commit

Permalink
dump stats on stop
Browse files Browse the repository at this point in the history
  • Loading branch information
guybortnikov authored and Jongy committed Apr 27, 2023
1 parent f83d0dc commit 6778799
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ Error Arguments::parse(const char* args) {
CASE("reverse")
_reverse = true;

CASE("meminfolog")
_log_meminfo_on_dump = true;

DEFAULT()
if (_unknown_arg == NULL) _unknown_arg = arg;
}
Expand Down
5 changes: 4 additions & 1 deletion src/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class Arguments {
const char* _title;
double _minwidth;
bool _reverse;
// Granulate Extra
bool _log_meminfo_on_dump;

Arguments(bool persistent = false) :
_buf(NULL),
Expand Down Expand Up @@ -230,7 +232,8 @@ class Arguments {
_end(NULL),
_title(NULL),
_minwidth(0),
_reverse(false) {
_reverse(false),
_log_meminfo_on_dump(false) {
}

~Arguments();
Expand Down
10 changes: 10 additions & 0 deletions src/profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,10 @@ Error Profiler::runInternal(Arguments& args, std::ostream& out) {
}
case ACTION_DUMP: {
Error error = dump(out, args);
if (args._log_meminfo_on_dump) {
logUsedMemory();
}

if (error) {
return error;
}
Expand Down Expand Up @@ -1685,3 +1689,9 @@ void Profiler::shutdown(Arguments& args) {

_state = TERMINATED;
}

void Profiler::logUsedMemory() {
std::ostringstream stringStream;
printUsedMemory(stringStream);
Log::info("%s", stringStream.str().c_str());
}
1 change: 1 addition & 0 deletions src/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class Profiler {
Error stop();
Error flushJfr();
Error dump(std::ostream& out, Arguments& args);
void logUsedMemory();
void printUsedMemory(std::ostream& out);
void switchThreadEvents(jvmtiEventMode mode);
int convertNativeTrace(int native_frames, const void** callchain, ASGCT_CallFrame* frames);
Expand Down

0 comments on commit 6778799

Please sign in to comment.