Hello I have a very simple question about jco components. I have a simple wasm component compiled from the following js
export const handlerInterface = {
handleevent(event) {
return event;
}
};
using jco componentize handler.js --wit ../component.wit -d all -o handler.wasm
with the following wit
package test:test;
interface handler-interface {
record request {
uri: string
}
handleevent: func(event: request) -> request;
}
world handler-world {
export handler-interface;
}
I'm using wasmtime to call the handleevent guest function on the component in an infinite loop. It seems that RES memory of the process is constantly increasing over time. Is this expected with components compiled with jco? I don't see the same memory usage using cargo-component for example. Maybe it's expected with a javascript runtime and JIT or whatnot, but it would seem weird to me? Any help appreciated.
Small repro is here https://github.com/ludfjig/jco-vs-cargo-component-memory-usage
Hey Ludvig, thank you for the repro. No, this is not expected behavior. Unfortunately, StarlingMonkey hasn't been thoroughly tested for long-running use cases, so it's entirely possible that we have a memory leak somewhere. I would start by ensuring you're using the latest jco version, as there were some memory-related fixes in the most recent StarlingMonkey release, and I will have a look at your example to see if I'm able to track the leak.
To provide additional context: I would also say it's normal to see memory usage fluctuations in JS components due to garbage collection. The GC will allow memory to accumulate temporarily before triggering a collection that should eventually bring memory usage down, but FWIU what you're observing is linear increase until oom?
Thanks for the reply. Indeed memory increases linearly with no signs of stabilizing. I tried most recent jco version as well, but unfortunately I'm still seeing it
Hey @Ludvig Liljenberg would you mind filing an issue about this? The most appropriate place might be either componentize-js or StarlingMonkey , but I'd love to track this so that we can be sure it's fixed long-term.
I mention this because I originally thought this might be a case of this bug from Jco, but it doesn't seem to be, so I'm thinking we should make sure it's tracked.
This topic was moved here from #general > Continuous memory growth in jco component by fitzgen (he/him).
Thanks, I filed https://github.com/bytecodealliance/ComponentizeJS/issues/279
I think I found the issue! I've made a PR here https://github.com/bytecodealliance/ComponentizeJS/pull/295 @Victor Adossi @Tomasz Andrzejak
Great job @Ludvig Liljenberg !
Last updated: Dec 06 2025 at 06:05 UTC