A
Andreas Lennartz
Hello,
I have some problems with the class WebRequest and its childs. I am
developing a bot that visits a lot of different urls and returns the
content. But every time an URL-Request is finished there is a memory leak.
Here is a small example that reproduces this problem:
I read of a File with many different(!) URIs. The next URI to visit is saved
in the variable "uri".Then I try to connect to this uri. I do it with the
following line of codes:
// HttpWebRequest Request = null; //is declared at the Beginning of the
class
// HttpWebResponse Response = null; //is declared at the Beginning of the
class
try
{
Request = (HttpWebRequest)WebRequest.Create(uri);
Request.Timeout = 1000;
Response = (HttpWebResponse)Request.GetResponse();
}
catch (Exception e) {;}
finally
{
if (Response != null) Response.Close();
if (Request != null) Request.Abort();
}
The connection is established without any problems. But if i do this
code-block in a
Not-Ending Loop, the memory requirement is climbing constantly.
Can anybody say me how to stop this memory leak?
(Sorry for my english, it's not my native language)
I have some problems with the class WebRequest and its childs. I am
developing a bot that visits a lot of different urls and returns the
content. But every time an URL-Request is finished there is a memory leak.
Here is a small example that reproduces this problem:
I read of a File with many different(!) URIs. The next URI to visit is saved
in the variable "uri".Then I try to connect to this uri. I do it with the
following line of codes:
// HttpWebRequest Request = null; //is declared at the Beginning of the
class
// HttpWebResponse Response = null; //is declared at the Beginning of the
class
try
{
Request = (HttpWebRequest)WebRequest.Create(uri);
Request.Timeout = 1000;
Response = (HttpWebResponse)Request.GetResponse();
}
catch (Exception e) {;}
finally
{
if (Response != null) Response.Close();
if (Request != null) Request.Abort();
}
The connection is established without any problems. But if i do this
code-block in a
Not-Ending Loop, the memory requirement is climbing constantly.
Can anybody say me how to stop this memory leak?
(Sorry for my english, it's not my native language)