1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crateMemorySize;
use memory_size as wasm_memory_size;
use ;
/// Returns the current memory usage of the WebAssembly module.
///
/// This function calculates the memory size allocated for both the heap and the stable storage
/// by querying the WebAssembly system interface and the Internet Computer's stable storage API.
///
/// # Returns
/// A `MemorySize` struct containing two fields:
/// - `heap`: The total size of the WebAssembly module's heap memory in bytes.
/// - `stable`: The total size of the stable storage used by the module in bytes.
///
/// Both sizes are calculated based on the WebAssembly page size.
///
/// # Example
/// ```
/// let memory_usage = junobuild_shared::segments::utils::memory_size();
/// println!("Heap size: {} bytes", memory_usage.heap);
/// println!("Stable storage size: {} bytes", memory_usage.stable);
/// ```
///
// For cargo test only