Sign in to follow this  

Something I need to watch for?

This topic is 4588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

During work today on my current project, I noticed the most recent compilation [using gcc] took quite a while on my dev machine, despite very modest changes. Poking around it looks as though the most recent changes were just enough to make the compilation process use more memory than was available, causing the swapper to come in and bog everything down. The machine has a slim 64meg, and is easily increased... The rather sizable executable [2.6meg] was suprising as well, though disabling debugging information [~.8meg] and turning on optimization [~.5 meg] helped in that regard... But the actual code is only about 150k, and I expect will become quite a bit more sizable before completion. This is my first sizable project with templating code, or common use of the Standard Library. I know that both [or rather either] will increase compilation times and the size of the binary compared to actual code, but -this- much? Is there some sort of code pattern which can cause such large compiler footprints? It's not really a problem now, but I'd hate to add more ram, only to max that out in a month or so as the project grows because of some faux pas on my part.

Share this post


Link to post
Share on other sites
Templates are notable for code bloat because the naive implementation requires one copy of the function for every type you throw through it. Optimisation may be able combine some of those functions, and you may also be able to combine some of them yourself (by factoring out any type-independent functionality into non-template functions). But I wouldn't worry about doing the latter unless it's a real problem. As for the debug information, it's quite typical for it to be that much. And sadly, 64MB is not a lot of memory for a C++ compiler these days. :( I believe templates are leading culprits here also, due to their cookie cutter nature requiring a memory-based instantiation before the linking stage. (That's pure speculation though since I've not looked into compiler technology for a while.)

Share this post


Link to post
Share on other sites

This topic is 4588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this