Are there any affordable (less than 300 dollars, for me) ultrasonic machines, that are big enough to clean a handgun?
I don't think so, depending on the size of the gun. I bought a cheap one from Harbor Freight, and have used it on small parts and the frame of a couple of revolvers. The whole frames could not be immersed at one time, but I just did both "halves". I'm not sure how long it will last, but my needs are very modest.
On small parts, it works great for me so far, getting gunk off that would have required substantial brushing, flushing and repeating; and for general degreasing. The parts come out warm, and I use a hair dryer to blow off the water and dry the parts.