memscope_rs/query/
types.rs1use crate::snapshot::types::{ActiveAllocation, ThreadMemoryStats};
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub enum Query {
11 TopAllocationsBySize { limit: usize },
13 TopAllocationsByCount { limit: usize },
15 MemoryLeaks { min_age_ms: u64 },
17 LargeAllocations { min_size: usize },
19 ThreadMemoryStats { thread_id: u64 },
21 ScopeMemoryStats { scope_name: String },
23 TypeMemoryStats { type_name: String },
25 Summary,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
31pub enum QueryResult {
32 Allocations(AllocationQueryResult),
34 Threads(ThreadQueryResult),
36 Summary(SummaryQueryResult),
38 Empty,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct AllocationQueryResult {
45 pub count: usize,
47 pub total_bytes: usize,
49 pub allocations: Vec<ActiveAllocation>,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct ThreadQueryResult {
56 pub count: usize,
58 pub total_bytes: usize,
60 pub threads: Vec<ThreadMemoryStats>,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct SummaryQueryResult {
67 pub total_allocations: usize,
69 pub total_deallocations: usize,
71 pub active_allocations: usize,
73 pub total_allocated: usize,
75 pub total_deallocated: usize,
77 pub current_memory: usize,
79 pub peak_memory: usize,
81 pub thread_count: usize,
83}