.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

Releasing memory for vm purposes

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :

Other than faking memory pressure to get sql to release memory, is there any other way to quickly release memory?


My issue is I do large imports every few nights.  This spikes my memory, but once the import is complete, I no longer need immediate access to that table, so I can release the memory.  However there's no way for sql server to do that apparently other than having the os pressure it to release it by temporarily running another memory consuming process.


I know what you'll say, if the os doesn't need it, why release it?  Because I have multiple virtual machines working with a set memory pool size.  If I have one box taking up 16gb of my pool, the other machines will suffer, and that one machine will have no idea that it needs to release the memory, even if it is not actively using it.

View Complete Post

More Related Resource Links

SQL Server not releasing memory back!

Hi Guys,   I have done enough research on this topic and understood that SQL Server loves to cache as much memory as it can get hold of , but did not find a straight forward answer to my problem.   To explain things in detail, We are currently using SQL Server 2005 (64 Bit) on Windows 2003 (64 Bit) with 32 GB of RAM. This morning when I checked, it was showing the memory as 1GB RAM.  As soon as I stopped and restarted SQL Sever, I got back all 31GB of it! This is a live mirrored server, and the data is exposed through a .NET Win Application. Also, this is a dedicated SQL Server.   The min and max memory of the SQL Server is set at 16 and 2147483647 respectively.   My questions: 1. What can be done to make SQL Server release the memory back once the process is complete?   2. If this involves setting a limit to the max memory of the SQL Server, what can it be set to? And does setting the max memory low affect the performance of server?   3. I have other servers that are not dedicated SQL Servers which are showing the same 'memory' related problems, what should be the max memory setting on these ?   Any help in this regard is deeply appreciated.   Little_Birdie.

Not Releasing memory in sql server 2008 R2

HI I have a server with 8 Gb Ram I installed Sql server 2008 R2 Enterprise Edition on 64 bit platform Enterprise edition,in that for Sql server I allocated 6 GB of Ram I enable the AWE oprtion as well but in processing time it taking above 6 Gb ram like 7.gb or more after query completing its not release the memory how can I resolve this issue. Actually when we running quries it taking the memory and memory increasing gradually after executing the query its not releasing the memory per example I set maximum 6 GB per Sql server then I run the query memory will increase gradually like 3.4 gb,3.7 gb, 4.5gb,and so on it will reach 7.56gb then after it steadily over there not come to down I am using X64 bit windows server 2008 sql server 2008 R2. My system configuration is sql server 2008R2(10.0.3798) windows server 2008 X64 Ram is 8GB

How to detect and avoid memory and resources leaks in .NET application

Despite what a lot of people believe, it's easy to introduce memory and resources leaks in .NET applications. The Garbage Collector, or GC for close friends, is not a magician who would completely relieve you from taking care of your memory and resources consumption.

I'll explain in this article why memory leaks exist in .NET and how to avoid them. Don't worry, I won't focus here on the inner workings of the garbage collector and other advanced characteristics of memory and resources management in .NET.

file upload in chunks or not buffering in memory before writing to disk?


What are the options for handling file uploads to reduce the memory footprint?  Is there a way to upload in chunks?  Is there a way to stream upload directly to disk instead of loading entire file in server memory?


Visual Studio 2008 Memory problems


My memory in task manager reaches about 900,000K  and I don't know why it does this. Definately slows everything down, especially when I rebuild my tableAdapters, takes about 30 seconds sometimes to rebuild the project.

Any plans on releasing the source code for WebMatrix itself?


I tried reflecting into WebMatrix.exe but was unable.  I'm interested on how you integrated the WPF Ribbon & the Office-style sidebar.

Crystal Report gives System.AccessViolationException: Attempted to read or write protected memory. T


when a crystal report for same id is opened again at same time or refreshed then it gives the

"System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stack Trace is :-

Stack Trace:

[AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetConnectionInfos(ConnectionInfos ConnectionInfos) +0
CrystalDecisions.CrystalReports.Engine.Table.ApplyLogOnInfo(TableLogOnInfo logonInfo) +362
CrystalDecisions.CrystalReports.Engine.ReportDocument.SetTableLogon(Tables tables, String user, String password, String server, String database, Boolean ignoreCase) +258
CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDatabaseLogon(String user, String password, String server, String database, Boolean ignoreCase) +204

Maximum memory for string ? . System.MemoryOutOfException Occurs when reading the Content of the fil



I have a C++ code which reads a file [vtk file - its similar to text file only]. and try to store it in string.

here's the code:

String^ ParallelProjectionRenderer::GetVolumeDataAsString(String^ FileName)

    vtkSmartPointer<vtkDataSetWriter> sWriter = vtkSmartPointer<vtkDataSetWriter>::New();

    String^ FileName = "D:\\Users\\...";

    char * sptName = static_cast<char *>(Marshal::StringToHGlobalAnsi(FileName).ToPointer());







    String^ result= File::ReadAllText(FileName);   [it breaks here with system.memoryoutofexception when the file size is huge]

    return result;


this code executes fine when the file size is less than 8mb.

I wanted to know whats the maximum memory allocated to the string.

As a workaround i skipped reading out in C++ code. and i tried to read the file contents in asp.net C# code and stor

Tools for memory error check in VS2005


Dear all,

I am going to write vs2005 program with ASP.NET and C++.

As you know that C++ will involve a lot of memory error handling.

Do you know is there any tools for checking memory error in Code Behind C++??

CLR Inside Out: Memory Usage Auditing For .NET Applications


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

Debug Leaky Apps: Identify And Prevent Memory Leaks In Managed Code


When is the .NET Garbage Collector unable to reclaim memory? The answer might surprise you. Stay tuned.

James Kovacs

MSDN Magazine January 2007

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

{ End Bracket }: Transactions for Memory


Injecting parallelism into your app is easy-managed code offers things like explicit threading and a thread pool for that. Ensuring your code remains correct when run in parallel, on the other hand, is not quite so simple.

Joe Duffy

MSDN Magazine January 2006

Memory Models: Understand the Impact of Low-Lock Techniques in Multithreaded Apps


Because the use of low-lock techniques in your application significantly increases the likelihood of introducing hard-to-find bugs, it is best to use them only when absolutely necessary. Here Vance Morrison demonstrates the limitations and subtleties low-lock techniques so that if you are forced to use them you have a better chance of using them correctly.

Vance Morrison

MSDN Magazine October 2005

Memory Lane: Rediscover the Lost Art of Memory Optimization in Your Managed Code


Managed applications rely on the garbage collector in the .NET Framework to allocate and clean up memory. The little CPU time spent performing garbage collection (GC) is usually a fair trade-off for not having to worry about memory management. But for applications in which CPU time and memory are precious resources, minimizing the time spent garbage collecting can greatly improve application performance and robustness. Find out how to manage memory all over again.

Erik Brown

MSDN Magazine January 2005

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