Click here to Skip to main content
15,916,030 members
Home / Discussions / C#
   

C#

 
GeneralRe: Outlook - right part of the window? Pin
BillyBlue27-Jul-04 6:25
BillyBlue27-Jul-04 6:25 
GeneralRe: Outlook - right part of the window? Pin
Heath Stewart27-Jul-04 9:08
protectorHeath Stewart27-Jul-04 9:08 
GeneralRe: Outlook - right part of the window? Pin
BillyBlue27-Jul-04 9:43
BillyBlue27-Jul-04 9:43 
QuestionHow to use NotifyParentPropertyAttribute Pin
jjansen25-Jul-04 21:19
jjansen25-Jul-04 21:19 
AnswerRe: How to use NotifyParentPropertyAttribute Pin
Heath Stewart26-Jul-04 10:13
protectorHeath Stewart26-Jul-04 10:13 
GeneralRe: How to use NotifyParentPropertyAttribute Pin
jjansen27-Jul-04 21:02
jjansen27-Jul-04 21:02 
GeneralProblems with GC and HttpWebResponse Pin
Amir Zicherman25-Jul-04 8:38
Amir Zicherman25-Jul-04 8:38 
GeneralRe: Problems with GC and HttpWebResponse Pin
Heath Stewart26-Jul-04 10:02
protectorHeath Stewart26-Jul-04 10:02 
First of all, a much better way to make sure your response and requests (or anything that implements IDisposable) gets disposed in C# (even in case of exceptions) is the using block:
HttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.codeproject.com");
using (request)
{
  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  using (response)
  {
    // ...
  }
}
Also, realize that type implementations in .NET are compiled to Intermediate Language (IL). This IL is just-in-time compiled (JIT compiled, or sometimes just "JIT'd") into native code which is cached in memory, as well as any type member implementations used by that type. There will be some increase that will not "go away" because it is the native code that is being cached.

If the memory continues to increase (after disposing both objects and any other objects you use that implement IDisposable) after several calls to your GetHTML method, try calling GC.Collect to see if that cleans up memory (remember there will be some overhead for the cached native code). If so, then there's probably something else you can dispose.

The main thing to remember is to always dispose disposable objects and let the GC do it's job. This may not always produce the best effect on your target machine, but remember that the .NET Framework - like other larger frameworks like Java - require many more resources than native applications typically do.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Problems with GC and HttpWebResponse Pin
Amir Zicherman27-Jul-04 7:59
Amir Zicherman27-Jul-04 7:59 
GeneralRe: Problems with GC and HttpWebResponse Pin
Heath Stewart27-Jul-04 10:43
protectorHeath Stewart27-Jul-04 10:43 
Questionif(DateTime.Now>=OldDateTime)..???? Pin
Adel83k25-Jul-04 6:02
Adel83k25-Jul-04 6:02 
AnswerRe: if(DateTime.Now>=OldDateTime)..???? Pin
ChrisAdams25-Jul-04 12:43
ChrisAdams25-Jul-04 12:43 
AnswerRe: if(DateTime.Now>=OldDateTime)..???? Pin
DougW4825-Jul-04 19:17
DougW4825-Jul-04 19:17 
GeneralDotNet DataGrid RowHeight Pin
Aerobatty25-Jul-04 5:08
Aerobatty25-Jul-04 5:08 
GeneralRe: DotNet DataGrid RowHeight Pin
DougW4825-Jul-04 19:45
DougW4825-Jul-04 19:45 
GeneralNeed C# Tutorial Writers - Will pay Pin
checker_src24-Jul-04 16:49
checker_src24-Jul-04 16:49 
GeneralRe: Need C# Tutorial Writers - Will pay Pin
Small Rat24-Jul-04 17:57
Small Rat24-Jul-04 17:57 
GeneralRe: Need C# Tutorial Writers - Will pay Pin
checker_src24-Jul-04 19:15
checker_src24-Jul-04 19:15 
GeneralRe: Need C# Tutorial Writers - Will pay Pin
Grimolfr25-Jul-04 2:57
Grimolfr25-Jul-04 2:57 
GeneralRe: Need C# Tutorial Writers - Will pay Pin
checker_src25-Jul-04 3:39
checker_src25-Jul-04 3:39 
GeneralConsole Applications Pin
Vickie Madigan24-Jul-04 15:33
Vickie Madigan24-Jul-04 15:33 
GeneralRe: Console Applications Pin
Small Rat24-Jul-04 17:53
Small Rat24-Jul-04 17:53 
GeneralRe: Console Applications Pin
Grimolfr25-Jul-04 2:54
Grimolfr25-Jul-04 2:54 
GeneralRe: Console Applications Pin
Vickie Madigan25-Jul-04 17:24
Vickie Madigan25-Jul-04 17:24 
GeneralRe: Console Applications Pin
Grimolfr26-Jul-04 3:54
Grimolfr26-Jul-04 3:54 

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.