дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
Opening a folder with many large Git repositories kept the backend at about 2.2 GB after indexing. redb's page caches (1 GiB default per database) are capped at 64 MiB for the symbol index and 32 MiB per repository commit log, and after a full scan the backend returns freed heap pages to the OS (malloc_zone_pressure_relief on macOS, malloc_trim on glibc). On 16 repositories / 152k files the footprint after a cold index dropped from 2226 MB to 1078 MB with unchanged index and log query times.
21 рядки
794 B
Rust
21 рядки
794 B
Rust
//! Returning freed heap pages to the OS.
|
|
|
|
/// Hands pages the allocator has freed but kept back to the OS. Call after a burst of
|
|
/// short-lived allocations (a full index scan); until then they still count towards the
|
|
/// process's memory footprint.
|
|
pub fn release_free_pages() {
|
|
#[cfg(target_os = "macos")]
|
|
{
|
|
unsafe extern "C" {
|
|
fn malloc_zone_pressure_relief(zone: *mut std::ffi::c_void, goal: usize) -> usize;
|
|
}
|
|
// SAFETY: a null zone covers every zone; a zero goal releases as much as possible.
|
|
unsafe { malloc_zone_pressure_relief(std::ptr::null_mut(), 0) };
|
|
}
|
|
#[cfg(all(target_os = "linux", target_env = "gnu"))]
|
|
// SAFETY: malloc_trim only returns free memory to the OS.
|
|
unsafe {
|
|
libc::malloc_trim(0);
|
|
}
|
|
}
|