On Wed, Nov 10, 2010 at 12:59 AM, Ted Kremenek <[email protected]> wrote:
> Author: kremenek
> Date: Tue Nov 9 23:59:39 2010
> New Revision: 118675
>
> URL: http://llvm.org/viewvc/llvm-project?rev=118675&view=rev
> Log:
> Region-allocate all AttributeList objects from a factory object instead of
> manually managing them
> using new/delete and OwningPtrs. After memory profiling Clang, I witnessed
> periodic leaks of these
> objects; digging deeper into the code, it was clear that our management of
> these objects was a mess. The ownership rules were murky at best, and not
> always followed. Worse, there are plenty of error paths where we could screw
> up.
>
> This patch introduces AttributeList::Factory, which is a factory class that
> creates AttributeList
> objects and then blows them away all at once. While conceptually simple,
> most of the changes in
> this patch just have to do with migrating over to the new interface. Most of
> the changes have resulted in some nice simplifications.
>
> This new strategy currently holds on to all AttributeList objects during the
> lifetime of the Parser
> object. This is easily tunable. If we desire to have more bound the
> lifetime of AttributeList
> objects more precisely, we can have the AttributeList::Factory object (in
> Parser) push/pop its
> underlying allocator as we enter/leave key methods in the Parser. This means
> that we get
> simple memory management while still having the ability to finely control
> memory use if necessary.
>
> Note that because AttributeList objects are now BumpPtrAllocated, we may
> reduce malloc() traffic
> in many large files with attributes.
>
> This fixes the leak reported in: <rdar://problem/8650003>
>
I don't know exactly why but this patch introduced a bunch of warnings
on MSVC 2008.
D:\Dev\llvm\llvm_trunk\tools\clang\include\clang/Sema/AttributeList.h(74)
: warning C4291: 'void *operator new(size_t,void *) throw()' : no
matching operator delete found; memory will not be freed if
initialization throws an exception
C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\include\new(57) : see declaration of 'operator new'
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits