Today while I was working on my thumbnail generator I ran into a nasty OutOfMemoryException while creating thumbnails from JPEG/JPG files. Of course I spent time pouring over my code to find the memory leak but when nothing turned up, I started researching the problem. Turns out that my code was good, and the issue lies partly with GDI. It turns out that GDI throws the OutOfMemoryException as a default exception. I looked to the images I was converting and found the issue was caused by some invalid images. The file system reported their sizes as 0. As soon as I deleted them, the thumbnail utility worked without issue.