Skip to content

[Bug] macOS上剩余内存读取问题 #4702

Description

@WhatDamon

问题描述 | Bug Description

在macOS下,分配内存页面的内存读取存在问题,有关代码:

public long getTotalMemorySize() {
try {
if (ManagementFactory.getOperatingSystemMXBean() instanceof com.sun.management.OperatingSystemMXBean bean) {
return bean.getTotalMemorySize();
}
} catch (NoClassDefFoundError ignored) {
}
return 0L;
}
public long getFreeMemorySize() {
try {
if (ManagementFactory.getOperatingSystemMXBean() instanceof com.sun.management.OperatingSystemMXBean bean) {
return bean.getFreeMemorySize();
}
} catch (NoClassDefFoundError ignored) {
}
return 0L;
}

此代码在Windows与Linux上均可正确汇报数据,但在macOS上,尤其是在使用统一内存架构(RAM和VRAM共享)的Apple Silicon,目前使用的函数不能正确处理这些数据

Image

可能在内存的读取上,需要针对macOS进行特别优化以保证数据的正确汇报,不过目前的情况正常使用不会产生特别严重的影响

启动器崩溃报告 / 启动器日志文件 | Launcher Crash Report / Launcher Log File

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions