<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi there,<div><br></div><div>I have a somewhat strange problem which may be related to my limited knowledge of ADOL-C, nevertheless I would very much appreciate your help :-)</div><div><br></div><div>Lots of memory seem to be allocated (until the program crashes) during runtime of the following program the program also gets increasingly slow during runtime. Please note that in this program never a tape is written, and no adoubles are allocated after calling the setup() function. Most interestingly, the issue goes away, if I do comment out the first line of setup().</div><div><br></div><div>I believe that this problem is caused because the automatic variable is allocated _before_ the huge array is allocated, but freed automatically _after_ creation of the array.</div><div><br></div><div>Any help is welcome! And yes -- I tried to google around for a while before asking the list..</div><div><br></div><div>Best regards</div><div><br></div><div>Martin</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(217, 40, 35); "><span style="color: #7b482f">#include </span><adolc/adolc.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(123, 72, 47); ">#define BLASIZE <span style="color: #2f2fcf">1024</span>*<span style="color: #2f2fcf">32</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #753ea3">adouble</span> * <span style="color: #488186">bla</span> = <span style="color: #c22a9c">NULL</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #753ea3">adouble</span> * makeBla(){<span style="color: #c22a9c">return</span> <span style="color: #c22a9c">new</span> <span style="color: #753ea3">adouble</span>[<span style="color: #7b482f">BLASIZE</span>];}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #c22a9c">void</span> setup()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #753ea3">adouble</span> m1 = <span style="color: #2f2fcf">1.0</span>; // no problems will occur, if this is commented out!</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #488186">bla</span> = <span style="color: #2c595d">makeBla</span>();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #c22a9c">void</span> cleanup()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(194, 42, 156); "><span style="color: #000000"> </span>delete<span style="color: #000000"> </span><span style="color: #488186">bla</span><span style="color: #000000">;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #c22a9c">void</span> fn(<span style="color: #c22a9c">double</span> *x) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #488186">bla</span>[<span style="color: #2f2fcf">0</span>] = x[<span style="color: #2f2fcf">0</span>];<span style="color: #008426">//t3 +t1;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #488186">bla</span>[<span style="color: #2f2fcf">1</span>] = x[<span style="color: #2f2fcf">1</span>];<span style="color: #008426">//t3 - t2;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #c22a9c">for</span>(<span style="color: #c22a9c">int</span> i = <span style="color: #2f2fcf">2</span>; i < <span style="color: #7b482f">BLASIZE</span>; i++){<span style="color: #488186">bla</span>[i] = <span style="color: #488186">bla</span>[i-<span style="color: #2f2fcf">1</span>] + <span style="color: #488186">bla</span>[i-<span style="color: #2f2fcf">2</span>];}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(194, 42, 156); "><span style="color: #000000"> </span>return<span style="color: #000000">;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span style="color: #c22a9c">int</span> main(<span style="color: #c22a9c">void</span>){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #c22a9c">double</span> x[<span style="color: #2f2fcf">2</span>] = {<span style="color: #2f2fcf">0</span>,<span style="color: #2f2fcf">0</span>};</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #2c595d">setup</span>();</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #c22a9c">for</span> (<span style="color: #c22a9c">int</span> i = <span style="color: #2f2fcf">0</span>; i < <span style="color: #2f2fcf">200</span>; i++) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #753ea3">std</span>::<span style="color: #753ea3">cout</span> << i ;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #c22a9c">for</span>(<span style="color: #c22a9c">int</span> j = <span style="color: #2f2fcf">0</span>; j < <span style="color: #2f2fcf">100</span>; j++) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> x[<span style="color: #2f2fcf">0</span>] = i * <span style="color: #2f2fcf">0.001</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> x[<span style="color: #2f2fcf">1</span>] = j * <span style="color: #2f2fcf">0.001</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #2c595d">fn</span>(x);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #753ea3">std</span>::<span style="color: #753ea3">cout</span> << <span style="color: #d92823">"*"</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> <span style="color: #753ea3">std</span>::<span style="color: #753ea3">cout</span> << <span style="color: #753ea3">std</span>::endl;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "> }</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"> <br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(44, 89, 93); "><span style="color: #000000"> </span>cleanup<span style="color: #000000">();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div></div><div><br></div><div><br></div><div><div><br class="Apple-interchange-newline">
</div>
<br></div></body></html>