.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

CLR Inside Out: Memory Usage Auditing For .NET Applications

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Memory usage can have a direct impact on how fast an application executes and thus is important to optimize. In this article we discuss the basics of memory optimization for .NET programs.

Subramanian Ramaswamy and Vance Morrison

MSDN Magazine June 2009

View Complete Post

More Related Resource Links

Inside Microsoft patterns & practices: Building WPF and Silverlight Applications with a Single Code


This article discusses the Project Linker tool and other techniques to create applications that target both WPF and Silverlight from a single code base.

Erwin van der Valk

MSDN Magazine August 2009

CLR Inside Out: International Applications


The CLR team takes a look inside the System.Globalization namespace to explain how to handle data formats for proper localization and globalization.

Melitta Andersen

MSDN Magazine November 2008

CLR Inside Out: Investigating Memory Issues


Memory issues can manifest in a wide variety of ways. This column shows you how to collect the data you need to determine what types of mem¬ory issues you are experiencing.

Claudio Caldato and Maoni Stephens

MSDN Magazine November 2006

Design: Inspect and Optimize Your Program's Memory Usage with the .NET Profiler API


Developers using .NET often make memory leak tracking a low priority because the common language runtime takes care of garbage collection. What few developers realize, however, is that their objects' lifespans, along with their size and what other objects have been instantiated, all affect how they are cleaned up. Depending on the particular circumstances, these combinations can negatively affect performance, especially over the lifetime of an application. This article presents a way for developers to see memory usage and understand garbage collection using the .NET Profiler API. Along the way, a sample application to demonstrate these principles is built.

Jay Hilyard

MSDN Magazine January 2003

Form background images and memory usage

Hello everyone, please forgive me if this is the wrong forum for this post. I have written a Windows App in C#. It's a real small application (something like a widget) that stays on your desktop and shows pictures of a folder in a random sequence. Before showing another picture i use : this.BackgroundImage.Dispose(); so that i keep memory usage low. If i won't do that i can see memory rising (depends on the image size). Now the code i use to change the picture is : this.BackgroundImage = Image.FromFile(path, true); So my question is about this last line of code. Is this a good approach of changing the picture after a while? (this code runs in a loop) Should i care about memory usage? The form is a small one for this kind of app, so loading big and large pictures can have some issues i guess. I have been monitoring my app for some time , memory and cpu usage were really low but i would like to know another and better approach on this one if somoeone knows.  de_Stan

SQL 2005 (32-bit) cluster memory usage

We recently did an in-place upgrade of our cluster from SQL 2000 Enterprise to 2005 Enterprise.  We are seeing memory utilization on the server that is not expected and wanted to get an idea from others if this is normal.  Here is our setup:

32-bit Windows Server 2003 SP1
SQL 2005 SP2, 2-node cluster
16 GB memory on each node
/3GB /PAE switches in the boot.ini file
AWE Enabled, min memory=0, max memory=14000

The strange bit is that in the Task Manager the SQL service is showing as only using 205 MB of memory and the pagefile usage is at 13 GB.  This is troublesome since it looks like SQL is using virtual memory instead of physical memory.  We recently upgraded the memory from 4 GB to 16 GB, the sql cluster service account was added to the Lock Pages in Memory policy, the boot.ini switches were set and the AWE enabled/max_server_memory script was run before upgrading to 2005.  Can anyone confirm either 1) this is normal or 2) how to correct the memory usage?

I have also questioned using the /3GB switch; would it be better to remove that and set the max memory for SQL to 12000?

Any help would be greatly appreciated.  If I left off any information that would be helpful, please let me know.


SQL Server 2008 Memory Usage


We are using SQL Server 2008 x64 SP1 CU8 EE, and we have 32 GB of RAM on the server. We currently have the instance restricted to 14 GB of RAM, the "Lock Pages in Memory" security setting on the service account, and AWE enabled in SQL Server. This server is part of a 3 node active/active/passive cluster. My question is:


How do I know how much memory sql server is actually using, or if the server is under memory pressure? 

John M. Couch

sql server high memory usage


Hello Guys

just wondering how do you handle similar situation, we had a call from angry client saying they are unable to do anything and things take too long to complete. when i logged in i noticed that sql server taking all memory (6GB) for some reason. interestingly CPU usage is normal.

I know i can run profiler to see what queries are taking such huge memory before it happens but what if it already happened and you want to see whats currently eating all that memory ? thanks for the advise.

sql server is 2008 and our desktop app is C# 2008.


Memory usage per message.


I have a WCF web service and I want to find out a memory profile of the service per message. In other words I want to issue a message service request from a client and after the message is serviced and a response is received I want to find out (preferably from the client) how that message affected the memory footprint of the service. What tools are readily available? I am aware of several profiling tools from third parties but I want to know how I can integrate the information available through the Performance Monitor and Task Manager (for example) with the message processed to yield a profile of what each message does to the memory footprint. This could be used as a leak detection (if the memory after is more than the memory before then that message more than likely has a leak). If the memory statistic was available during the message processing it could be seen that message A consumes alot of peak memory whereas message B consumes relatively little. Ideas?

Thank you.


Struct Memory Usage - clarification


class Program

        static void Main(string[] args)
            var prg = new Program();

Auditing inside the tables



I want to configure audit in SQL server. But want the audit activities to be inside the tables. I take a look of auditing in SQL server but it will add the audit into a file or even logs. I want audits to be on each table. So I create in each table 4 fields like (Created-by, modified-by, created-date, modified-date). I want those fields to be field automatically based on the logged in user and not on the application level. Is this possible?


Your response is highly appreciated.

Configuring AWE and memory usage in SQL Server 2005

Dear Sirs,
I installed SQL Server 2005 Enterprise Edition (with SP3) on a server running Windows Server 2003 Enterprise Editon SP2 with 8GB RAM and with "Physical Address Extension".
I want the SQL Server 2005 makes use of memory that is in excess of 4 GB and will perform the following steps to accomplish this:

1) I'll add the SQL service account to the
policy "lock his pages in memory"

2) I'll include the /PAE switch in Boot.ini

3) I'll change the "awe enabled" with the following commands:

sp_configure 'show advanced options', 1
sp_configure 'awe enabled', 1

4) I'll change "min server memory" and "max server memory" with the following commands:

sp_configure 'min server memory', 1024
sp_configure 'max server memory', 8192

memory usage (consumption) of individual controls on a web form shown in a browser



Is there a way to check the memory usage (consumption) of individual controls on a web form shown in a browser. Like Repeater Control, Multiline Text box etc. The reason is I am putting the repeater control in session and checking the status of controls, based on which I am doing further actions.



SQL Server 2008 - High Memory Usage


Hi ,

  We are facing problem with the high memory usage with SQL Server 2008. 64 bit , standard edition sp2 . 8 GB RAM , 8 processors .

Memory usage keep on growing ..sometimes it will reach to 7.5 GB also .... and its not coming down ..untill we restart the service...

These are the details of DBCC MEMORYSTATUS :: Please suggest how to overcome this problem

Memory Manager                           KB
---------------------------------------- -----------
VM Reserved                              8484792
VM Committed                             4220368
Locked Pages Allocated                   0
Reserved Memory                          1024
Reserved Memory In Use      &n

SQL Server 2008 R2 on Windows Server 2008 R2 Memory Usage issues and not giving memory back


Okay so i have a physical server i am trying to replace with a virtual server. Its doing a large load process every night, about 190GB on one disk.

The VM is:

On vSphere 4.1 ESXi

O/S is Windows Server 2008 R2 Enterprise

SQL version is SQL Server 2008 R2 Enterprise.

4 vCpus

Now 20GB of memory

Disks assigned to this virtual are all seperate LUNs except for the O/S which is on a shared LUN which is not busy. So 1 LUN/Datastore per 'disk drive on this SQL virtual. Data/Log/TempDB/Backup are on their own LUNs.

All the recommended exclusions are in place for McAfee on a SQL Server.

ESXi 4.1 Enterprise host is not overcommitted. Has 4 x 6core 2.6Ghz AMD processors. BL685c G6 and 128GB of memory. Almost nothing else is running at the time i am testing this load and host is not overcommited or stressed or anywhere near it.

SQLServer process shows 127,236K Working Set and 130,040K Peak working set and memory Private working set 88,828k and Commit Size of 302,792k.

It seems when i check the memory usage in task manager it doesn't show much. In Windows 2003 X64 in would show the GB being used, like 8GB right in task manager. But i don't see that in Windows 2008 R2 task manager. I downloaded SysInternals and it shows the memory on the Windows 2008 r2 box as 15Gb of AWE memory. How can this be? The case is th

High memory usage by the SSMS.exe and no Running Query


Hi i am editing a stored procedure using the SSMS (I have SQL Server 2008 SP1 - Windows 2003 Server Standard). At the begining everything is ok, but around of 3 or 4 minutes of work the ssms is becoming to slow, I open the Task Manager and I see that the process SSMS.exe is using 1.2GB of RAM Memory. I have open just one script (The stored procedure that I'm editing) but the script isnt running only editing. I dont understand that high memory because i'm not retreiving data of any query and im not running any thing on my ssms. Take a look of my task manager http://i875.photobucket.com/albums/ab319/jacarmonaro/highMemory.jpg

Other thing: When I minimize the ssms window the smss.exe process come back to a normal RAM memory usage.

Please any help??



ASP.NET Server Memory usage



My name is Johnathan and I work as an asp.net web devoloper.

My company is starting to transfer from classic asp to asp.net 4.0 in our websites. During the transition I have encountred a few issues:

  1. It seems that asp.net uses a lot more memory then classic asp on the server that hosts the websites. Is that true, and if so how can I minimize the memory usage?
  2. Does asp.net 4 transitiond out of the beta phase? I have a website that is built in the asp.net 4.0 technology that is running smooth on the localhost, but on the server sometimes it doesn't connect to the database. Does this mean it is the host provider's fault or is it something in the code? (here is the website: http://www.sospets2.co.cc/)

Thanks alot and have a nice day!


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend