Hacker News new | past | comments | ask | show | jobs | submit login

Some simple habits, like always writing your malloc() and free() calls at the same time in balanced pairs, can make C quite managable.

One can also use the Boehm GC if they feel it necessary.




I'm curious as to who uses a garbage collector in C. It seems like if you're using C, you probably are in a situation where you want as close control of that kind of stuff as possible (short of assembly).


GCC and Mono use it internally, I believe.

It's a very conservative garbage collector at the end of the day. It can be tweaked so as to be completely bare bones, and the performance impact is very benign. Rather, memory consumption is its weakness.


The same thing can be said about malloc. It's a matter of degree, and different projects have (sometimes subtly) different requirements.


Expanding - in particular, Boehm seems to only run collections on allocations. If your code is structured such that you don't allocate during periods when you need more precise control (already a good idea, if you are using malloc!) then this won't have an impact.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: