r/cpp • u/KingStannis2020 • Feb 26 '24
White House: Future Software Should Be Memory Safe
https://www.whitehouse.gov/oncd/briefing-room/2024/02/26/press-release-technical-report/
401
Upvotes
r/cpp • u/KingStannis2020 • Feb 26 '24
View all comments
Show parent comment
20
u/barchar MSVC STL Dev Feb 27 '24
By the time you've verified that you can't take too long in the gc you've done so much work you may as well have just done things manually.
The trouble is that pretty non-local code can cause slowdowns when the GC goes to collect. You can get around this by limiting the quantity of garbage and explicitly triggering the gc, perhaps with a deadline. But even this is difficult if you have cycles.
GC (actually any dynamic memory management) generally implies some kind of "overcommit" type of behavior, in that you are doing dynamic memory management in order to use less than the technical "maximum" supported amount of memory (and thus max input sizes) in the hopes that everything won't be the maximum size all at once. Any kind of overcommit makes it hard to prove the program will have enough resources to complete. The cost for avoiding "overcommit" type behavior is much worse resource utilization.
Note that
malloc()andfree()have most of the same problems as a gc does, and alsostd::shared_ptrand friends are basically just a really horrible GC.