9cc icon indicating copy to clipboard operation
9cc copied to clipboard

On free()

Open mcandre opened this issue 7 years ago • 1 comments

Compilers may be short-lived programs, but they often capitalize on a large amount of memory even when they are using free(). For example, installing dependencies in C, C++, Java, Node.js, and Haskell tends to require upwards of 4GB of memory on build machines. Some operating systems / dev tool pairs are more efficient, using <1GB of memory. But in general, compilation tends to be one of the most memory-intensive things you can do! And I'm not talking about building complex projects like the Linux kernel or video games, I'm talking about absolute minimum requirements to build small-to-medium size middleware projects you'd find on GitHub.

I think 8cc/9cc is a cool project, but for building projects of realistic size, it is probably worth freeing memory whenever we can. Otherwise, many projects may require more buildtime memory hardware than a typical laptop offers. Does that make sense?

I do think it is cool to think about different memory styles, like skipping free() closer to the end of main() functions... But valgrind isn't smart enough to handle that, so I tend to put them there anyway :P

mcandre avatar Dec 14 '18 20:12 mcandre

The D reference compiler doesn't free() in order to improve performance.

odeits avatar Dec 16 '18 00:12 odeits