#How can I debug the memory usage of my code?
1 messages · Page 1 of 1 (latest)
I'm running my program in a docker container in production. I would like to debug memory usage in prod.
require(“bun:jsc”).heapStats() will give you an object with a bunch of data about what’s in the heap
You can also use the —smol flag to use a smaller heap
You can use process.memoryUsage() to get the current memory usage
I have seen this, but it's unclear to me how to associate this data with a problem in my code
apart from the object type count which can lead me in the right direction
You can use bun —inspect and then get a heap profile
And then it will show you a graph of why various objects exist in memory
To be clear I think it’s kind of not great right now
We really need some kind of monitoring thing
okay looking into this a bit more, it seems to be that intentionally unhandled promises are staying in memory including their context. seems like a bun issue as i can't reproduce with the exact same code in node