Skip to content

Commit f04e47a

Browse files
committed
GH-555 use FileChannel.MapMode.PRIVATE on macOS aarch64
1 parent c77fde6 commit f04e47a

File tree

1 file changed

+19
-1
lines changed
  • visualvm/libs.profiler/lib.profiler.heap/src/org/graalvm/visualvm/lib/jfluid/heap

1 file changed

+19
-1
lines changed

visualvm/libs.profiler/lib.profiler.heap/src/org/graalvm/visualvm/lib/jfluid/heap/AbstractLongMap.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ private static boolean isLinux() {
205205
return osName.endsWith("Linux"); // NOI18N
206206
}
207207

208+
private static boolean isMacOS() {
209+
String osName = System.getProperty("os.name"); // NOI18N
210+
211+
return "Mac OS X".equals(osName); // NOI18N
212+
}
213+
214+
private static boolean isAarch64() {
215+
String osArch = System.getProperty("os.arch"); // NOI18N
216+
217+
return "aarch64".equals(osArch); // NOI18N
218+
}
219+
208220
abstract Entry createEntry(long index);
209221

210222
abstract Entry createEntry(long index,long value);
@@ -379,7 +391,7 @@ public void force() throws IOException {
379391

380392
private static class MemoryMappedData extends AbstractData {
381393

382-
private static final FileChannel.MapMode MAP_MODE = isLinux() ? FileChannel.MapMode.PRIVATE : FileChannel.MapMode.READ_WRITE;
394+
private static final FileChannel.MapMode MAP_MODE = computeMapMode();
383395

384396
//~ Instance fields ------------------------------------------------------------------------------------------------------
385397

@@ -439,6 +451,12 @@ private static MappedByteBuffer createBuffer(RandomAccessFile file, long length)
439451
return channel.map(MAP_MODE, 0, length);
440452
}
441453
}
454+
455+
private static FileChannel.MapMode computeMapMode() {
456+
if (isLinux()) return FileChannel.MapMode.PRIVATE;
457+
if (isMacOS() && isAarch64()) return FileChannel.MapMode.PRIVATE;
458+
return FileChannel.MapMode.READ_WRITE;
459+
}
442460
}
443461

444462
private static class LongMemoryMappedData extends AbstractData {

0 commit comments

Comments
 (0)