Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory leak when using HttpWebRequest object in ASP.NET site
    text
    copied!<p>This is my class:</p> <pre><code>public class HttpRequestHelper { public static string GetRequestText(string url, string method, string referer, string postData, int timeout = 50000, string userAgent = null, string proxy = null) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); request.Method = method; request.Timeout = timeout; if (!string.IsNullOrEmpty(proxy)) request.Proxy = new System.Net.WebProxy(proxy); request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; if (!userAgent.IsNullOrEmptyText()) { request.UserAgent = userAgent; } if (!string.IsNullOrEmpty(referer)) { request.Referer = referer; } if (method == "POST") { if (!string.IsNullOrEmpty(postData)) { request.ContentLength = postData.Length; using (Stream writeStream = request.GetRequestStream()) { UTF8Encoding encoding = new UTF8Encoding(); byte[] bytes = encoding.GetBytes(postData); writeStream.Write(bytes, 0, bytes.Length); } } else request.ContentLength = 0; } string result = string.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8)) { result = readStream.ReadToEnd(); } } } return result; } } </code></pre> <p>Normal my site take around 170mb memory (around 40k records in database). But when i call <code>GetRequestText</code> function the memory up to 1Gb memory. I dont know why? Any idea or solution for this ?</p> <p>Thanks advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload