Skip to content

Commit

Permalink
Changed way to change sorting from bytes to count
Browse files Browse the repository at this point in the history
  • Loading branch information
schmelter-sap committed Oct 9, 2023
1 parent c8a40a5 commit cf7f35a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/hotspot/os/posix/malloctrace/mallocTrace2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2260,14 +2260,14 @@ MallocTraceDumpDCmd::MallocTraceDumpDCmd(outputStream* output, bool heap) :
_count_fraction("-count-fraction", "The fraction in percent of the total allocation count " \
"the output must contain.", "INT", false, "100"),
_max_entries("-max-entries", "The maximum number of entries to dump.", "INT", false, "-1"),
_sort("-sort", "If given the stacks are sorted. If the argument is 'size' they are " \
"sorted by size and if the argument is 'count' the are sorted by allocation " \
"count.", "STRING", false) {
_sort_by_count("-sort-by-count", "If given the stacks are sorted according to the number " \
"of allocations. Otherwise they are orted by the number of allocated bytes.",
"BOOLEAN", false) {
_dcmdparser.add_dcmd_option(&_dump_file);
_dcmdparser.add_dcmd_option(&_size_fraction);
_dcmdparser.add_dcmd_option(&_count_fraction);
_dcmdparser.add_dcmd_option(&_max_entries);
_dcmdparser.add_dcmd_option(&_sort);
_dcmdparser.add_dcmd_option(&_sort_by_count);
}

void MallocTraceDumpDCmd::execute(DCmdSource source, TRAPS) {
Expand All @@ -2276,12 +2276,12 @@ void MallocTraceDumpDCmd::execute(DCmdSource source, TRAPS) {

DumpSpec spec;
spec._dump_file = _dump_file.value();
spec._sort = _sort.value();
spec._sort = _sort_by_count.value() ? "count" : "size";
spec._size_fraction = _size_fraction.value();
spec._count_fraction = _count_fraction.value();
spec._max_entries = _max_entries.value();
spec._on_error = false;
spec._sort_by_count = (spec._sort != NULL) && (strcmp("count", spec._sort) == 0);
spec._sort_by_count = _sort_by_count.value();

MallocStatistic::dump(_output, spec);
}
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/os/posix/malloctrace/mallocTrace2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class MallocTraceDumpDCmd : public DCmdWithParser {
DCmdArgument<jlong> _size_fraction;
DCmdArgument<jlong> _count_fraction;
DCmdArgument<jlong> _max_entries;
DCmdArgument<char*> _sort;
DCmdArgument<bool> _sort_by_count;

public:
static int num_arguments() {
Expand Down Expand Up @@ -176,5 +176,3 @@ class MallocTraceDumpDCmd : public DCmdWithParser {
}

#endif


Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static void testEnvSanitizing() throws Exception {
}

private static void testTracking() throws Exception {
ProcessBuilder pb = runStress(1000, 1024 * 1024 * 100, 65536);
ProcessBuilder pb = runStress(1, 1024 * 1024 * 100, 65536);
new OutputAnalyzer(pb.start()).shouldHaveExitValue(0);
}

Expand Down

0 comments on commit cf7f35a

Please sign in to comment.