Memory leaks using the WebBrowserComponent


#1

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


#2

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.


#3

Same here. see below:

Windows 10, VS 2015, JUCE 4.3.1


#4

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)


#5

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. )
#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.