If you get a new gem and you don't have space for it in your inventory, there are three possible scenarios:

1. If the new gem is less valuable than any of your current gems, it will automatically be sold and you will receive gold instead.

2. If the new gem is more valuable than any of your current gems, the lesser gem will be sold, and the new gem will take its place.
 
3. If your totem is broken, it will still have a slot for your gem. So even if your inventory is full, you can still transfer the gem to your next totem!

You can also increase your inventory capacity by purchasing more gem slots.