<?xml version="1.0" encoding="iso-8859-1" ?>
<rss version="2.0">
  <channel>
    <title>HtmlEditor</title>
    <link>http://www.itwriting.com/phorum/list.php?3</link>
    <description><![CDATA[For discussion of the .Net HTMLEditor control]]></description>
    <language>EN</language>
    <pubDate>Tue, 22 Apr 2003 09:04:53 +0100</pubDate>
    <lastBuildDate>Tue, 22 Apr 2003 09:04:53 +0100</lastBuildDate>
    <category>HtmlEditor</category>
    <generator>Phorum 5.1.25</generator>
    <ttl>60</ttl>
    <item>
      <title>Re: MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,557#msg-557</link>
      <author>grin</author>
      <description><![CDATA[Thanks Tim, I didn't know that. It realy might be the issue here, MSHTML<br />
is about 8MB which is close to  my &quot;lost 12MB&quot;.  I'll dive into the subject<br />
you pointed me out and see what can be done.]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,557#msg-557</guid>
      <pubDate>Tue, 22 Apr 2003 09:04:53 +0100</pubDate>
    </item>
    <item>
      <title>Re: MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,549#msg-549</link>
      <author>Tim Anderson</author>
      <description><![CDATA[Here's an interesting snippet from a Microsoft engineer which you can find through Google groups:<br />
<br />
&quot;This is by design in the CLR. A DLL (or an assembly to be more correct) can<br />
only be unloaded when the appdomain that has loaded it goes away.&quot;<br />
<br />
I wonder if this is the issue here? In which case there might be a solution via using a separate AppDomain (I have never tried this).<br />
<br />
Tim]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,549#msg-549</guid>
      <pubDate>Mon, 21 Apr 2003 22:47:12 +0100</pubDate>
    </item>
    <item>
      <title>Re: MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,543#msg-543</link>
      <author>Tim Anderson</author>
      <description><![CDATA[I'll keep hitting at this; but in the meantime I want to thank you for pointing towards another leak in htmlEditor. I discovered that if you handle the HtmlEvent, then the form on which htmlEditor sits never gets disposed :-(. Fortunately I think I've found the fix - see separate post.<br />
<br />
Tim]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,543#msg-543</guid>
      <pubDate>Mon, 21 Apr 2003 18:03:45 +0100</pubDate>
    </item>
    <item>
      <title>Re: MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,541#msg-541</link>
      <author>grin</author>
      <description><![CDATA[<br />
I'm tracking total system memory with Task Manager(last tab) I've just realized that you're probably using processes tab to track this memory.<br />
I see your point now, minimizing the app reduces process memory, but<br />
total system memory stays at the same level, how to interpret that?<br />
<br />
I think that the GetTotalMemory() method only tracks memory resources<br />
allocated from managed code(MSHTML is unmanaged), <br />
so you're right that it doesn't report it. I didn't noticed that because I<br />
was only tracking differences(mem_before - mem_after).]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,541#msg-541</guid>
      <pubDate>Mon, 21 Apr 2003 16:31:34 +0100</pubDate>
    </item>
    <item>
      <title>Re: MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,540#msg-540</link>
      <author>Tim Anderson</author>
      <description><![CDATA[Which brings me back to the earlier question - how are you tracking this memory?<br />
<br />
GC.GetTotalMemory, which you mentioned, doesn't report it. If you display an htmlEditor with a loaded document GC.GetTotalMemory only reports 80K or so. I agree that Task Manager reports more than this, but that seems to be a different thing. You can reduce it by minimzing the app or by calling the SetProcessWorkingSetSize API.<br />
<br />
I'm not saying you're wrong; but I'd like to know how to track it.<br />
<br />
Tim]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,540#msg-540</guid>
      <pubDate>Mon, 21 Apr 2003 13:51:10 +0100</pubDate>
    </item>
    <item>
      <title>Re: MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,539#msg-539</link>
      <author>grin</author>
      <description><![CDATA[This is not quite the same situation, let me explain.<br />
The problem isn't about HtmlEditor or HtmlDocument instances <br />
it's rather about core MSHTML library which is loaded just after <br />
first &quot;new HtmlEditor()&quot; call and which occupies about 12MB.<br />
I want to be able to unload the MSHTML library which seems to be a problem.<br />
<br />
The example you gave above is about UI library which is a part of the Windows and .NET runtime. Ther's no way you can unload it (or load - it just stays in memory).]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,539#msg-539</guid>
      <pubDate>Mon, 21 Apr 2003 11:49:01 +0100</pubDate>
    </item>
    <item>
      <title>Re: MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,538#msg-538</link>
      <author>Tim Anderson</author>
      <description><![CDATA[Well, I can't get this behaviour even with a simple dialog containing just a text box. After I show, close and dispose the dialog, mem usage is higher than it was before. However it's not a leak as such, because it doesn't go on increasing.<br />
<br />
Tim]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,538#msg-538</guid>
      <pubDate>Mon, 21 Apr 2003 07:08:31 +0100</pubDate>
    </item>
    <item>
      <title>Re: MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,537#msg-537</link>
      <author>grin</author>
      <description><![CDATA[Hi, <br />
<br />
The problem isn't about many instances of HtmlEditor(), try this test:<br />
<br />
1) Comment this line out from Form1.InitializeComponent(),<br />
    so there is no instance of HtmlEditor:<br />
<br />
     this.htmlEditor1 = new onlyconnect.HtmlEditor();<br />
<br />
   compile &amp; run, check memory usage using Task Manager<br />
    - mine is showing 170448 K<br />
<br />
2) Uncomment the line out, so there is only one instance of HtmlEditor, <br />
    compile &amp; run, check memory usage<br />
    - mine is showing 182624 K<br />
<br />
3) Add three more instances of HtmlEditor:<br />
    this.htmlEditor2 = new onlyconnect.HtmlEditor();<br />
    this.htmlEditor3 = new onlyconnect.HtmlEditor();<br />
    this.htmlEditor4 = new onlyconnect.HtmlEditor();<br />
<br />
    compile &amp; run, memory usage is 182880 K<br />
-----<br />
<br />
As you can see the amount of memory used by one instance of HtmlEditor<br />
is almost the same as amount used by four instances(it's about 12MB),<br />
with next instances memory is increasing but not so drastically as with first.<br />
What I want to do is to remove at some point in my code one (and only)HtmlEditor instance, so I can reduce memory usage as in point 2) <br />
to the level of point 1).]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,537#msg-537</guid>
      <pubDate>Sun, 20 Apr 2003 22:19:13 +0100</pubDate>
    </item>
    <item>
      <title>Re: MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,536#msg-536</link>
      <author>Tim Anderson</author>
      <description><![CDATA[Well, it is a slippery subject.<br />
<br />
I've tried an experiment. In this one, I display the htmlEditor in a modal dialog, within a loop that runs 1000 times. The code is like this (VB):<br />
<br />
Dim i As Integer<br />
For i = 0 To 1000<br />
Dim f As New Form2 ' form  with htmlEditor<br />
f.ShowDialog()<br />
Me.Label1.Text = GC.GetTotalMemory(True)<br />
f.Dispose()<br />
GC.Collect()<br />
Label2.Text = i.ToString ' just to check progress<br />
Application.DoEvents()<br />
Next i<br />
<br />
Form2 has an event handler for ReadyStateChanged, looking for &quot;complete&quot;. On the first &quot;complete&quot;, it loads a document. On the 2nd &quot;complete&quot;, it closes the dialog.<br />
<br />
On first load, GC.GetTotalMemory returns 67788.  Task Manager 8408.<br />
<br />
With the test running, GC.GetTotalMemory goes up fairly quickly to 101300. However, it doesn't increase after that. Task Manager shows 15908K, again it doesn't increase.<br />
<br />
After 1000 loops, the memory settles to 92120. Minimizing the app has the usual odd effect in task manager - mem down to 872K. However, GC.GetTotalMemory stays at 92120.<br />
<br />
Now I try a similar test with a dialog containing a text control instead of htmlEditor. This time, the dialog loads a small piece of text, and then a timer closes the form. I get broadly the same result, except that the memory usage peaks at 75260 and stays there. Task manager 9452K.<br />
<br />
I don't know quite how to interpret this, but it is a mildly encouraging result I think.<br />
<br />
Tim]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,536#msg-536</guid>
      <pubDate>Sun, 20 Apr 2003 19:15:44 +0100</pubDate>
    </item>
    <item>
      <title>MSHTML memory resources</title>
      <link>http://www.itwriting.com/phorum/read.php?3,535,535#msg-535</link>
      <author>grin</author>
      <description><![CDATA[Hi, <br />
I have a problem with releasing memory resources occupied by MSHTML<br />
objects (HTMLDocument), I've been pointed out that the  HtmlEditor handles<br />
clean up very well, I played with it and I found that it has basically the same<br />
problem. The method HtmlEditor::CleanupControl() which is responsible for<br />
releasing memory doesn't work. I added &quot;Release&quot; button to DemoHtmlApp.Form1 with this code atached:<br />
<br />
   this.htmlEditor1.CleanupControl();<br />
   // or this.htmlEditor1.Dispose();<br />
   this.htmlEditor1 = null;<br />
   System.GC.Collect();<br />
   this.Refresh();<br />
<br />
and when I click on it the document disapears but memory resources <br />
aren't released. So the question rises: how to release memory occupied<br />
by MSHTML(before exiting the code)?]]></description>
      <category>HtmlEditor</category>
      <guid isPermaLink="true">http://www.itwriting.com/phorum/read.php?3,535,535#msg-535</guid>
      <pubDate>Sun, 20 Apr 2003 09:22:38 +0100</pubDate>
    </item>
  </channel>
</rss>
