mm, right. crypto is indeed WASM - either libolm (which is only 150KB of WASM) or vodozemac (our new rust impl, which is 5.5MB of WASM unstripped). Neither use much heap though - probably only a few 100KB.
The main heap management trick for matrix-js-sdk would be to turn on (experimental) sliding sync mode, which means that it only syncs the rooms it cares about - so O(1) with number of rooms, rather than O(N). However, i'm guessing you probably weren't testing with a large account?
Oh I was definitely testing with a large account and I was also using sliding sync. It doesn’t matter though. I moved on to the rust sdk with this project and it’s awesome :)