Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch "OutOfMemory" exceptions to prevent the program from crashing #7

Open
RyanLaFauci opened this issue May 7, 2017 · 5 comments

Comments

@RyanLaFauci
Copy link

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.

@LazoCoder
Copy link
Owner

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?

@RyanLaFauci
Copy link
Author

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.

@LazoCoder
Copy link
Owner

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.

@RyanLaFauci
Copy link
Author

RyanLaFauci commented Jun 1, 2017

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.

@LazoCoder
Copy link
Owner

Awesome, thanks. I'll see what I can do about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants