Screen recording: profiling an F# app in VS Code with SharpLsp, from hot pipeline stages and closures to F# records and union cases leaking from a module value, and a verified fix
Transcript
This is FsStorefront, an F# app that's running right now. Let's find out where its time goes.
Stop the profiler, and every hot line of F# lights up: the catalog parsing, the basket shuffle, and the discount fold.
The results keep the names the F# compiler gives your code. Every closure and pipeline stage is named after its line, so you know exactly where to look.
Now let's track memory on the same app. SharpLsp snapshots the heap every ten seconds.
F# records and union cases show up as leak suspects. Click one, and you jump straight to the line that builds it.
So, what's keeping them alive?
A module value called sessions, named just as you wrote it. It holds every session the app has ever seen.
The fix: keep the last thousand sessions, and let the rest go.
Rebuild, run it again, and track memory.
This time the heap holds steady, and nothing climbs past Low. That's F# profiling in SharpLsp. Free, and open source.