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


Top 5 Contributors of the Month
Kaviya Balasubramanian
Imran Ghani
Post New Web Links

Speed issues with ReaderWriterLockSlim and Garbage Collection

Posted By:      Posted Date: October 17, 2010    Points: 0   Category :.NET Framework
 

I have an example piece of code the illustrates issues in my code when GC.Collect is carried out on a class having a ReaderWriterLockSlim member variable. The GC.Collect takes between 2 and 3 seconds to run. I need to carry out GC at regular intervals because my applicaton is extremely memory intensive.

namespace WpfApplication12

{

 public class DataItem

 {

  private readonly ReaderWriterLockSlim m_propertyLock = new ReaderWriterLockSlim();



  public DataItem()

  {

  }

 }



 /// <summary>

 /// Interaction logic for Window1.xaml

 /// </summary>

 public partial class Window1 : Window

 {

  public Window1()

  {

   InitializeComponent();



   List<DataItem> dataItemList = new List<DataItem>();

   
                                     
                                            
                                        

View Complete Post


More Related Resource Links

Garbage Collection-Part 2: Automatic Memory Management in the Microsoft .NET Framework

  

The first part of this two-part article explained how the garbage collection algorithm works, how resources can clean up properly when the garbage collector decides to free a resource's memory, and how to force an object to clean up when it is freed. The conclusion of this series explains strong and weak object references that help to manage memory for large objects, as well as object generations and how they improve performance. In addition, the use of methods and properties for controlling garbage collection, resources for monitoring collection performance, and garbage collection for multithreaded applications are covered.

Jeffrey Richter

MSDN Magazine December 2000


Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework

  

Garbage collection in the Microsoft .NET common language runtime environment completely absolves the developer from tracking memory usage and knowing when to free memory. However, you'll want to understand how it works. Part 1 of this two-part article on .NET garbage collection explains how resources are allocated and managed, then gives a detailed step-by-step description of how the garbage collection algorithm works. Also discussed are the way resources can clean up properly when the garbage collector decides to free a resource's memory and how to force an object to clean up when it is freed.

Jeffrey Richter

MSDN Magazine November 2000


EventListeners and Garbage Collection

  

If I have a collection of objects that all have a PropertyChanged event (they implement INotifyPropertyChanged).  If I add a listener to the PropertyChanged events for all the objects in that collection, but start removing those objects will I create a memory leak, by not deattaching the listener before removing the object?  I.e. will I prevent garbage collection from happening for those objects or the listeners?


Garbage Collection

  
I have some understanding of Garbage collection but need some more clarifications. Which all are unmanaged and managed resources? Is database connection an unmanaged resource, if I open a database connection would I be creating an unmanaged resource. What is the difference b.w finalize and dispose. Do I have to call dispose for both managed and unmanaged resources or finalize method for umanaged resources. Setting objects = null, does that mean it clears out the memory allocated to them.   Thanks.

Long running WPF application - Garbage Collection

  
Hi All, I have a long running WPF application; users start the application and keep it open for at least 6 hours straight. I spend a couple days with a Memory Profiler, solving a couple of memory leaks. According to the Memory Profiler, all is good now. However, when I run the application, and monitor the Memory in the Windows Task Manager, it only seems to grow. When I create a button to force the garbage collection (GC.Collect()), a lot of memory is freed from the app. My questions: 1. I don't feel like it's a good idea to call GC.Collect() explicitly; is there any case where it is advised to do so? 2. Is it normal that it takes WPF that long to start garbage collecting automatically? Thanks, Koen

SQL Server 2008 R2 Analysis Services - Syncronization Speed Issues

  

We are experiencing a severe performance issue when syncronizing cubes using R2. We have 2 sets of machines that we are experiencing varied performance and speed when syncronizing cubes.

Test Server Pair 1
---------------------------------- 
Dell R710, 72GB Ram, 2 drives in Raid 1 (OS), 4 drives in Raid 10 (Cube and DB Storage) - This is the source server
Dell R900, 256GB Ram, 2 Drives in Raid 1 (OS), 3 Drives in Raid 5 (Cubes & Storage) - Server recieving sync updates

These servers are running Windows 2008 R2 Enterprise and SQL Server 2008 SP1 CU9 Enterprise (64bit). The performance of the cube syncronization is slow but manageable.

Test Server Pair 2
---------------------------------- 
Dell R710, 96GB Ram, 2 drives in Raid 1 (OS), 4 drives in Raid 10 (Cube and DB Storage) - This is the source server
Dell R910, 256GB Ram, 2 Drives in Raid 1 (OS), 14 Drives in Raid 10 (Cubes & Storage) - Server recieving sync updates

These servers are running Windows 2008 R2 Enterprise and SQL Server 2008 R2 CU2 Enterprise (64bit). This pair of servers running SQL 2008 R2 syncronize very slowly.  The process about 70-80 percent slower than the first pair. Our cubes that we syncronize are very large in size (some are 500-800GB in size) and for that reason con

Garbage collection in this example, true or false?

  

when using this code:  

string s;
s = "wombat";
s += " kangaroo";
s += " wallaby";
s += " koala";
Console.WriteLine(s);

 

they tell me: only the last string has a reference, the other three will be disposed of during garbage collection.

 

So what does this mean exactly?

string s got only the reference of "koala"? or a reference to "wombat"??

 

thanx


disable Garbage Collection

  

Plz make me suggestion:

I want to implement logic to garbage collector using c#.net. i.e. want to code to do GC in my own logic. So my Questions are:

1. Where should i write code to do it?

2. If it is c#.Net. how do i disable or restrict .Net Framework to auto collect garbage?

 

Please advice me for above question.


IE 8 Issues with Chinese/Japanese Characters

  

On my web application, I display information in different languages. Everything works fine in IE compatibility mode and FireFox but it shows boxes for chinese/japanese languages. I am pretty much having the same issue as described here

 

http://tuts9.com/questions/22344/japanese-characters-are-not-displaying-correctly-in-ie-8-not-sure-about-earlier-versions

Thanks for your help.


The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

  

Hey guys


I came across this bug using while trying to implement a sitemap




Line 147:						Panel panel = new Panel();
Line 148:						panel.Controls.Add(_viewState);
Line 149:						Page.Form.Controls.Add(panel);
Line 150:						string script = "document.getElementById('" + _viewState.ClientID + "').value = GetViewState__AspNetTreeView('" + Extender.MakeChildId("UL") + "');";
Line 151:						Page.ClientScript.RegisterOnSubmitStatement(typeof(TreeViewAdapter), _viewState.ClientID, script);


[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +8696951
   CSSFriendly.TreeViewAdapter.SaveAdapterViewState() in E:\wwwroot\ThirdParty\CSSFriendly\CSSFriendly_24242\CSSFriendly\TreeViewAdapter.cs:149
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +8901848
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.

Speed SQL: Tuning Your Database Calls with Tier Interaction Profiling

  

Tier interaction profiling (TIP) is a feature of the Visual Studio profiling tools that measures the duration of synchronous calls to ADO.NET-compliant data stores. We'll show you how TIP works and provide some best practices for using TIP to diagnose performance problems in your apps.

Mark Friedman

MSDN Magazine August 2010


CLR Inside Out: Profiling the .NET Garbage-Collected Heap

  

In this article, the authors complete the picture for Garbage Collected (GC) heap related memory issues by providing step-by-step instructions on using the CLR Profiler for .NET GC heap memory investigations.

Subramanian Ramaswamy, Vance Morrison

MSDN Magazine October 2009


Basic Instincts: Collection and Array Initializers In Visual Basic 2010

  

Collection Initializers are a great addition to the language and allows concise syntax in order to initialize both framework and user defined collection types.

Spotty Bowles

MSDN Magazine October 2009


Concurrency: Tools And Techniques to Identify Concurrency Issues

  

Efficient parallel applications aren't born by merely running an old app on a parallel processor machine. Tuning needs to be done if you're to gain maximum benefit.

Rahul V. Patil and Boby George

MSDN Magazine June 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


Categories: 
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