OutOfMemoryException in Wallpaper Changer

Posted by

I’ve been able to (finally) track down the OutOfMemory exceptions that Wallpaper Changer has sometimes been known to throw. Until now I hadn’t been able to reproduce the problem, but just this morning I downloaded a new image and go the error.

It seems it has to do with corrupted JPEGs – the GDI+ code that I use seems to throw OutOfMemory on all sorts of errors, and corrupted JPEGs is one of them. I discovered the problem as I was downloading a new image – I didn’t realise it was still downloading, and when I tried to open it in Wallpaper Changer, it threw the error.

Looking at the documentation, pretty much the only two documented exceptions for Image.FromFile are FileNotFoundException and OutOfMemoryException.

So anyway, if you’re running into this problem, try loading the image in another program, and if it works there, just try to save the file again and see if that fixes it in Wallpaper Changer.

Unfortunately, since I moved house and changed computers, I no longer have the source code for Wallpaper Changer, so unless I do a re-write, updates are unlikely :(

blog comments powered by Disqus