mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 01:54:47 +02:00
8255978: [windows] os::release_memory may not release the full range
Reviewed-by: iklam, minqi
This commit is contained in:
parent
6702910b74
commit
f626ed6a43
7 changed files with 491 additions and 1 deletions
|
@ -5485,6 +5485,35 @@ bool os::supports_map_sync() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void os::print_memory_mappings(char* addr, size_t bytes, outputStream* st) {
|
||||
unsigned long long start = (unsigned long long)addr;
|
||||
unsigned long long end = start + bytes;
|
||||
FILE* f = ::fopen("/proc/self/maps", "r");
|
||||
int num_found = 0;
|
||||
if (f != NULL) {
|
||||
st->print("Range [%llx-%llx) contains: ", start, end);
|
||||
char line[512];
|
||||
while(fgets(line, sizeof(line), f) == line) {
|
||||
unsigned long long a1 = 0;
|
||||
unsigned long long a2 = 0;
|
||||
if (::sscanf(line, "%llx-%llx", &a1, &a2) == 2) {
|
||||
// Lets print out every range which touches ours.
|
||||
if ((a1 >= start && a1 < end) || // left leg in
|
||||
(a2 >= start && a2 < end) || // right leg in
|
||||
(a1 < start && a2 >= end)) { // superimposition
|
||||
num_found ++;
|
||||
st->print("%s", line); // line includes \n
|
||||
}
|
||||
}
|
||||
}
|
||||
::fclose(f);
|
||||
if (num_found == 0) {
|
||||
st->print("nothing.");
|
||||
}
|
||||
st->cr();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////// Unit tests ///////////////
|
||||
|
||||
#ifndef PRODUCT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue