I think when you run headless the nano runs a separate configuration set-up. This “headless” configuration does not include GNOME or any other “desktop UI” resources.
As much as I love the nano, it’s no computer replacement. Any more than 4 web browsers open pretty much consumes all RAM to the point that you get memory warnings.
I’ve changed my swap to about 8GB but found that wasn’t helping much.
In any case, I’ve since moved to a “Headless” configuration. The only things I have plugged into the nano are the power supply (5V) and an ethernet cable.
I ssh and run jupyter lab on my nano for any projects. It’s frustrating at first, since most examples don’t run in Jupyter Lab as-is, or expect that you’re connected to a display, but I’m learing more and more each day. Eventually I’ll be able to run a deepstream project in Jupyter (I’m still a noob so I want to spend more time playing and less time developing).