Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
jmclemo66807yIf you have access to C++11 you could use the smart pointers (shared_ptr, unique_ptr) introduced in it.
-
donuts238487ybtw... so is there actually a Garbage Collector utility in C++ lib or do u usually just use delete?
And i guess getting ahead of the book but... why would i ever need to use malloc?
or is this how you declare arrays? -
donuts238487y
-
jmclemo66807y@billgates I would assume you have C++11 support then. I use Vim and g++ by themselves though, so you would have to look it up to make sure. :P
-
donuts238487y@Artemix ok... So basically this book is teaching everything WRONG.... crap....
So need to start over again... -
There actually is a pretty good garbage collector for C/C++ called the Boehm GC
http://www.hboehm.info/gc/
But since C++ was never meant to be garbage collected it can result in some hard-to-find bugs.
You can also roll your own GC without much effort (because C++ lets you work with low level memory manipulation). The advantage here is that your GC can be optimized for your application (eg. a GC for a game engine would have different requirements compared to a GC for a simple desktop app).
However, good C++ coding practices (smart pointers, etc) more-or-less make GCs unnecessary. If you're really scared of memory leaks you may want to switch to a GC-ed language like C# or Java. -
donuts238487y@hsbfsix I'm not scared... Just saying this feels new and maybe good... C++ developers all know how to clean up their shit... Unlike a lot of Java developers...
-
@billgates hey we are occupied with cleaning up enterprise-level shit okay?
@Artemix yeah my bad, seems like i cant fucking read -
@billgates
Yeah sorry, didn't mean it that way.
Like I said, what you use should depend on the application.
And also, welcome to the world of memory management! -
QCat8367yIf you are very lazy or truly need a garbage collector, you can use Hans boehm garbage collector. I used it to make a Lisp interpreter and it is amazing, but atrociously complicated
So in C++ there is no garbage collector to clean up the mess u leave behind?
And now i feel like a garbage collector.... always cleaning up after monkeys... :(
undefined