These both come from third party developers - one I was aware of and one was completely new to me.
The Debug Heap Is Slow
Veteran Windows C++ developers know this, but if you don't spend a lot of time with MSVC, this might be new.
The default configuration of MSVC is to force use of the debug heap when the debugger is attached; this applies even to release builds of binaries that aren't yours.
What this means is: if you do nothing else but start your plugin "inside" X-Plane, X-Plane will use Microsoft's debug heap.
We avoid doing this internally because it is really, really, really slow. The debug heap provides some great tracking for finding memory problems, but the cost is really, really slow load time.
The fix is simple: add _NO_DEBUG_HEAP=1 to the environment variables for your debugger. You can do this in the control panel as shown in the linked article, or you can add it to MSVC's debugger properties.
Other Things To Go Fast
As a side tangent, when debugging a plugin, find ways to load X-Plane faster. A few things that can help:
- Turn off AI aircraft.
- Pick a simple aircraft to fly (e.g. not the 747).
- Go somewhere without scenery (or without much scenery, e.g. PMDY).
- If you have to have scenery, turn 3-d all the way off.
My Plugin Won't Reload
We receive periodic bug reports that plugins won't reload on Windows. This is miserable for you as a third party developer - it means rebooting the sim instead of just reloading your plugin. But why does it happen?
I thought we had a bug, but a third party developer found this:
I did searched the registry for the names I've used for X-Plane 11 folder and found this items at
Each name used was included there with "$IgnoreFreeLibrary<win.xpl>"
value, after removing them and restarting X-Plane I got able to compile the plugin using the names again.
I have not found any official Microsoft documentation on this, just a lot of ranting from really annoyed programmers who want to know why the hell Microsoft would do this. If anyone has better Google-Fu than me and can find official docs, please do share. So what follows is my wild speculation of what's going on.
In some old version of Windows, FreeLibrary probably didn't actually (or immediately) free a DLL under certain circumstances. Application developers then wrote buggy apps that relied on this behavior, e.g. they freed a library while it was in use and their app didn't crash.
Microsoft updated Windows and made FreeLibrary do what it says on the label, always, and old buggy apps started crashing left and right.
Microsoft, being Microsoft, did not say "you app developers are idiots, why don't you go rewrite your buggy apps". Instead, they added a feature to the App Compatibility Wizard that watches your app and, if it crashes after a DLL was unloaded and the moon is the right shade of Rondele, it adds a registry key marking this library as "never to be unloaded, even if this app says so".
From that point on, the app doesn't crash because the old semantics of FreeLibrary ("ha ha ha, you don't mean that do you") are restored in that one case.
The above is entirely made up - it's my mental model for what might have happened, unless Raymond Chen someday gives us some back story.
Still, you can see what has gone wrong here - Windows decided that for compatibility reasons, plugins should not actually be unloaded, and since all of your DLLs are named win.xpl, this one plugin crash has caused plugins to never be unloaded. Thus the plugin unload/reload never releases the DLL and you can't swap in new code.
Nuke the registry key and you're back in business, at least until you crash again.