Home ASP .NET web application memory leaks - profiler shows a lot of strings
Reply: 0

ASP .NET web application memory leaks - profiler shows a lot of strings

user1877
1#
user1877 Published in May 22, 2018, 11:32 am

My web application constantly hits the IIS limitation set on the virtual memory allocated to the application pool. This causes IIS to stop the application.

I've been trying to identify possible memory leaks in my app using .NET memory profiler and so far the largest amount of memory retained after GC seems to be in strings. Even for accessing one page the memory usage grows quite a lot.

When I look into the strings stored I find duplicated strings like SQL queries used in SqlDataSource.SelectCommand

My website consists of a masterpage in which I have some user controls. In one of these user controls I use an SqlDataSource that does a simple select from the database like this:

<asp:SqlDataSource DataSourceMode="DataSet" CacheDuration="100" ID="myDataSource"
    runat="server" ProviderName="System.Data.Odbc" ConnectionString="<%$ ConnectionStrings:mysql %>"></asp:SqlDataSource>

In the control's Page_Load I have:

myDataSource.SelectCommand =
            "SELECT * from table limit 0,10";

The same string I can find duplicated in memory hundreds of times (probably each time the page is accessed).

Am I missing something? Do I have to dispose the data source manually?

thanks

UPDATE:

Turns out that a huge amount of strings (including the SQL queries) were kept in memory because I had a several custom user controls which apparently use by default EnableViewState="true"

After setting EnableViewState="false" for these controls (I did not need it) and the strings are not longer filling up the memory

UPDATE 1:

After setting EnableViewState="false" in production the application pool no longer hits the virtual memory limitation, so PROBLEM SOLVED!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.369945 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO