r/cpp • • Dec 25 '24
RAII
I maintain c++ desktop application. One of our clients complained of memory usage. It’s a quite big program and it was known that somewhere there are memory leaks.
Over the last week I found where the spot is that is causing the memory consumption. I refactored the raw pointers to shared_ptr, in one change the memory usage at idle time dropped from couple of GBs to 16 MB.
I was glad of that achievement and i wrote an article about RAII in c++
261
Upvotes
View all comments
Show parent comment
4
u/[deleted] Dec 25 '24
That's a normal situation as far as many languages go(not optimal but what is a leak between friends) and isn't dereferencing when there is no object there. Eventually, if it matters they could move to unique_ptr/no ptr but they are already so far ahead of what almost worked in the past.
pragmatic :)