8255978: [windows] os::release_memory may not release the full range

Reviewed-by: iklam, minqi
This commit is contained in:
Thomas Stuefe 2020-11-19 11:51:09 +00:00
parent 6702910b74
commit f626ed6a43
7 changed files with 491 additions and 1 deletions

View file

@ -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