I’m using wasmWasi with wasmtime to run Kotlin/Was...
# webassembly
d
I’m using wasmWasi with wasmtime to run Kotlin/Wasm from within C++. Works great, mostly, but I have some questions and feedback about the Kotlin side. Where is the best place to get help? :) I feel like there aren’t too many people with this setup. :) Thanks!
here 2
Ok, well, one thing I’m noticing is that if I call println(“some text”) in a loop I get a “GC heap out of memory” error. Fairly sure that means there’s a memory leak in encodeToByteArray. Wanted to investigate that.
An even simpler way to reproduce the issue is this. GC will fill up and crash the app.
Copy code
for (i in 0..1000) {
  “some string”+i
}
l
I have never used this, so what I'm saying may be complete nonsense. But, could it be that the implementation doesn't GC until it exists the calling function?
What if you move the string concatenation into its own function?
Although, I just realised that if that was the case, then the
println
case would not exhibit this.
Does it happen with things other than strings?
d
Thanks for the suggestion! I just tried putting the for-loop in c++ and calling into Wasm 1000 times, which should allow GC to run. Unfortunately I also get the same heap error I’m only seeing this behavior with strings. For example, if I create 1000 ByteArrays and populate them, I don’t have any issues. You make a good point though, I’ll investigate with other class types and see what I can find.
l
That sure makes it sounds like a bug. Probably something worth reporting.
👍 1
d
That’s a good idea. I’ll report it. It may also be a bug in wasmtime because their GC support was just brought up recently. All of this is so new that it’s difficult to know for sure or find anyone who would know. 🙂