Hi, welcome to the forum.
I know, but really does smell like an uncontrolled loop (or recursion)
There are many threads on the forum for this topic: Search results for '"JavaScript heap out of memory" order:latest' - Node-RED Forum
This one was a little different.
which was resolved like this:
we do add --max_old_space_size=512. What that means is when this heap fills up, Node.js needs to perform a garbage collection (GC) cycle. Coupled with your comment about "now not able to modify flows" (my mind reads "you have recently modified flows" ) from that, I dont think it is a stretch to conclude something has changed and the GC is now unable able to keep up with memory allocations.
Are you able to try something out? If possible, edit the file lib/launcher.js in your device agent installation and change the line to something like '--max_old_space_size=1024' (or remove it altogether)
Where you set max_old_space_size will depend on how you are running node-red (do a search)
but the 100% CPU spike really really smells like a hard, blocking loop - so perhaps a buggy contrib? or some recursive (self calling) function node code? or an invisible loop caused by link nodes or MQTT?