C# - WebRequest/WebResponse Memory Leak?

Dec 7, 2010

I have an .Net Framework #4.0 application that makes a large number of web requests using the WebRequest/WebResponse classes , as i see it has memory leak (or maybe i am doing something wrong)I Wrote some small simple application that demonstrates this:

class Program
{
public static void Main(string[] args)[code]...

The only one solution i came up with is use GC.Collect() (unmarked in example) , All the object are disposed , all streams are closed , am I missing something ?I found something but i don't understand the reason , if i minimize Console the memory usage decreases and looks O.K , what can be the reason for that is there a problem with Conosole or WinForm .

View 1 Replies


Similar Messages:

DataSource Controls :: Memory Leak - Server Will Crash - Log A Ton Of SQL Errors Stating That It Is "out Of Memory"

Jul 27, 2010

I have a memory leak somewhere that I cant find. Every few days my server will crash, and just before that I log a ton of SQL errors stating that it is "out of memory".

I cant find it anywhere, all of my connections are being disposed like so:

[Code]....
Then I call the connection from my pages like so:[Code]....

That is all pretty straight forward. The connection is disposed because it is implementing the USING clause. I am opening the connection in my connection manager class, and not where it is being utilized?Or, could the problem be in the below method I am using to populate a SqlDataReader:[Code]....

Now, at first it appears as though this could be the problem because the Connection isn't part of a USING clause, however doesn't the 'Data.CommandBehavior.CloseConnection' pretty much do the same thing. This makes sure that the connection is closed when the reader is closed, right? Here is how I call that above reader from my login page code behind:[Code]....

So the DataReader will get closed even without the .Close() because it is in the USING, and the connection should get closed because I specified it in the ExecuteReader paramters right?

View 8 Replies

C# - Impersonation Memory Leak

Feb 9, 2011

On http://msdn.microsoft.com/en-us/library/w070t6ka(v=VS.100).aspx there is an example on how to do impersonation with .net 4.0. We have used this example in a class that inherits IDisposable for ease of use. However, when we use this class in a asp.net web application, we notice a slight but steady increase of Pool Paged Bytes in performance monitor. After a week, the application crashes.

I've tried different implementations of the impersonation-class, using http://msdn.microsoft.com/en-us/library/w070t6ka(v=VS.90).aspx and http://support.microsoft.com/kb/306158 as reference, but they all show the same leak.

Where does this leak come from? Is there a problem with the windows api? We are running Windows 2008 R2.

This is our current version of the impersonation class:

public class Impersonator : IDisposable
{
public Impersonator(string username, string domain, string password)
{
if (!ImpersonateValidUser(username, domain, password))[code]....

And this is the performance monitor graph of two webservers using different versions of the class:

When we disable the class, and use global impersonation via web.config, those lines are completely flat.

Update,I have made a test-application that successfully reproduce the problem. It can be downloaded here:

http://rapidshare.com/files/447325211/ImpersonationTest.zip

The result over 18 hours looks like this:

View 1 Replies

C# - Mscorwks.dll Memory Leak

Aug 2, 2010

We got a problem in one of our ASP.net apps, the mscorwks.dll is using a lot of memory. where to start looking for the memory leak ?

mscorwks!EEVirtualAlloc+119: 1.26 GBytes worth of outstanding allocations.

View 3 Replies

MVC :: Memory Leak In Database Factory

Jun 14, 2010

I'm writing an MVC app and want to have a central DataBase factory class to provide all my DB connections, something like this:-

[Code]....obviously I'll have to instanciate this every time I need to use it, so I was thinking of making it a static class:-

[Code].... so that instead of my controller code saying

[Code].... I can just say

but would this cause a memory leak? I'm sure I remember reading somewhere that if a static class creates objects that persist beyond it's methods and return those (esp things like DB connection objects) these won't get garbaged collected when the calling method is disposed of as they were created/referenced outside the scope of that calling (controller action) method and so will hang around in memory?

var tableObject = DatabaseFactory.GetDatabaseTable();
List<DbRecord> records = tableObject.Table.ToList();

View 9 Replies

AJAX :: UpdatePanel Memory Leak IE8?

Nov 2, 2010

I created a site which fills an UpdatePanel with dynamically created buttons when clicking on an other button. Now every time I click the button the used memory increases. I already tried the workaround from http://www.crockford.com/javascript/memory/leak.html to remove old eventhandlers before updating the UpdatePanel. But the used memory still increase. Is there a problem with my code or is there an other workaround?

Here is the code of a sample aspx site which shows the problem: [Code]....

Browser IE8

OS WinXP SP2

.Net Framework 3.5 SP1

View 3 Replies

.net - Possible Memory Leak In Asynchronous .NET Call To A WebService?

Sep 16, 2010

I've created a small class library to asynchronously call a WebService(Fire and Forget. I don't need the result).In a Windows Form application, the XXXAsync() method works fine. But, in a Web Application, the process is locked until the XXXCompleted event is fire.My problem is: I tried to create a Delegate and use the Begin/EndInvoke to call the XXXAsync() method. It worked fine, but, the w3wp process seems to be consuming a huge amount of memory. I'm calling the EndInvoke method properly. Invoking the GC.Collect did not free any memory

View 1 Replies

Facebook - How To Find Memory Leak From ASPX App Having A DLL

Apr 30, 2010

Any tips How to figure out where is memory leak in my Facebook app, its ASPX using Facebook toolkit DLL and I am afraid the bug may be in that CS library.

The problem is that after one week uptime, server is running out of memory and needs to be rebooted, there are quite many users and I cannot run debugger on this "production server", so I would need to simulate somehow use on my local PC.

View 1 Replies

Web Forms :: Memory Leak When I Bind GridView To My Dataset?

Oct 29, 2010

I am facing problem memory leak when I bind GridView to my dataset. The dataset will be retrieve when page first loaded (Not postback) and store into session. ANy postback will reuse the dataset from session.

The problem now is, whenever any postback, the memory leak is keep increasing and till 1GB. I read some articles and mentioned it is ASP.NET databind issue. Is it true? Any workaround?

View 9 Replies

Forms Data Controls :: Memory Leak - Gridview

Jan 13, 2011

I am using DevExpress Gridview basically, and hit out of memory exception whenever I keep refresh page that contains huge data. I reported to DevExpress team and they claimed it is ASP.NET gridview issue.

Therefore, I create a simple project, a girdview to sqlDataSource. Run the page and press F5 to refresh. I use ANTS profiler to check if any object instance is keep increasing but never been disposed. I found that, memory does happen in this simple project, as what DevExpress team claimed.[Code]....

View 4 Replies

AJAX :: ToolkitScriptManager Memory Leak - Using IE7 And Have Removed All Inline JS And JS Files

Jan 17, 2011

I'm using the ToolkitScriptManager on a page so that I can use the update panel. Everytime I refresh the page the mem usage in task manager jumps up 3-4megs. I'm using IE7 and have removed all inline JS and JS files to no avail.

View 4 Replies

DataSource Controls :: Possible Memory Leak In DataTable.Select Method?

Jun 18, 2010

I have an application which was recently ported from Classic ASP to .NET 3.5. I'm pulling some data from a stored procedure and once retrieved, I'm doing using the Select method on the DataTable in a loop so I don't have to keep going back to the database.It appears that there's something wrong here as I can refresh the page repeatedly and see the memory usage increase by a few megabytes, up to the point where we get an error. If we recycle the app pool in IIS, it starts working again, for a little while.

Is there a memory leak in this method? I did some research on the subject and Microsoft said there was an issue like that in .NET 1.0 and 1.1, but I'm using a higher version.Or, is this something else, such as not managing resources correctly? Here's a snipped of my code:

[Code]....

Initially, this app was using XML instead of a datatable and using XPATH to query the data, but it was too slow. I thought using a dataset with DataTable selects was a better option, but now we found this issue. I was thinking since the loop executes several hundred times that getting all the data and filtering through it on the client was a better choice instead of calling several web methods to get the subsets of data.

View 5 Replies

Visual Studio :: VS 2010 Memory Leak When Trying To Copy & Paste Code Inside?

Oct 8, 2010

It happens frequently when I try to copy & paste code inside VS 2010 with following message:

insufficient available memory to meet the expected demands of an operation at this time, possibly due to virtual address space fragmentation. Please try later.

and I check the memory usage with taskmanager on my computer. It is fine.

In order fix it, I need to close VS 2010 and restart again.

View 1 Replies

C# - Crawler Webresponse Operation Timed Out

May 18, 2010

I have built a simple threadpool based web crawler within my web application. Its job is to crawl its own application space and build a Lucene index of every valid web page and their meta content. Here's the problem. When I run the crawler from a debug server instance of Visual Studio Express, and provide the starting instance as the IIS url, it works fine. However, when I do not provide the IIS instance and it takes its own url to start the crawl process(ie. crawling its own domain space), I get hit by operation timed out exception on the Webresponse statement. Could someone please guide me into what I should or should not be doing here? Here is my code for fetching the page. It is executed in the multithreaded environment.

private static string GetWebText(string url)
{
string htmlText = "";

[code]...

View 1 Replies

VS 2008 - WebResponse 500 Internal Server Error

Sep 26, 2011

I'm trying to make a webpage that get's a url from another web page (this other webpage works fine in a browser, both IE and FF) but when I make the webrequest call the returned page is a 500 internal server error. Here's the code:

Imports System.Net
Imports System.IO
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

[Code] ....

Here's the error I'm getting:

Code:

System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.GetResponse()
at SW_GetDownloadFile._Default.GetDownloadFile(String Url) in C:Documents and SettingsvmMy DocumentsVisual Studio 2008ProjectsSW_GetDownloadFileSW_GetDownloadFileDefault.aspx.vb:line 24

The DownloadHandler.jsp page simply displays a text line being a text file download link, there's no html formatting or anything and when I paste that text into the browser it shows the text file contents just fine, I need my asp webpage to get that text file link so it can turn around and open it to parse the info.

I'm not in control of the DownloadHandler.jsp page so i can't alter that, the Java team wont make any changes to it either.

View 6 Replies

MVC3 - ActionResult Rendering DotNetOpenAuth WebResponse As String?

Nov 12, 2010

I've just updated my MVC2 project to run MVC3 (RC). Everything is working as expected except for one problem.

I'm running DotNetOpenAuth, but when I go to authenticate, my page renders the string

DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult

instead of authenticating (which worked in the MVC2 app)

I found this question elsewhere on SO, and I did what was suggested, but to no avail.

Here is a clip of my Web.Config

</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>

[Code]....

View 1 Replies

Examine WebResponse Without Affecting The Underlying Response Stream In .NET?

Oct 27, 2010

After a call to initial HttpWebResponse.GetResponseStream() and reading through the stream, that stream is done for and cannot be reused.

I have a situation where I need to examine the content of the response and if it is of a certain data, get another page and then pass the new response down the line. Otherwise, pass down the original response as is. The only problem is that after examining the response to check for this "special data", that response is no good to the downstream code.

The only way, I can think of, to make this transparent to the downstream code, is to create a derived class of HttpWebResponse, and somehow cache the data streamed, and pass that cached stream down the line instead of the initial stream. I'm not sure if that's even feasible since I haven't looked into it further.

View 3 Replies

Error Occurring When Using Wcf To Run Query - Memory Gates Checking Failed Because Of The Free Memory

May 21, 2010

I am building an asp.net application, using II6 on windows server 2003 (vps hosting).

I am confronted with an error I didn't receive on my development machine (windows 7, iis 7.5, 64 bit).

When my wcf service tries launching my query running against a local sql server this is the error I receive:

Memory gates checking failed because the free memory (43732992 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.

View 1 Replies

Error: Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory Is Corrupt?

Oct 11, 2010

I have both VS 2005 and 2008 installed on my machine. 2005 is fine. For 2008, literally any asp.net project I try to create gets this eror. I try stepping into the code, and the error occurs apparently before anything that I can trap is loaded. There is no information written to the event log. I have tried this with a "Hello World" webpage with nothing else going on. Seems unique to my Windows Server 2003 machine.

View 3 Replies

Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory Is Corrupt

Jul 30, 2010

I am getting a weird error in asp.net while using leadtools imaging api. Here's the stack trace.

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at SetThreadData(_THREADDATA* )
at Leadtools.Codecs.CodecsOptions.Use()
at Leadtools.Codecs.RasterCodecs.DoSave(SaveParams saveParams)
at Leadtools.Codecs.RasterCodecs.Save(RasterImage image, Stream stream, RasterImageFormat format, Int32 bitsPerPixel)........

View 1 Replies

Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory?

Jan 26, 2011

I am maintaining C# .NET code written by somebody else, I get following exception few times,Attempted to read or write protected memory. This is often an indication that other memory is corruptThe code structure where I get the above exception is somethign like this,- it is using ref variables in following sequence,Variable-1 and variable-2 are local variables in App1, - App1: func1() which passes these variables reference to func2(), - App1: func2() passes same variables reference via .net remoting to another application (App2).-App2: does the same passes same received reference to another call 2 times.- The execption is occured while returning from App2.

(App1:func1(ref Var1, ref Var2) --> App1:func2(ref Var1, ref Var2) <---App1 .net remoting to App2--> App2:func3(ref Var1, ref Var2)--> App2:func4(ref Var1, ref Var2)-->variables getting updated and function returned to original caller)

My doubts are ,1. Is passing reference variables in such chain is correct? will it cause such exeption? Does .net support ref variable call directly?

View 1 Replies

ANTS Memory Profiler - Which Memory Should Be Looking At?

Aug 24, 2010

I have a memory issue on my websites and am trying to get to the bottom of it. I have downloaded the 14 day trial of ANTS Memory Profiler and have been playing with it to get a grip of what it's telling me. In the memory options on the timeline, I can see Bytes in All Heaps and Private Bytes etc but I am not sure which ones I should be focusing on to see where the memory spikes and doesn't go back down.I am profiling a ASP.NET website using ASP.NET 2.0.

View 1 Replies

How To Keep Connection Alive When Using Webrequest

Mar 8, 2011

string strURL = (Request.IsSecureConnection ? [URL] : [URL]

[code]....

I get an error on da line objPost.Close();.....the unusual error is that when I debug this code line by line slowly using F10 in visual studio 2010...the code works..but when I just run the program or even debug the program fast...it throws an error at that line.. it gives an error that the connection which was expected to be open was closed by the server..

View 1 Replies

Find Out Where The Performance Leak Is?

Jan 31, 2010

I have an self-build asp.net page, (link), and on my own localhost-server it runs very fast.But when I have uploaded it to my rent server (Win08Server, 3GB Ram, 3GhZ...) it goes very very slow (3-5 second a site-switch).

hot to find out what programm is disturbing or where I have a leak?

(the most of the content is static, only a 2 database querys at the beginning!!!)

View 4 Replies

Including Login Credentials With A WebRequest?

Jul 7, 2010

I am trying to "behind the scenes" log myself into a website, from the VB code behind my ASP.NET website. But I am dumbfounded as to how to do this.

As far as I know I should be using the WebRequest or Webclient class. That is about as much as I know. I am not sure how to use the class.

I want to click a button on my website and have its Click event send a username and password to another website. This other site isot affiliated with mine. I realize the concept may seem stupid, but I plan on taking this further later, but Just need to know this now.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved