There are several things you can do here.
The first would be not to run a desktop on the Pi if that is what you are doing. Unless you have a Pi4 with loads of memory, the Pi's are generally fairly short on memory and a desktop takes up a LOT.
Secondly, you should check how you are running Node-RED. In the past, a parameter was passed max-old-space
which changes when Node.js performs its garbage collection. If you do have it, try removing it. If you don't have it, try adding it. For the old Pi's, we used to set it to 256
.
There are quite a few threads here in the forum about memory management. Here are a couple but you should use the search function as well.
Help - how can I reduce memory footprint of node-red - General - Node-RED Forum (nodered.org)
Analysing Memory Use - FAQs - Node-RED Forum (nodered.org)
There are also a few nodes that help with this:
node-red-contrib-gc (node) - Node-RED (nodered.org)
There may be others, please do a search in the Flows site.
Another thing that you can do is to remove any contributed nodes that you don't really need.
And then you should check your flows for anything that might be either loading a really large chunk of data or that might not be releasing data.