There has been an issue with growing databases due to test data and test attachments not being deleted. I have an earlier blogpost ( also here) on how to fix this, using a tool called Test Attachment Cleaner, and also containing a set of scripts you can run on your server to check on how your database sizes.
In TFS 2015 update 1 this was fixed by building a data retention policy in to the TFS. This works both for on-premises and for VSTS instances.
The retention policy is off by default, but you can enable it by going to the Test tab on the admin page in the WEB UI.
Press (1) under to go to the admin page)
On the admin page, press 2 (Test tab) to get to the retention policy settings
You have two groups, one for automated tests and one for manual tests, which can be set independently.
The retention time is in days, and you can set any number of days, either by selecting from the predefined list, or just by editing in a number there, up to 10000 days. If that is not enough, then it is Never Delete.
Cleaning older databases
There is no option for cleaning an existing database, which can be handy if you are moving up some data from an earlier version, and there is a not of stuff there. What you do then is to set the retention policy to –1- day, and just wait that single day.