diff --git a/site/dashboard.html b/site/dashboard.html
index e75b7f6..ffc6e0d 100644
--- a/site/dashboard.html
+++ b/site/dashboard.html
@@ -814,15 +814,15 @@ function renderMemory(mem, stats) {
if (!mem) return;
// Stat card
- document.getElementById('memoryRss').textContent = formatBytes(mem.process_rss_bytes);
+ document.getElementById('memoryRss').textContent = formatBytes(mem.process_memory_bytes);
document.getElementById('memorySub').textContent = 'est. ' + formatBytes(mem.total_estimated_bytes);
const entryCounts = {
- cache: mem.cache_entries,
- blocklist: mem.blocklist_entries,
+ cache: stats.cache.entries,
+ blocklist: stats.blocking.domains_loaded,
query_log: mem.query_log_entries,
srtt: mem.srtt_entries,
- overrides: mem.overrides_entries,
+ overrides: stats.overrides.active,
};
// Sidebar panel
@@ -852,7 +852,7 @@ function renderMemory(mem, stats) {
${rows}
`;
}
diff --git a/src/api.rs b/src/api.rs
index f3f7b37..1a6b7ef 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -214,17 +214,14 @@ struct BlockingStatsResponse {
#[derive(Serialize)]
struct MemoryStats {
cache_bytes: usize,
- cache_entries: usize,
blocklist_bytes: usize,
- blocklist_entries: usize,
query_log_bytes: usize,
query_log_entries: usize,
srtt_bytes: usize,
srtt_entries: usize,
overrides_bytes: usize,
- overrides_entries: usize,
total_estimated_bytes: usize,
- process_rss_bytes: usize,
+ process_memory_bytes: usize,
}
#[derive(Serialize)]
@@ -556,17 +553,14 @@ async fn stats(State(ctx): State>) -> Json {
},
memory: MemoryStats {
cache_bytes,
- cache_entries: cache_len,
blocklist_bytes,
- blocklist_entries: bl_stats.domains_loaded,
query_log_bytes,
query_log_entries,
srtt_bytes,
srtt_entries,
overrides_bytes,
- overrides_entries: override_count,
total_estimated_bytes: total_estimated,
- process_rss_bytes: crate::stats::process_rss_bytes(),
+ process_memory_bytes: crate::stats::process_memory_bytes(),
},
})
}
diff --git a/src/blocklist.rs b/src/blocklist.rs
index 0a7db4d..e5caa99 100644
--- a/src/blocklist.rs
+++ b/src/blocklist.rs
@@ -184,7 +184,6 @@ impl BlocklistStore {
}
pub fn heap_bytes(&self) -> usize {
- // HashSet stores (hash, String) per slot + 1 control byte
let per_slot_overhead = std::mem::size_of::() + std::mem::size_of::() + 1;
let domains_table = self.domains.capacity() * per_slot_overhead;
let domains_heap: usize = self.domains.iter().map(|d| d.capacity()).sum();
diff --git a/src/cache.rs b/src/cache.rs
index a329d53..d9a2a76 100644
--- a/src/cache.rs
+++ b/src/cache.rs
@@ -143,7 +143,6 @@ impl DnsCache {
}
pub fn heap_bytes(&self) -> usize {
- // Outer HashMap: (hash, String, HashMap) per slot + control byte
let outer_slot = std::mem::size_of::()
+ std::mem::size_of::()
+ std::mem::size_of::>()
@@ -151,7 +150,6 @@ impl DnsCache {
let mut total = self.entries.capacity() * outer_slot;
for (domain, type_map) in &self.entries {
total += domain.capacity();
- // Inner HashMap: (hash, QueryType, CacheEntry) per slot + control byte
let inner_slot = std::mem::size_of::()
+ std::mem::size_of::()
+ std::mem::size_of::()
diff --git a/src/override_store.rs b/src/override_store.rs
index 96e0179..9b8a3f4 100644
--- a/src/override_store.rs
+++ b/src/override_store.rs
@@ -118,7 +118,6 @@ impl OverrideStore {
}
pub fn heap_bytes(&self) -> usize {
- // HashMap: (hash, String, OverrideEntry) per slot + control byte
let per_slot = std::mem::size_of::()
+ std::mem::size_of::()
+ std::mem::size_of::()
diff --git a/src/srtt.rs b/src/srtt.rs
index bf02055..bfad115 100644
--- a/src/srtt.rs
+++ b/src/srtt.rs
@@ -101,7 +101,6 @@ impl SrttCache {
}
pub fn heap_bytes(&self) -> usize {
- // HashMap stores (hash, key, value) per slot + 1 control byte
let per_slot = std::mem::size_of::()
+ std::mem::size_of::()
+ std::mem::size_of::()
diff --git a/src/stats.rs b/src/stats.rs
index 32739cc..c1a176f 100644
--- a/src/stats.rs
+++ b/src/stats.rs
@@ -1,7 +1,8 @@
use std::time::Instant;
-/// Returns the process resident set size in bytes, or 0 if unavailable.
-pub fn process_rss_bytes() -> usize {
+/// Returns the process memory footprint in bytes, or 0 if unavailable.
+/// macOS: phys_footprint (matches Activity Monitor). Linux: RSS from /proc/self/statm.
+pub fn process_memory_bytes() -> usize {
#[cfg(target_os = "macos")]
{
macos_rss()