S.
06/16/2026, 3:48 PMwithScopedMemoryAllocator {} frees it up directly after executing the block so that doesn't work. Alternatively, is there a way to find out the memory address of a top level bytearray like private val sharedBuffer = ByteArray(4096) ?
I need to write a bytearray into memory and retrieve the pointer to return it back to the hostIgor Yakovlev
06/16/2026, 8:07 PMS.
06/16/2026, 8:37 PMwithScopedMemoryAllocator does work for my experiments, I guess freeing up doesn't mean being immediately overwritten.
withScopedMemoryAllocator {
val bytes = Cbor.encodeToByteArray(Memo("Wasm", 1))
val ptr = it.allocate(bytes.size)
bytes.forEachIndexed { index, byte ->
Pointer((ptr.address + index.toUInt())).storeByte(byte)
}
return pack(ptr.address, bytes.size)
}
I'm still a bit worried about inconsistency, I'm reading from memory that's already freed up.
There is also componentModelRealloc which is only freed up manually, but for this I would need an initial pointer.Igor Yakovlev
06/17/2026, 6:20 AMS.
06/17/2026, 12:46 PMCharlieTap
06/19/2026, 5:56 PMS.
06/21/2026, 3:48 PMUnresolved platforms: [wasmJs] with version 1.4.7 🤔CharlieTap
06/21/2026, 3:57 PMS.
06/21/2026, 4:14 PMCharlieTap
06/21/2026, 4:18 PM