feat: update default memory from 2GB to 4GB (#6172)

* feat: update default memory from 2GB to 4GB

* prepr
This commit is contained in:
Prospector
2026-05-23 21:26:51 -07:00
committed by GitHub
parent aeb9f5a075
commit e12230ff59
2 changed files with 32 additions and 5 deletions
+21 -4
View File
@@ -181,12 +181,29 @@ pub async fn test_jre(
Ok(version == major_version)
}
// Gets maximum memory in KiB.
pub async fn get_max_memory() -> crate::Result<u64> {
Ok(sysinfo::System::new_with_specifics(
fn system_memory_bytes() -> u64 {
sysinfo::System::new_with_specifics(
RefreshKind::nothing()
.with_memory(MemoryRefreshKind::nothing().with_ram()),
)
.total_memory()
/ 1024)
}
/// Recommended default max heap (MiB) for new instances based on system RAM.
pub fn default_memory_max_mb() -> u32 {
const BYTES_PER_GIB: u64 = 1024 * 1024 * 1024;
let system_gib = system_memory_bytes() / BYTES_PER_GIB;
if system_gib < 8 {
1024 * 2
} else if system_gib >= 24 {
1024 * 6
} else {
1024 * 4
}
}
// Gets maximum memory in KiB.
pub async fn get_max_memory() -> crate::Result<u64> {
Ok(system_memory_bytes() / 1024)
}