Answer the question
In order to leave comments, you need to log in
Webbrowser in console application - out of memory, why?
When the application starts, at about the 100th iteration of the loop, the application is already unrealistically stupid. In the process, I see that the memory is gradually increasing.
static void Main(string[] args)
{
var mThreadt = new Thread(getPage);
mThreadt.SetApartmentState(ApartmentState.STA);
mThreadt.Start();
}
static void getPage()
{
StreamReader file = new System.IO.StreamReader(@"kw.txt");
while ((line = file.ReadLine()) != null)
{
String GoogleHTML = String.Empty;
using (WebBrowser browser = new WebBrowser())
{
browser.ScriptErrorsSuppressed = true;
browser.Navigate("https://www.google.com.ua/search?q=");
while (browser.ReadyState != WebBrowserReadyState.Complete)
Application.DoEvents();
GoogleHTML = browser.DocumentText;
}
}
}
Answer the question
In order to leave comments, you need to log in
what's the point of having a separate thread in the console? So that the UI does not slow down?) The
only thing that can be here is the GC does not have time to collect garbage (because there will be a lot of it)
Can be added after the block is completed using the GC.Collect() code;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question