<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 21, 2016 at 9:08 PM, Pete Cooper <span dir="ltr"><<a href="mailto:peter_cooper@apple.com" target="_blank">peter_cooper@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><span class=""><div>On Mar 21, 2016, at 9:05 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br></span><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Mon, Mar 21, 2016 at 8:44 PM, Pete Cooper via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: pete<br>
Date: Mon Mar 21 22:44:32 2016<br>
New Revision: 264022<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264022&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=264022&view=rev</a><br>
Log:<br>
Use owning pointers instead of raw pointers for Atom's to fix leaks.<br>
<br>
Currently each File contains an BumpPtrAllocator in which Atom's are<br>
allocated. Some Atom's contain data structures like std::vector which<br>
leak as we don't run ~Atom when they are BumpPtrAllocate'd.<br></blockquote><div><br></div></span><div>FWIW, if the only thing allocated in the BumpPtrAllocator is Atoms, you could use a SpecificBumpPtrAllocator, which does run the doors.<br></div></div></div></div></div></blockquote>I think there might be Reference’s in there, but worth investigating doing it this way. Unfortunately the Window’s bots didn’t like what I did here so i’ve reverted for now.<span class=""><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>(& if the BumpPtrAllocator doesn't contain only Atoms, you could change it so it does)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Now each File actually owns its Atom's using an OwningAtomPtr. This<br>
is analygous to std::unique_ptr and may be replaced by it if possible.<br></blockquote><div><br>Yeah, this looks like it could just be a typedef of unique_ptr with a custom deleter that only runs the dtor but doesn't delete, etc.</div></div></div></div></div></blockquote></span>Just tried this as a quick fix to get the bots to work. Unfortunately the YAML parser doesn’t like that solution. The problem is that the YAML parser wants to take a reference to a pointer, so i had to make the get() methods be defined as follows to support that. std::unique_ptr doesn’t return a reference from get() so the YAML parser stops working with them.</div></div></blockquote><div><br></div><div>Ah, yeah, that's not a safe operation (in the mutable case, especially) for a smart pointer - so if we're going to smart pointerify these things, probably need to adjust that code no matter which smart pointer we use.<br><br>Did you try making the dtor virtual to fix MSVC's issues? If you are destroying derived objects your dtor does need to be virtual if you're calling it from a base object expression. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class=""><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
+ T *const &get() const {<br>
+ return atom;<br>
+ }<br>
+<br>
+ T *&get() {<br>
+ return atom;<br>
+ }<br>
+</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote></div></div></div></div></blockquote><div><br></div></span><div>Cheers,</div><div>Pete</div></div></div></blockquote></div><br></div></div>