Click here to Skip to main content
15,895,011 members
Home / Discussions / C#
   

C#

 
GeneralRe: Get external application name Pin
Martin#28-Aug-07 6:14
Martin#28-Aug-07 6:14 
QuestionModify the App.Config File at Run Time Pin
BhuMan27-Aug-07 21:48
BhuMan27-Aug-07 21:48 
Questionmemory exception Pin
arkiboys27-Aug-07 21:25
arkiboys27-Aug-07 21:25 
AnswerRe: memory exception Pin
Martin#27-Aug-07 22:25
Martin#27-Aug-07 22:25 
AnswerRe: memory exception Pin
Vasudevan Deepak Kumar27-Aug-07 22:28
Vasudevan Deepak Kumar27-Aug-07 22:28 
AnswerRe: memory exception Pin
Rudolf Jan28-Aug-07 9:05
Rudolf Jan28-Aug-07 9:05 
QuestionSorted List and Garbage Collector Pin
JoZ CaVaLLo27-Aug-07 21:14
JoZ CaVaLLo27-Aug-07 21:14 
AnswerRe: Sorted List and Garbage Collector Pin
Martin#27-Aug-07 22:20
Martin#27-Aug-07 22:20 
Hello,

JoZ CaVaLLo wrote:
and is concerned about the use of SortedLists because of memory performances.

This is what the documentation say:[^]
Operations on a SortedList object tend to be slower than operations on a Hashtable object because of the sorting. However, the SortedList offers more flexibility by allowing access to the values either through the associated keys or through the indexes.

JoZ CaVaLLo wrote:
Can somebody tell me when the Garbage Collector is called to clean sorted lists that are not used anymore?

No, the GC will clean up your object when he wants and is able to do so!
But, he is only able if there are no references left, which hold the instance of the sorted List.
Therefor you have to call the Dispose() method.
The Dispose method frees the instance from unmanaged resources.

If you are creating and using an instance of the SortedList inside of a method, I would suggest a "using"-block.
sample code:
private void YourMethod()
{
    using(SortedList yourSL = new SortedList())
    {
        yourSL.Add(....
    }
    //The dispose method will automatically be called at the end of the "using"-block
    //A "using"-block can be used for all classes, which implement "IDisposable".
}

If you have a SortedList instance as a member of a class, you should implement "IDisposable" in your class,
and dispose the instance of SortedList at the Dispose method of your class.
protected override void Dispose( bool disposing )
{
    if( disposing )
    {
        if(yourSL != null)
            yourSL.Dispose();
    }
    base.Dispose( disposing );
}


Additionaly:
Interesting disussion here on the forum![^]

How To Dispose by Joe Duff[^]

Implement IDisposable by Scott Dorman[^]


Hope it helps!

All the best,

Martin

GeneralRe: Sorted List and Garbage Collector Pin
Luc Pattyn28-Aug-07 0:54
sitebuilderLuc Pattyn28-Aug-07 0:54 
GeneralRe: Sorted List and Garbage Collector Pin
Martin#28-Aug-07 1:01
Martin#28-Aug-07 1:01 
AnswerRe: Sorted List and Garbage Collector Pin
Luc Pattyn28-Aug-07 0:59
sitebuilderLuc Pattyn28-Aug-07 0:59 
Questionpicture viewer?? Pin
jith - iii27-Aug-07 21:14
jith - iii27-Aug-07 21:14 
AnswerRe: picture viewer?? Pin
Christian Graus27-Aug-07 21:19
protectorChristian Graus27-Aug-07 21:19 
GeneralRe: picture viewer?? [modified] Pin
jith - iii27-Aug-07 22:07
jith - iii27-Aug-07 22:07 
AnswerRe: picture viewer?? Pin
Vasudevan Deepak Kumar27-Aug-07 22:50
Vasudevan Deepak Kumar27-Aug-07 22:50 
GeneralRe: picture viewer?? Pin
jith - iii27-Aug-07 23:54
jith - iii27-Aug-07 23:54 
AnswerGot solution............ Pin
jith - iii27-Aug-07 23:49
jith - iii27-Aug-07 23:49 
Questionneed a custom textbox... Pin
TheCardinal27-Aug-07 20:54
TheCardinal27-Aug-07 20:54 
AnswerRe: need a custom textbox... Pin
JoZ CaVaLLo27-Aug-07 21:17
JoZ CaVaLLo27-Aug-07 21:17 
Questioninternal and internal protected Pin
Sonia Gupta27-Aug-07 19:28
Sonia Gupta27-Aug-07 19:28 
AnswerRe: internal and internal protected Pin
NaNg1524127-Aug-07 19:45
NaNg1524127-Aug-07 19:45 
GeneralRe: internal and internal protected Pin
Sonia Gupta27-Aug-07 19:50
Sonia Gupta27-Aug-07 19:50 
GeneralRe: internal and internal protected Pin
NaNg1524127-Aug-07 19:59
NaNg1524127-Aug-07 19:59 
GeneralRe: internal and internal protected Pin
NaNg1524127-Aug-07 20:07
NaNg1524127-Aug-07 20:07 
AnswerRe: internal and internal protected Pin
Vikram A Punathambekar27-Aug-07 19:46
Vikram A Punathambekar27-Aug-07 19:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.