mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 18:14:38 +02:00
8261167: print_process_memory_info add a close call after fopen
Reviewed-by: stuefe, dholmes
This commit is contained in:
parent
48f5220c80
commit
43ae0cf878
1 changed files with 28 additions and 22 deletions
|
@ -2195,6 +2195,7 @@ void os::Linux::print_process_memory_info(outputStream* st) {
|
||||||
int num_found = 0;
|
int num_found = 0;
|
||||||
FILE* f = ::fopen("/proc/self/status", "r");
|
FILE* f = ::fopen("/proc/self/status", "r");
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
if (f != NULL) {
|
||||||
while (::fgets(buf, sizeof(buf), f) != NULL && num_found < num_values) {
|
while (::fgets(buf, sizeof(buf), f) != NULL && num_found < num_values) {
|
||||||
if ( (vmsize == -1 && sscanf(buf, "VmSize: " SSIZE_FORMAT " kB", &vmsize) == 1) ||
|
if ( (vmsize == -1 && sscanf(buf, "VmSize: " SSIZE_FORMAT " kB", &vmsize) == 1) ||
|
||||||
(vmpeak == -1 && sscanf(buf, "VmPeak: " SSIZE_FORMAT " kB", &vmpeak) == 1) ||
|
(vmpeak == -1 && sscanf(buf, "VmPeak: " SSIZE_FORMAT " kB", &vmpeak) == 1) ||
|
||||||
|
@ -2209,6 +2210,8 @@ void os::Linux::print_process_memory_info(outputStream* st) {
|
||||||
num_found ++;
|
num_found ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
st->print_cr("Virtual Size: " SSIZE_FORMAT "K (peak: " SSIZE_FORMAT "K)", vmsize, vmpeak);
|
st->print_cr("Virtual Size: " SSIZE_FORMAT "K (peak: " SSIZE_FORMAT "K)", vmsize, vmpeak);
|
||||||
st->print("Resident Set Size: " SSIZE_FORMAT "K (peak: " SSIZE_FORMAT "K)", vmrss, vmhwm);
|
st->print("Resident Set Size: " SSIZE_FORMAT "K (peak: " SSIZE_FORMAT "K)", vmrss, vmhwm);
|
||||||
if (rssanon != -1) { // requires kernel >= 4.5
|
if (rssanon != -1) { // requires kernel >= 4.5
|
||||||
|
@ -2219,6 +2222,9 @@ void os::Linux::print_process_memory_info(outputStream* st) {
|
||||||
if (vmswap != -1) { // requires kernel >= 2.6.34
|
if (vmswap != -1) { // requires kernel >= 2.6.34
|
||||||
st->print_cr("Swapped out: " SSIZE_FORMAT "K", vmswap);
|
st->print_cr("Swapped out: " SSIZE_FORMAT "K", vmswap);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
st->print_cr("Could not open /proc/self/status to get process memory related information");
|
||||||
|
}
|
||||||
|
|
||||||
// Print glibc outstanding allocations.
|
// Print glibc outstanding allocations.
|
||||||
// (note: there is no implementation of mallinfo for muslc)
|
// (note: there is no implementation of mallinfo for muslc)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue