<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 10, 2014, at 10:20 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Could you describe the high level design here?<br class=""><br class="">It looks like there's a static pool (CodeGenDAGPatterns.cpp::memReclaimer) of instances that's used as some kind of last-chance cleanup? Instances of TreePatternNode mostly manage their own lifetime but then if any haven't been destroyed by the time the CodeGenDAGPatterns dtor runs, the remaining elements are destroyed. This is to handle cycles, I take it?<br class=""><br class="">It still seems like a bit of a GC-esque workaround to handle this case when there might be something better... but I don't know much about tablegen, perhaps there isn't.<br class=""><br class="">How often are nodes destroyed by themselves? Should we just give up owning these anywhere else & move all ownership into CodeGenDAGPatterns and clean them up in CodeGenDAGPatterns' dtor? (just have a vector of unique_ptrs (maybe even a list or deque of nodes directly owned, rather than via unique_ptr), only create nodes, never destroy them, then destroy them all at the end)</div></div></blockquote><div><br class=""></div><div>Thanks Hui Wu for simplifying this!</div><div><br class=""></div><div>David’s question makes sense to me and I’d be interested to know the answer. Does the proposal to give up ownership make sense to you; would it not significantly simplify the code even further?</div><div><br class=""></div><div>-Andy</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 10, 2014 at 9:58 PM, wuhui1973 <span dir="ltr" class=""><<a href="mailto:wuhui1973@163.com" target="_blank" class="">wuhui1973@163.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class="">Hi Andrew, David and Hal:</span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class=""><br class=""></span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class="">I have made a new solution for this memory leak issue, which is much simpler than previous one. </span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class=""><br class=""></span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class="">I have tested it, it works well!</span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class=""><br class=""></span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class="">Please have a look, and appreciate any comment.</span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class=""><br class=""></span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class="">Thanks & Regards</span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class=""><br class=""></span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><span style="line-height:23.7999992370605px" class="">Hui Wu</span></div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><br class=""></div></div><span title="neteasefooter" class=""><span class=""></span></span></div><br class=""><br class=""><span title="neteasefooter" class=""><span class=""></span></span></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>