I think that's a valid concern; besides using an alternate data structure for 
InitListExprs one could also consider extending ASTVector (or something more 
generic) to recycle memory, regardless of the underlying allocator.  This could 
be done by passing something else other than ASTContext& to the ASTVector that 
manages the freelist and when necessary grabs new memory from ASTContext (or 
whatever is used for the underlying allocation).

Note that InitListExpr is not the only place where we use a "vector" in the 
ASTs, and in those cases we leak memory as well.

On Apr 14, 2010, at 4:59 AM, Benjamin Kramer wrote:

> 
> On 14.04.2010, at 01:39, Ted Kremenek wrote:
> 
>> Author: kremenek
>> Date: Tue Apr 13 18:39:09 2010
>> New Revision: 101194
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=101194&view=rev
>> Log:
>> Introduce ASTVector, which is a std::vector-like class that allocates all 
>> memory
>> using the allocator associated with an ASTContext.  This is largely 
>> copy-and-paste
>> from SmallVector, and should be refactored one day.
> 
> I was thinking about this before and came to the conclusion that a 
> BumpPtrAllocator + vector is a
> bad combination. Every time the vector resizes the old memory isn't freed and 
> adds up. I guess
> it doesn't matter in smaller cases but it could become a huge memory waste if 
> we're not checking every
> ASTVector's insert characteristics carefully. In my opinion a list-like data 
> structure should be
> preferred (where applicable).


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to