I learnt about WPF transparency and memory exceptions

I was seeing a very strange issue in WPF where resizing a window across multiple monitors generated an insufficient memory exception.

Making it full height and then resizing horizontally, making it full width and then resizing vertically and combinations enabled me to plot the widths and heights that the application crashed. This translated into an almost straight line.

Cutting the application back to just creating a window it still crashed. Another application did not crash.

After much investigation it turns out that the difference was that AllowTransparency was set to true in the one that crashes. This seems to cause the memory usage to jump. So now to solve this my custom window style has a white background that is only visible in the corners. Not a great solution but needed as the user could need to resize the window across multiple monitors.

As an aside, trying this on a colleague’s machine did not cause the error, however he has a significantly improved graphics card.