Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
AnswerRe: help!! question Pin
OriginalGriff9-May-14 8:02
mveOriginalGriff9-May-14 8:02 
AnswerRe: help!! question Pin
Gerry Schmitz9-May-14 12:16
mveGerry Schmitz9-May-14 12:16 
Questionc# console application sharing variables with visual basic Pin
Papatrexas9-May-14 2:36
Papatrexas9-May-14 2:36 
AnswerRe: c# console application sharing variables with visual basic Pin
Rob Philpott9-May-14 3:35
Rob Philpott9-May-14 3:35 
AnswerRe: c# console application sharing variables with visual basic Pin
Wayne Gaylard9-May-14 3:36
professionalWayne Gaylard9-May-14 3:36 
Questionin the same class we are having two methods like method Add() and Static Method Sub() here...? Can i Cal Static method Sub() from non static method Add() Pin
balaramanN9-May-14 0:08
balaramanN9-May-14 0:08 
AnswerRe: in the same class we are having two methods like method Add() and Static Method Sub() here...? Can i Cal Static method Sub() from non static method Add() Pin
Richard MacCutchan9-May-14 0:25
mveRichard MacCutchan9-May-14 0:25 
QuestionImplementing IDisposable Pin
Gilbert Consellado8-May-14 22:58
professionalGilbert Consellado8-May-14 22:58 
some of my classes implementing IDisposable, then it came up in my mind to test how the IDisposable works.

so i try this.

C#
public class cc : IDisposable
        {
            bool isDisposed;
            int[] sampleData;

            public cc()
            {
                sampleData = new int[50000000];
            }

            ~cc()
            {
                Dispose(false);
            }

            public void Dispose()
            {
                Dispose(true);
                GC.SuppressFinalize(this);
            }

            public void Dispose(bool isDisposing)
            {
                if (!isDisposed)
                {
                    if (isDisposing)
                    {
                        sampleData = null;
                    }
                }

                isDisposed = true;
            }

            public void smp()
            {
                for (int i = 0; i < 50000000; i++)
                {
                    sampleData[i] = i;
                }

                System.Threading.Thread.Sleep(20000);
                Console.WriteLine("middle");
                Console.ReadLine();
            }

            public void s2()
            {
                int[] ssss = new int[50000000];
                for (int i = 0; i < 50000000; i++)
                {
                    ssss[i] = i;
                }
            }
        }



now creating the object and calling the smp() method, the program memory consumption increase about 100mb to 150mb then after the object was disposed, i was expecting that it will the memory it will consumed but even i leaved the program open for several minutes, still it doesn't release the memory.

why is that happen? i already try to test it in debug mode and check the sampleData variable after disposed it was NULL.

is there wrong it there?

BTW on the method s2(), does ssss will release the memory if the object is destroyed?

modified 9-May-14 7:11am.

AnswerRe: Implementing IDisposable Pin
Pete O'Hanlon8-May-14 23:58
mvePete O'Hanlon8-May-14 23:58 
GeneralRe: Implementing IDisposable Pin
Gilbert Consellado9-May-14 0:05
professionalGilbert Consellado9-May-14 0:05 
GeneralRe: Implementing IDisposable Pin
Pete O'Hanlon9-May-14 0:36
mvePete O'Hanlon9-May-14 0:36 
GeneralRe: Implementing IDisposable Pin
Gilbert Consellado9-May-14 1:11
professionalGilbert Consellado9-May-14 1:11 
GeneralRe: Implementing IDisposable Pin
Dave Kreskowiak9-May-14 1:26
mveDave Kreskowiak9-May-14 1:26 
GeneralRe: Implementing IDisposable Pin
Gilbert Consellado9-May-14 1:38
professionalGilbert Consellado9-May-14 1:38 
Questionpolling call to a url Pin
nitin_ion8-May-14 20:38
nitin_ion8-May-14 20:38 
AnswerRe: polling call to a url Pin
Pete O'Hanlon8-May-14 20:52
mvePete O'Hanlon8-May-14 20:52 
QuestionDrawing a rectangle using GraphicsPath in C# doesn't complete the drawing (GDI+) Pin
jesuraj.pradeep8-May-14 20:05
jesuraj.pradeep8-May-14 20:05 
AnswerRe: Drawing a rectangle using GraphicsPath in C# doesn't complete the drawing (GDI+) Pin
Bernhard Hiller8-May-14 21:36
Bernhard Hiller8-May-14 21:36 
AnswerRe: Drawing a rectangle using GraphicsPath in C# doesn't complete the drawing (GDI+) Pin
OriginalGriff8-May-14 21:41
mveOriginalGriff8-May-14 21:41 
QuestionSearch and Retrieving String Pin
ASPnoob8-May-14 20:01
ASPnoob8-May-14 20:01 
AnswerRe: Search and Retrieving String Pin
Mycroft Holmes8-May-14 21:21
professionalMycroft Holmes8-May-14 21:21 
AnswerRe: Search and Retrieving String Pin
V.8-May-14 23:27
professionalV.8-May-14 23:27 
AnswerRe: Search and Retrieving String Pin
Emre Ataseven11-May-14 5:50
professionalEmre Ataseven11-May-14 5:50 
QuestionHandle Task Exception In Main Thread Pin
Kevin Marois8-May-14 14:31
professionalKevin Marois8-May-14 14:31 
QuestionDeveloping a .NET obfuscator. Need feedback. Pin
ianderf8-May-14 9:17
ianderf8-May-14 9:17 

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.