Skip to content
Permalink
Browse files
8286198: [linux] Fix process-memory information
Reviewed-by: dholmes, mbaesken
  • Loading branch information
tstuefe committed May 10, 2022
1 parent 65f5067 commit 9e320d9ab1813eda705d7318ef964092c50d1ade
Showing 1 changed file with 7 additions and 4 deletions.
@@ -2152,23 +2152,26 @@ void os::Linux::print_process_memory_info(outputStream* st) {
// - Print glibc tunables
#ifdef __GLIBC__
size_t total_allocated = 0;
size_t free_retained = 0;
bool might_have_wrapped = false;
if (_mallinfo2 != NULL) {
struct glibc_mallinfo2 mi = _mallinfo2();
total_allocated = mi.uordblks;
total_allocated = mi.uordblks + mi.hblkhd;
free_retained = mi.fordblks;
} else if (_mallinfo != NULL) {
// mallinfo is an old API. Member names mean next to nothing and, beyond that, are 32-bit signed.
// So for larger footprints the values may have wrapped around. We try to detect this here: if the
// process whole resident set size is smaller than 4G, malloc footprint has to be less than that
// and the numbers are reliable.
struct glibc_mallinfo mi = _mallinfo();
total_allocated = (size_t)(unsigned)mi.uordblks;
total_allocated = (size_t)(unsigned)mi.uordblks + (size_t)(unsigned)mi.hblkhd;
free_retained = (size_t)(unsigned)mi.fordblks;
// Since mallinfo members are int, glibc values may have wrapped. Warn about this.
might_have_wrapped = (info.vmrss * K) > UINT_MAX && (info.vmrss * K) > (total_allocated + UINT_MAX);
}
if (_mallinfo2 != NULL || _mallinfo != NULL) {
st->print_cr("C-Heap outstanding allocations: " SIZE_FORMAT "K%s",
total_allocated / K,
st->print_cr("C-Heap outstanding allocations: " SIZE_FORMAT "K, retained: " SIZE_FORMAT "K%s",
total_allocated / K, free_retained / K,
might_have_wrapped ? " (may have wrapped)" : "");
}
// Tunables

7 comments on commit 9e320d9

@tstuefe
Copy link
Member Author

@tstuefe tstuefe commented on 9e320d9 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 9e320d9 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe the backport was successfully created on the branch tstuefe-backport-9e320d9a in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 9e320d9a from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 10 May 2022 and was reviewed by David Holmes and Matthias Baesken.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev tstuefe-backport-9e320d9a:tstuefe-backport-9e320d9a
$ git checkout tstuefe-backport-9e320d9a
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev tstuefe-backport-9e320d9a

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 9e320d9 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe
Copy link
Member Author

@tstuefe tstuefe commented on 9e320d9 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk18u

@openjdk
Copy link

@openjdk openjdk bot commented on 9e320d9 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe the backport was successfully created on the branch tstuefe-backport-9e320d9a in my personal fork of openjdk/jdk18u. To create a pull request with this backport targeting openjdk/jdk18u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 9e320d9a from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 10 May 2022 and was reviewed by David Holmes and Matthias Baesken.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk18u:

$ git fetch https://github.com/openjdk-bots/jdk18u tstuefe-backport-9e320d9a:tstuefe-backport-9e320d9a
$ git checkout tstuefe-backport-9e320d9a
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk18u tstuefe-backport-9e320d9a

@tstuefe
Copy link
Member Author

@tstuefe tstuefe commented on 9e320d9 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 9e320d9 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe the backport was successfully created on the branch tstuefe-backport-9e320d9a in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 9e320d9a from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 10 May 2022 and was reviewed by David Holmes and Matthias Baesken.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev tstuefe-backport-9e320d9a:tstuefe-backport-9e320d9a
$ git checkout tstuefe-backport-9e320d9a
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev tstuefe-backport-9e320d9a

Please sign in to comment.