Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5942423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:15:02+00:00 2026-05-22T16:15:02+00:00

I am using HttpWebRequest object to upload files using SSL with client certificate, I

  • 0

I am using HttpWebRequest object to upload files using SSL with client certificate, I have a valid certificate on my server, My application is having a memory leak issue and Microsoft has posted something related to the issue on the following link:

FIX: Memory Leak When SSL and Client Certificates Are Used With the HttpWebRequest Object

Is there any work around to avoid this memory leak specially that each request is consuming 8K leaked memory, this will cause my application to consume so much memory.


 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
 ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
 request.Method = "POST";
 request.ContentType = "text/xml; charset=utf-8";

memory leaks were detected using .NET Memory Profiler and it shows the HttpWebRequest object has array of bytes that leaks the memory, I am deposing both stream and request objects.

I have tried this case with SSL and without SSL the leaks have disappeared in non SSL Requests.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:15:03+00:00Added an answer on May 22, 2026 at 4:15 pm

    simply set the AllowWriteStreamBuffering property of your HttpWebRequest object to false:

    request.AllowWriteStreamBuffering = false;
    request.AllowAutoRedirect = false;
    

    Note : The Framework caches SSL sessions as they are created and attempts to reuse a cached session for a new request, if possible. When attempting to reuse an SSL session, the Framework uses the first element of ClientCertificates (if there is one), or tries to reuse an anonymous sessions if ClientCertificates is empty.

    Other Note : For performance reasons, you shouldn’t add a client certificate to a HttpWebRequest unless you know the server will ask for it.
    For a code example illustrating how to enumerate the certificates in the client certificate store, see the X509Certificate2Collection class.

    Or try to use this :

    request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with a POST I'm doing using the HttpWebRequest object from
I'm trying to make an SSL call using HTTPWebRequest and its continually failing saying
I have a task to perform an HttpWebRequest using Task<WebResponse>.Factory.FromAsync(req.BeginGetRespone, req.EndGetResponse) which can obviously
I need to upload a file in C# using an httpwebrequest. I don't need
I'm using an HttpWebRequest object to access a web service via an HTTP POST.
I have a strange issue using HttpWebRequest, I'm trying to post a string to
I am attempting to call a RESTful service using an HttpWebRequest object via POST.
I'm using the HttpWebRequest object to make a get call to a site/web service
I get a timeout when using a SOAP client on a production server: System.Net.WebException:
I'm using HttpWebRequest to pull down XML, and POST data back to a 'WebService'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.