mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-18 00:10:33 -04:00
Adjust the policy of automatic memory allocation
This commit is contained in:
parent
7beef30d20
commit
12932a1d33
@ -454,6 +454,20 @@ public class HMCLGameRepository extends DefaultGameRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long getAllocatedMemory(long minimum, long available, boolean auto) {
|
public static long getAllocatedMemory(long minimum, long available, boolean auto) {
|
||||||
return auto ? Math.max(minimum, (long) (available * 0.8)) : minimum;
|
if (auto) {
|
||||||
|
available -= 256 * 1024 * 1024; // Reserve 256MB memory for off-heap memory and HMCL itself
|
||||||
|
if (available <= 0) {
|
||||||
|
return minimum;
|
||||||
|
}
|
||||||
|
|
||||||
|
final long threshold = 8L * 1024 * 1024 * 1024;
|
||||||
|
final long suggested = Math.min(available <= threshold
|
||||||
|
? (long) (available * 0.8)
|
||||||
|
: (long) (threshold * 0.8 + (available - threshold) * 0.2),
|
||||||
|
32736L * 1024 * 1024); // Limit the maximum suggested memory to ensure that compressed oops are available
|
||||||
|
return Math.max(minimum, suggested);
|
||||||
|
} else {
|
||||||
|
return minimum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user