Yosemite auto creates multiple desktops (spaces) on main monitor Since upgrading to Yosemite I've been having issue with OS X creating additional desktops on my main monitor for no apparent reason. I usually have 3 different desktops setup on my main monitor and just one on my second monitor. By the end of the day, OS X will usually have created 2-3 extra desktops automatically.

I can't find any setting or shortcut that might be causing this to happen. There also doesn't seem to be any reason for it since it can happen as soon as I boot up my computer.

Is there a way to set a maximum number of desktops so I can prevent this from happening?

Image from related question - Why does Mac Yosemite open dozens and dozens of empty desktops?
It has to do with the 'separate space' feature for external displays Apple introduced in OS X 10.10 Yosemite: If the setting "Displays have separate Spaces" in System Preferences -> Mission Control is activated (see https://support.apple.com/kb/PH18809?locale=en_US), every time you hook up a display a new space will be created for that display. After you pull the plug, OS X will not delete that created space, hence accumulating lots of spaces over time.

If you don't activate the option, you're external display will behave like before 10.10: only one menu bar on the main screen etc.