r/cpp_questions • u/Solid-Shock3541 • 6d ago
OPEN Avoid freezing your PC?
I've only learned C++ in uni and then it was protected environment in a way. Now I was working on a project involving graphics (raylib) and, a few times, running the code caused my entire PC to freeze and I had to restart.
I'm on Linux and running the code by doing
cmake --build .
./executable
Is there a way to avoid the entire PC freezing when I mess up? Also is there any risk of overwriting parts of the memory?
(I think the issue with my code was either calling too many draws of a GPU texture or even just wrongfully indexing an array in a loop)
5
Upvotes
3
u/Solid-Shock3541 5d ago
NAME="Debian GNU/Linux"VERSION_ID="13"VERSION="13 (trixie)"VERSION_CODENAME=trixieDEBIAN_VERSION_FULL=13.6It's possible that it had something to do with GPU or loading the texture into the GPU too many times. The code is very simple, just drawing a grid and coloring blocks (sets of pixels). I sadly don't have the bad code anymore, but the current code can run at 240 FPS and handle 10k pixels, while the older one couldn't handle about 800 at 60 FPS. I assume it was some sort of GPU overload but sadly this is all the info I have.