Skip to content

Conversation

@WhatDamon
Copy link
Contributor

Fix #3980

实现逻辑:通过 vm_stat 命令获取空闲内存,内存读取较原有逻辑误差显著降低

受限于手头设备原因,这可能需要额外的测试来证明代码可用性

Before

Before

After

After

误差原因:这是同时计算了 vm_stat 输出的 Pages inactivePages free,可能逻辑与检测工具之间存在差异

long freePages = -1;
long inactivePages = -1;

try (var reader = process.inputReader()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要这样用 inputReader,应该显式指定编码为 OperatingSystem.NATIVE_CHARSET


try (var reader = process.inputReader()) {
String line;
while ((line = reader.readLine()) != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要在这里重复实现一遍列表解析,而不用 KeyValuePairUtils.loadList

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该用KeyValuePairUtils.loadPair更为合适,我将进行调整

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Mac 上启动器对系统内存占用识别不正确

2 participants