Click here to Skip to main content
15,890,527 members
Home / Discussions / C#
   

C#

 
GeneralRe: Outlook - right part of the window? Pin
Heath Stewart27-Jul-04 6:17
protectorHeath Stewart27-Jul-04 6:17 
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 
Hello,

I'm running the following program and getting memory leaks. The source of the leak is the "response = (HttpWebResponse)request.GetResponse();" line. When i close the connection to the response, it still won't clear up all the memory. I'm not sure why this is happening. I tried this code on an WinXP box with VS .NET 2002 and a Win 2003 Server box running Visual C# 2005 Express. I get leaks on both. I also tried calling GC.Collect() and GC.WaitForPendingFinalizers(), but that didn't help. Please let me know what i'm doing wrong here.

Thanx for the help, Amir



using System;
using System.Collections;
using System.Net;
using System.IO;

namespace GarbageCollectorTester
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{

public static string GetHTML(string url_)
{
HttpWebResponse response = null;
HttpWebRequest request= null;
try
{
Console.WriteLine("B: " + GC.GetTotalMemory(false));
request = (HttpWebRequest)(WebRequest.Create(url_));
response = (HttpWebResponse)request.GetResponse();
//Console.WriteLine("A: " + GC.GetTotalMemory(false));
}
catch(Exception e)
{
Console.WriteLine(e);
}
finally
{
if(response != null)
{
response.Close();
((IDisposable)response).Dispose();
}
request = null;
response = null;
//Console.WriteLine("A: " + GC.GetTotalMemory(false));
}
return "";
}

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
while(true)
{
GetHTML("http://www.hotornot.com");
}
}
}
}

GeneralRe: Problems with GC and HttpWebResponse Pin
Heath Stewart26-Jul-04 10:02
protectorHeath Stewart26-Jul-04 10:02 
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&gt;=OldDateTime)..???? Pin
Adel83k25-Jul-04 6:02
Adel83k25-Jul-04 6:02 
AnswerRe: if(DateTime.Now&gt;=OldDateTime)..???? Pin
ChrisAdams25-Jul-04 12:43
ChrisAdams25-Jul-04 12:43 
AnswerRe: if(DateTime.Now&gt;=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 

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.