Xcode is freezing

Xcode is freezing and closing the app. Because of Xcode sometimes my battery drains very fast and my Mac is getting hot. I went to apple and they said there is no hardware problem. They also said probably it is because of the app. I reinstall it but it did not change. Also my friend has the same problem. What can I do?

Xcode is freezing
 
 
Q