blob: aed995ee37d9b1d9e0239f887dc9fb12d584d809 [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.memory;
using fuchsia.memorypressure;
using zx;
/// Interface used to register for memory notifications.
@discoverable
protocol Monitor {
Watch(resource struct {
watcher client_end:Watcher;
});
// Writes to `socket` a JSON capture as a well-formed UTF-8 string.
WriteJsonCapture(resource struct {
socket zx.handle:<SOCKET, zx.rights.WRITE | zx.rights.WAIT>;
});
};
type Stats = struct {
/// The total amount of physical memory available to the system.
total_bytes uint64;
/// The amount of unallocated memory.
free_bytes uint64;
/// The amount of memory reserved by and mapped into the kernel for reasons
/// not covered by other fields in this struct. Typically for readonly data
/// like the ram disk and kernel image, and for early-boot dynamic memory.
wired_bytes uint64;
/// The amount of memory allocated to the kernel heap.
total_heap_bytes uint64;
/// The portion of `total_heap_bytes` that is not in use.
free_heap_bytes uint64;
/// The amount of memory committed to VMOs, both kernel and user.
/// A superset of all userspace memory.
/// Does not include certain VMOs that fall under `wired_bytes`.
vmo_bytes uint64;
/// The amount of memory used for architecture-specific MMU metadata
/// like page tables.
mmu_overhead_bytes uint64;
/// The amount of memory in use by IPC.
ipc_bytes uint64;
/// Non-free memory that isn't accounted for in any other field.
other_bytes uint64;
};
/// A watcher for memory changes
protocol Watcher {
OnChange(struct {
stats Stats;
});
};
/// Interface used to debug the singleton memory_monitor instance.
@discoverable
protocol Debugger {
/// Signals registered watchers of the fuchsia.memorypressure service with
/// the specified memory pressure level. Intended for debugging only. Does
/// not affect the real memory pressure level on the system, or trigger any
/// kernel memory reclamation tasks.
SignalMemoryPressure(struct {
level fuchsia.memorypressure.Level;
});
};