Hello list,
while trying to build gcc-4.6.0 on my sparcstation, I got gengtype OOM
killed. That's when I noticed that its RAM usage peaks at 150MB, which is
a bit excessive for parsing a ~500K text file.
The attached patch fixes the leak and gengtype now uses a peak of 4MB
heap. Hopefully I don't do something wrong, since it took me a while to
understand those obstacks...
Thanks,
Dimitris
P.S. I was trying to test gcc on a rare arch (sparc-unknown-linux-gnu) but
unfortunately the sparcstation crashed and burned after this, so I can't
continue the build and report back :-(
--- gcc/gengtype-state.c.orig 2011-04-20 23:06:29.000000000 +0300
+++ gcc/gengtype-state.c 2011-04-20 23:12:43.000000000 +0300
@@ -303,7 +303,7 @@
obstack_1grow (&id_obstack, (char) 0);
ids = XOBFINISH (&id_obstack, char *);
sid = state_ident_by_name (ids, INSERT);
- obstack_free (&id_obstack, ids);
+ obstack_free (&id_obstack, NULL);
ids = NULL;
tk = XCNEW (struct state_token_st);
tk->stok_kind = STOK_NAME;
@@ -408,7 +408,7 @@
tk->stok_file = state_path;
tk->stok_next = NULL;
strcpy (tk->stok_un.stok_string, cstr);
- obstack_free (&bstring_obstack, cstr);
+ obstack_free (&bstring_obstack, NULL);
return tk;
}