-
-
Save alexeychirkov/bd8a7afe8d4c85e3858efc59e07d5be7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Array "mo:base/Array"; | |
import Iter "mo:base/Iter"; | |
import Nat64 "mo:base/Nat64"; | |
import Prim "mo:prim"; | |
actor { | |
type CanisterMemoryInfo = { | |
rts_version : Text; | |
rts_memory_size: Nat; | |
rts_heap_size: Nat; | |
rts_total_allocation: Nat; | |
rts_reclaimed : Nat; | |
rts_max_live_size : Nat; | |
}; | |
let initialSize = 1_000_000; | |
var store: [var Nat64] = Array.init<Nat64>(initialSize, 0); | |
public query func getSize() : async Nat { | |
store.size() | |
}; | |
public query func getCanisterMemoryInfo() : async CanisterMemoryInfo { | |
return { | |
rts_version = Prim.rts_version(); | |
rts_memory_size = Prim.rts_memory_size(); | |
rts_heap_size = Prim.rts_heap_size(); | |
rts_total_allocation = Prim.rts_total_allocation(); | |
rts_reclaimed = Prim.rts_reclaimed(); | |
rts_max_live_size = Prim.rts_max_live_size(); | |
}; | |
}; | |
public func destroyArray() : async (Nat, CanisterMemoryInfo) { | |
store := Array.thaw([]); | |
(store.size(), await getCanisterMemoryInfo()) | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment