------- Comment #2 from rguenth at gcc dot gnu dot org 2010-06-17 10:36 ------- The issue is not so much the number of functions but the number of calls in main (and thus its size).
With GCC 4.3.4 I see parser : 6.87 (12%) usr 0.79 (14%) sys 8.14 (13%) wall 266316 kB (18%) ggc expand : 14.02 (24%) usr 1.38 (25%) sys 15.50 (24%) wall 619261 kB (41%) ggc global alloc : 10.65 (18%) usr 0.27 ( 5%) sys 10.79 (17%) wall 81920 kB ( 5%) ggc final : 6.16 (11%) usr 0.17 ( 3%) sys 6.21 (10%) wall 32704 kB ( 2%) ggc TOTAL : 57.78 5.60 63.76 1509835 kB peaking at 1.3GB virtual memory usage. With GCC 4.5 I see parser : 1.81 ( 3%) usr 0.66 ( 5%) sys 2.42 ( 3%) wall 196460 kB (13%) ggc expand : 15.24 (25%) usr 3.45 (28%) sys 18.95 (26%) wall 506302 kB (34%) ggc integrated RA : 11.75 (20%) usr 0.27 ( 2%) sys 12.09 (17%) wall 89600 kB ( 6%) ggc reload : 6.07 (10%) usr 0.15 ( 1%) sys 5.98 ( 8%) wall 54527 kB ( 4%) ggc thread pro- & epilogue: 2.97 ( 5%) usr 0.08 ( 1%) sys 3.22 ( 4%) wall 131586 kB ( 9%) ggc final : 4.73 ( 8%) usr 0.15 ( 1%) sys 5.17 ( 7%) wall 36288 kB ( 2%) ggc TOTAL : 59.83 12.45 72.64 1504261 kB peaking at 1.7GB virtual memory usage. Turning on basic optimization (-O1) inlines all your functions making main() smaller, reducing peak memory usage to around 1GB but using a lot of compile-time (I stopped it after 10min). You basically have a gigantic basic-block in main() and GCC isn't tuned to handle that case well. Removing the main() function unfortunately doesn't make GCC behave much saner here with regarding to memory usage. Removing all functions but main reproduces the above figures with slightly reduced memory usage and increased compile-time because the functions are not known to be const. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Keywords| |compile-time-hog, memory-hog Last reconfirmed|0000-00-00 00:00:00 |2010-06-17 10:36:48 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44563