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 8289569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:32:17+00:00 2026-06-08T12:32:17+00:00

I am using a custom text box (read only) that consist of 2 WebBrowser

  • 0

I am using a custom text box (read only) that consist of 2 WebBrowser components. It’s displaying text with complicated layout (Generating a html code was a simplest option to make such a text viewer).

I am also binding the mousedown event on all components:

foreach (HtmlElement html in webBrowser1.Document.All)
{
     html.MouseDown += new HtmlElementEventHandler(Scrollback_Clicked);
}

this happens after each time where I finish loading of html source. (this is irrelevant but it’s the only customization of WebBrowser control I made, just in case it was the reason why it doesn’t work)

However, after several hundreds of reloads the text box eats about 2GB of ram, I suspect it’s a cache the browsercontrol has implemented, which stores all HtmlDocuments that were generated so far.

Is there a way to disable or flush the cache of WebBrowser control?

  • 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-06-08T12:32:18+00:00Added an answer on June 8, 2026 at 12:32 pm

    First off, you’re probably leaking event handlers, considering the way you’re registering them and then failing to dispose them. That might cause a slight performance problem, but it obviously doesn’t explain the consumption of an excessive 2 GB of RAM.

    Anyway, the WebBrowser control is based on Internet Explorer, so it’s possible it inherits a memory leak from there. You may also be onto something with the caching theory. There is a knowledge base article that discusses precisely this problem and how to solve it: How to clear the cache when your application hosts a WebBrowser control in Visual C# .NET.

    Basically, it suggests that you manually flush the browser cache using the WinInet APIs. But that seems like a bit of a sledgehammer solution to me. It’s solving a local problem using a global solution, which should raise a few red flags.

    If I were you, I’d be rethinking my application’s design so as to avoid this problem altogether. RichTextBox controls don’t have any show-stopper memory leaks. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am displaying images and text to a listview using a custom adapter, when
I'm implementing a custom text box using -interpretKeyEvents: and am trying to figure out
I had been created text box custom validation control and I'm using this in
I am using a custom validator to compare value in two text box. This
So I created a custom text view using core graphics and have it conformed
I am using Delphi, and I want to show custom text in the buttons
I am using a custom font in my text fields and labels in my
I'm indexing and searching code using a custom analyzer. Given text will wi-fi work,
I'm using custom class that subclass from UILabel. It works fine unless I change
I have written a user control that contains a text box and a button.

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.