Review Request: Patch to reduce C++ memory consumption by removing DuContext* pointer from the AST

David Nolden zwabel at
Mon Feb 15 17:19:54 UTC 2010

Am Montag 15 Februar 2010 18:14:53 schrieb Alexander Dymo:
> 2010/2/15 Alexander Dymo <alexander.dymo at>:
> > C++ parser's AST base class has "KDevelop::DUContext* ducontext" pointer
> > which isn't used for most of the nodes. For example, the primary
> > expression AST nodes do not open a new context and if your file is big,
> > the memory is wasted.
> >
> > This patch removes the context pointer from AST and instead fills a
> > QMap<AST*, DuContext*> in the ParseSession class.
> >
> > For me and my huge files this saves ~50M of memory.
> >
> > Note, that the map will be ~2% slower than the pointer (when building
> > uses for example).
> David, what's your opinion on this? Is the gain in memory consumption
> worth the loss in performance? I still haven't decided on this myself.

Hmm but where does the performance loss come from? Normally we don't store the 
AST, and in such a case we also shouldn't build the parent-map, so it should 
not affect our normal usage.

Greetings, David

More information about the KDevelop-devel mailing list