# Memory leaks using the WebBrowserComponent

**URL:** <https://forum.juce.com/t/memory-leaks-using-the-webbrowsercomponent/21341>\
**Category:** Development\
**Created:** [March 14, 2017, 6:03pm UTC](https://forum.juce.com/t/memory-leaks-using-the-webbrowsercomponent/21341 "2017-03-14T18:03:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobsellon](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@bobsellon](https://forum.juce.com/u/bobsellon)\
**Post date:** [March 14, 2017, 6:03pm UTC](https://forum.juce.com/t/memory-leaks-using-the-webbrowsercomponent/21341/1 "2017-03-14T18:03:31Z")

</div>

I’ve been tracking down a memory leak in my app and eventually found that it was in the Juce WebBrowserComponent.

I’ve been able to reproduce this by creating a new GUI app, adding a ScopedPointer webBrowser\_ member to the MainContentComponent class then creating it (i.e. new) and do a addAndMakeVisible(webBrowser\_) in the constructor. Of course webBrowser\_ = nullptr; in the destructor. Build the app, run it and close it and you’ll get (I’m getting) something like this in the Visual Studio 2015 Output window:

“Dumping objects -  
{383} normal block at 0x018F32E0, 12 bytes long.  
Data: \< = \> 94 87 3D 01 01 00 00 00 00 08 03 00  
{382} normal block at 0x018D27F0, 16 bytes long.  
Data: \< = 2 \> 90 88 3D 01 01 00 00 00 00 08 03 00 E0 32 8F 01  
{381} normal block at 0x018F3040, 12 bytes long.  
Data: \<L = ’ \> 4C 89 3D 01 01 00 00 00 F0 27 8D 01  
Object dump complete.”

I don’t have a work around yet but I noticed that I only get the leak if I call the addAndMakeVisible() so it’s not the basic construction/destruction. It also doesn’t seem to matter if I do a goToURL() or not.

Note that I’m seeing this on my Windows 8 machine. When I do the same on macOS I get “objc\_disposeClassPair”…“still has subclasses, including 'NSKVONotify\_JUCEWIndow\_…”

This is using JUCE v4.3.1

---

<div class="post-metadata">

**Author:** ![bobsellon](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@bobsellon](https://forum.juce.com/u/bobsellon)\
**Post date:** [March 14, 2017, 6:19pm UTC](https://forum.juce.com/t/memory-leaks-using-the-webbrowsercomponent/21341/2 "2017-03-14T18:19:48Z")

</div>

I should add that there are always 3 leaks and that they are always 12, 16 and 12 bytes long.

Also, the first couple of bytes of each block seems to be the same each time I ran the app suggesting buffers with only 2 bytes used.

---

<div class="post-metadata">

**Author:** ![loopfine](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/loopfine/32/141_2.png) [@loopfine](https://forum.juce.com/u/loopfine)\
**Post date:** [March 14, 2017, 9:32pm UTC](https://forum.juce.com/t/memory-leaks-using-the-webbrowsercomponent/21341/3 "2017-03-14T21:32:22Z")

</div>

Same here. see below:

![](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/7/745dcf48ab46b596e85f67284f9db24d6ec7c563.PNG)

Windows 10, VS 2015, JUCE 4.3.1

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 15, 2017, 7:42am UTC](https://forum.juce.com/t/memory-leaks-using-the-webbrowsercomponent/21341/4 "2017-03-15T07:42:21Z")

</div>

If the leaks are only showing up in the VS debug window and aren’t triggering any of JUCE’s own leak-detection then they’re most likely bits of memory that the web browser itself is leaking.

Obviously leaking a handful of bytes once per run is no danger to anything at all, but my guess would be that the browser isn’t having time to shutdown itself cleanly - e.g. perhaps the message thread needs to run a bit after the browser is removed to let it mop up any pending messages in its queue. (Of course, it’s impossible for us to guess what the problem/fix would be if it’s in Microsoft code)

---

<div class="post-metadata">

**Author:** ![bobsellon](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@bobsellon](https://forum.juce.com/u/bobsellon)\
**Post date:** [March 15, 2017, 4:56pm UTC](https://forum.juce.com/t/memory-leaks-using-the-webbrowsercomponent/21341/5 "2017-03-15T16:56:16Z")

</div>

I was able to hold off the the quit() call using a timer triggered from the systemRequestedQuit() override nulling the webBrowser member but I’m still getting the leak.

I had been modifying the emulation mode of the embedded IE explorer to IE9 using the reg value with the app’s name in “HKEY\_CURRENT\_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE\_BROWSER\_EMULATION\” but other values did not change the leak so I don’t think it’s related but thought it was worth mentioning.

These are some macros for the various IE versions if anyone has any interest: (I included the comment from the microsoft [“Internet Features Control” page](https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx). )  
#define MicrosoftIEBrowserEmulation\_IE7 0x1B58 // (7000) IE7 Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.  
#define MicrosoftIEBrowserEmulation\_IE8 0x1F40 // (8000) IE8 Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8  
#define MicrosoftIEBrowserEmulation\_IE9 0x2328 // (9000) IE9 Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.  
#define MicrosoftIEBrowserEmulation\_IE9\_StandardsMode 0x270F // (9999) IE9 Windows Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.  
#define MicrosoftIEBrowserEmulation\_IE10 0x2710 // (10000) Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.  
#define MicrosoftIEBrowserEmulation\_IE10\_StandardsMode 0x2710 // (10001) Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.  
#define MicrosoftIEBrowserEmulation\_IE11 0x2AF8 // (11000) IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.  
#define MicrosoftIEBrowserEmulation\_IE11\_StandardsMode 0x2AF9 // (11001) Internet Explorer 11. Webpages are displayed in IE11 edge mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
