Windows-Hacks
Windows-Hacks copied to clipboard
Catch "OutOfMemory" exceptions to prevent the program from crashing
I ran this program on a computer that only had 4 GB of RAM, and about half of the hacks crashed the program. Instead of crashing the program, you should catch these exceptions and alert the user that the specific hack they were trying to use is too intense for their PC.
This is a good idea but this issue is strange because the PC that I built this on also has only 4 GB of RAM and I never experienced any crashing.
I added a try-catch to the second hack (Rotate Desktop) and I was just about to add try-catches to all the rest, but then it occurred to me that garbage collection should be cleaning up the memory and 4 GB should be more than enough.
Are you using some sort of ultra high resolution external monitor?
Not at all, the 4 GB computer simply has two regularly sized monitors. The weird thing too is that I later tested it on my 8 GB laptop and it still threw these exceptions.
Could you copy and paste the error message / stack trace on here so I can see which line of code is causing the issue? It would help a lot. Thanks.
at System.Drawing.Bitmap.Clone(Rectangle rect, PixelFormat format)
at ImageProcessing.Tools.Crop(Bitmap bmp, Rectangle rec)
at WindowsHacks.HueShifter.Run() in C:\Users\RyanL\Downloads\Windows-Hacks-master\WindowsHacks\HueShifter.cs:line 36
Line 36 for me is the "bmp = Tools.Crop(bmp, new Rectangle(
" line, may differ from what's on master.
Awesome, thanks. I'll see what I can do about this.