I’m linking another thread here. The user had a very similar experience to yours. I’ve listed all the steps here. Try those suggestions that might solve your problem.
You don’t have a swap partition/file. The creator of the post I linked also had vscode and it was eating his memory.
Please try the suggestion in that thread and see if your problem gets solved.