-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Debunking "bad_alloc" and out of memory errors in C++ #421
Comments
I agree, it's certainly quite manageable on some operating systems, though there are issues in the language that make it sketchy. A typical example is software that allows opening multiple projects in the same process, if opening a project results in running out of memory it can safely be rolled back and the other open projects (which may have unsaved changes) can remain open and unharmed. The problem is that the way C++ exceptions are dynamically allocated means the exception throwing code can itself fail. You could hope and pray that compiler implementers carve out some special memory or special handling for Another issue is that some operating systems use overcommit, where they give you a pointer to memory that they tell you they've allocated, when actually all they've done is allocate the address space and not the backing memory. Then you don't find out there's a problem until you access every page of that memory and force the OS to fault in the pages, at which point it's usually too late (or too troublesome) to do anything but terminate the process. You don't ever get |
Coming in Ep451 |
Some have said that there's no meaningful way to deal with out of memory in C++, but I have students who regularly deal with this stuff, so I'm recording an episode about it.
The text was updated successfully, but these errors were encountered: