473,800 Members | 2,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory Leak with Web-Requests

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.Cre ate(uri);
Request.Timeout = 1000;
Response = (HttpWebRespons e)Request.GetRe sponse();
}
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)
Nov 15 '05 #1
2 7173
Andreas,

This is not a memory leak. The CLR will allocate more memory as needed.
The CLR will continue to grab up memory until it feels that it would
constrain the system by doing so.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"Andreas Lennartz" <al***@gmx.ne t> wrote in message
news:OP******** ******@TK2MSFTN GP09.phx.gbl...
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.Cre ate(uri);
Request.Timeout = 1000;
Response = (HttpWebRespons e)Request.GetRe sponse();
}
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)

Nov 15 '05 #2
This is not a memory leak. The CLR will allocate more memory as needed. The CLR will continue to grab up memory until it feels that it would
constrain the system by doing so.


Hallo,

first thank you for your answer. Well, that the CLR grabs as much memory as
it feels to need would explain the behaviour of my programm. The bot I'm
developing visits about 20 pages every turn, and a turn lasts about 6 sec.
So, there are many different pages which are visited in a (relative) short
time. I tried serveral methods of spidering the pages (with threads and
asynchronous I/O), with several instances of the bot or only one instance.
Unfortunately, the memory requirement of the bot is always above 100MB. Till
now I always thought that would be a memory leak. After some more test runs
I recognized that it level off around 120MB. But that seems to me very much
to fulfil such an simple task.
Running this on a webserver would be risky.
Are there any possibilities to reduce the memory my application gets?
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5784
by: ianstirkcv | last post by:
Hello, I wonder if you can please help… We are running a web application built using .net framework version 1.0, service pack 2, running on Windows 2000 server, service pack 3. The server has 1 gigabytes of RAM. We are using Perfmon to monitor memory usage of aspnet_wp.exe, CPU usage, and % time in the Garbage Collector.
7
1585
by: Jon Davis | last post by:
OK I have a web app that I built that makes MANY calls to the DB in each request. The app wasn't tuned for scalability so this wasn't a problem, but time is too short to redesign how the database is accessed because the data that's being stored is time relevant and the web app will be thrown out in a few months. Since I try to separate the OleDb stuff from the business logic, I just create new database connections and trust that those...
19
1744
by: Jon Davis | last post by:
I'm reposting this because I really need some advice. I have a web app that makes many queries to the database on every page. In order to save development effort, I've consolidated all database querying to methods in a single static class, so whenever I need data, I pass a SQL string to a method and I am passed a datareader or else individual values (string, integer, etc). There is a horrible memory leak in this application. Just one...
9
425
by: Anton | last post by:
{Willy Skjveland} Hi, how can I trace a Memory leak in aspnet_wp.exe? {Rheena} One moment please while I search it for you. It may take me a few moments {Willy Skjveland} I need to find out which application and which dll and asmx page that cause the problem. {Rheena} May I know what operating system you are using?
1
2318
by: Charlotte | last post by:
Hello, We are doing a stability test on our application to prepare for Microsoft SQL Server 2000 certification, and we found a memory leak, but we cannot find its source and fix it. We use an ASP page written in JScript that connects to Analysis Services 2000 using ADOMD and retrieves data from it (this is a very simplified version of our real application that we created just to test the memory leak), see the code below.
8
8557
by: Adrian | last post by:
Hi I have a JS program that runs localy (under IE6 only) on a PC but it has a memory leak (probably the known MS one!) What applications are there that I could use to look at the memory usage of each object within my JS app to help locate my problem? Thanks
3
5328
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". Anybody know anything about this? Does *Javascript* leak memeory, or does the *browser* leak memory?
2
4892
by: =?Utf-8?B?Tm9tYW4gQWxp?= | last post by:
Hi, We are facing a strange problem in our ASP. NET website. Some times it gives the following unhandled exception. Error Message: Exception of type System.Web.HttpUnhandledException was thrown. Detailed Error Message: System.InvalidOperationException: There has been an overflow or underflow in GC memory pressure. The possible cause is unbalanced AddMemoryPressure and RemoveMemoryPressure calls. at...
0
1181
by: rkmr.em | last post by:
the memory usage of a python app keeps growing in a x86 64 linux continuously, whereas in 32 bit linux this is not the case. Python version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8 Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) i isolated the memory leak problem to a function that uses datetime module extensively. i use datetime.datetime.strptime, datetime.timedelta, datetime.datetime.now methods... i tried to get some info...
2
2701
by: Jay | last post by:
I have a web app running on the windows CE device. In one of the asp.net pages - it has javascript code. That seems to have a memory leak. When I run the web app - in about one hour, the app hangs. I looked at the memory and it seems to be full. I removed all the javascript code - and the app seems to be have no leaks. As soon as I include my javascript code - the memory consumption gradually increases. Whether I actually invoke the...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10275
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.