<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I’m not involved with however our threading is implemented or used ;) All I know is that we’re trying to match each allocation with a de-allocation and the
 way the LLVM code currently works is not compatible with this philosophy. Because we felt this might have been an issue with LLVM itself we decided to go here and ask you guys.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">We will probably just patch LLVM locally (argh, I can already hear the muttered curses of the people who have to re-patch a future version upgrade… Haha).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></a></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Kostya Serebryany [mailto:kcc@google.com]
<br>
<b>Sent:</b> Wednesday, March 19, 2014 15:29<br>
<b>To:</b> Bryan Keiren<br>
<b>Cc:</b> Caldarale, Charles R; llvmdev@cs.uiuc.edu<br>
<b>Subject:</b> Re: [LLVMdev] getElapsedWallTime unnecessary heap allocation and memory leak<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Wed, Mar 19, 2014 at 6:18 PM, Bryan Keiren <<a href="mailto:bryan.keiren@guerrilla-games.com" target="_blank">bryan.keiren@guerrilla-games.com</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal">We are indeed trying to completely clean the heap before exiting main().<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Which means that you either don't have threads, or you join all threads before main exits.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Is that the case?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Good for you if so! <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><br>
<br>
-----Original Message-----<br>
From: Caldarale, Charles R [mailto:<a href="mailto:Chuck.Caldarale@unisys.com">Chuck.Caldarale@unisys.com</a>]<br>
Sent: Wednesday, March 19, 2014 14:42<br>
To: Bryan Keiren; <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
Subject: RE: [LLVMdev] getElapsedWallTime unnecessary heap allocation and memory leak<br>
<br>
> From: <a href="mailto:llvmdev-bounces@cs.uiuc.edu">llvmdev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvmdev-bounces@cs.uiuc.edu">llvmdev-bounces@cs.uiuc.edu</a>]<br>
> On Behalf Of Bryan Keiren<br>
> Subject: [LLVMdev] getElapsedWallTime unnecessary heap allocation and<br>
> memory leak<br>
<br>
> In the file \lib\Support\Process.cpp on line 60, it seems as though an<br>
> unnecessary heap allocation and memory leak occurs.<br>
<br>
> static TimeValue getElapsedWallTime() {<br>
>  static TimeValue &StartTime = *new TimeValue(TimeValue::now());<br>
>  return TimeValue::now() - StartTime;<br>
> }<br>
<br>
> The issue is that the StartTime variable's value is allocated on the<br>
> heap, after which a *reference* to it is stored (not the pointer<br>
> itself). This means that the allocated memory is actually never properly de-allocated.<br>
<br>
Since the StartTime field is static, why is this considered a leak?  The reference has not been lost and is utilized whenever getElapsedWallTime() is invoked.  Although it might be infinitesimally more efficient to avoid the new operator, the overall memory
 consumption is almost identical.<br>
<br>
Are you trying to get rid of the entire heap at some point before process termination?<br>
<br>
 - Chuck<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">
http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>