To add to the already great answers from Trevor and Emma, I'd state the way Kentico is setup by default it will work very well and not use a lot of memory or grow exponentially like you're explaining. Instances in which I've seen high memory usage is where there is a lot of custom development NOT using the Kentico API or not using it correctly.
So if you are saying you have a lot of custom code and you're using the CMS.ConnectionHelper.GetConnection()
method, then I'm willing to bet none of that custom code is utilizing any of the OOTB API tools. Typically when a developer is using GetConnection()
it's because they don't know how to take advantage of the API and simply call a SQL query.
The GetConnection()
method should automatically close the connection, so no worries about that. What's more concerning is for each page load this code is being run and none of it is being cached. So without seeing the code itself I'm willing to bet you have a lot of bad code causing your memory issues.
As Emma stated turn on debugging and check out what is going on there as well.