System.String to be disposed or not

Use this forum to discuss subjects that don't belong in the other forums.

Moderator: SciTech Software

System.String to be disposed or not

Postby bhargava381 » Tue Jun 09, 2015 10:26 pm

Hi ,
I have been trying to dispose the strings .I was not sucessfull in doing so they are being introduced from RuntimePropertyInfo , Pinned GC Handle () and my 3rd party contol's which are poining to string.
In this below artcile from MSDN, it states to worry less about any string and array objects less than 85,000 bytes that is LOH.

[url](http://blogs.msdn.com/b/tess/archive/20 ... emory.aspx)[/url]

So my question now is , should we only worry about object greater than 85,000 bytes.If so, can we force the LOH to clear.As far as I know,Gen # 2 clean up triggers LOH to clean.


Regards,
Bhargav
bhargava381
 
Posts: 9
Joined: Thu Jun 04, 2015 8:44 pm

Re: System.String to be disposed or not

Postby Andreas Suurkuusk » Thu Jun 11, 2015 7:26 am

Strings and arrays may very well be part of a memory leak. but, as it says in the article, string and arrays are used by almost all parts of the .NET Framework and a .NET program. Therefore it is recommended that you focus on other types which can more easily be identified as potential memory leaks. If you for instance have a document type, and you have a new document instance after you open and close the document, then it's probably easier to focus on that single new instances than on maybe thousands of new string instances used by the document.

Instead of looking at string and array types, you can use Held bytes column in the Types list to identify types which use a lot of memory. If you have a document instance that are using a lot of strings, the held bytes value for the document type will include the size of all those string, even if there is only a single instance of the document. For more information about held bytes, see http://memprofiler.com/onlinedocs/helda ... tances.htm.
Best regards,

Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
 
Posts: 957
Joined: Wed Mar 02, 2005 7:53 pm
Location: Sweden


Return to General

Who is online

Users browsing this forum: Google [Bot] and 3 guests

SciTech Software logo

© Copyright 2001-2016. SciTech Software AB
All rights reserved.


SciTech Software AB
Kartvägen 21
SE-175 46 Järfälla
Sweden


E-mail: mail@scitech.se

Telephone: +46-706868081

cron