Accidentally turned down SQL memory too low to log in, how do I fix?
Connect using the Dedicated Administrator Connection (DAC), which is guaranteed a minimal amount of resources in order to solve issues exactly like this one. For example, if you are connecting via Management Studio, launch a New Query window and just type ADMIN:servername instead of servername when it prompts you to connect. Ignore any errors you get which are usually benign as they are associated with Object Explorer, the database dropdown list, IntelliSense, etc. also trying to connect on your behalf (only one DAC connection is allowed).

More info here, here, and some troubleshooting here.