|
14 | 14 | [3] <span class="sgr1">similar</span>
|
15 | 15 | <span class="sgr90"> @</span> <span class="sgr90">./<span class="sgr4">array.jl:420</span> [inlined]</span>
|
16 | 16 | [4] <span class="sgr1">\</span>
|
17 |
| -<span class="sgr90"> @</span> <span class="sgr90">/opt/hostedtoolcache/julia/1.10.0-rc3/x64/share/julia/stdlib/v1.10/LinearAlgebra/src/<span class="sgr4">triangular.jl:1483</span> [inlined]</span> |
| 17 | +<span class="sgr90"> @</span> <span class="sgr90">/opt/hostedtoolcache/julia/1.10.0/x64/share/julia/stdlib/v1.10/LinearAlgebra/src/<span class="sgr4">triangular.jl:1483</span> [inlined]</span> |
18 | 18 | [5] <span class="sgr1">\(</span><span class="sgr90">A</span>::Matrix<span class="sgr90">{Float64}</span>, <span class="sgr90">B</span>::Vector<span class="sgr90">{Float64}</span><span class="sgr1">)</span>
|
19 |
| -<span class="sgr90"> @</span> <span class="sgr35">LinearAlgebra</span> <span class="sgr90">/opt/hostedtoolcache/julia/1.10.0-rc3/x64/share/julia/stdlib/v1.10/LinearAlgebra/src/<span class="sgr4">generic.jl:1118</span></span> |
| 19 | +<span class="sgr90"> @</span> <span class="sgr35">LinearAlgebra</span> <span class="sgr90">/opt/hostedtoolcache/julia/1.10.0/x64/share/julia/stdlib/v1.10/LinearAlgebra/src/<span class="sgr4">generic.jl:1118</span></span> |
20 | 20 | [6] <span class="sgr1">var"##linsolve#228"(</span><span class="sgr90">a</span>::Matrix<span class="sgr90">{Float64}</span>, <span class="sgr90">b</span>::Vector<span class="sgr90">{Float64}</span><span class="sgr1">)</span>
|
21 | 21 | <span class="sgr90"> @</span> <span class="sgr36">Main</span> <span class="sgr90">./<span class="sgr4">REPL[1]:1</span></span>
|
22 | 22 | </code></pre><p>we see what type of object was allocated, and where in the code the allocation appeared.</p><h3 id="Functions-that-throw-exceptions"><a class="docs-heading-anchor" href="#Functions-that-throw-exceptions">Functions that throw exceptions</a><a id="Functions-that-throw-exceptions-1"></a><a class="docs-heading-anchor-permalink" href="#Functions-that-throw-exceptions" title="Permalink"></a></h3><p>Some functions that we do not expect may allocate memory, like <code>sin</code>, actually may:</p><pre><code class="language-julia hljs">@allocated try sin(Inf) catch end</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">48</code></pre><p>The reason for this is that <code>sin</code> needs to allocate if it <strong>throws an error</strong>.</p><p>By default, <code>@check_allocs</code> ignores all such allocations and assumes that no exceptions are thrown. If you care about detecting these allocations anyway, you can use <code>ignore_throw=false</code>:</p><pre><code class="language-julia hljs">@check_allocs mysin1(x) = sin(x)
|
23 | 23 | @check_allocs ignore_throw=false mysin2(x) = sin(x)
|
24 | 24 |
|
25 | 25 | @test mysin1(1.5) == sin(1.5)
|
26 | 26 | @test_throws AllocCheckFailure mysin2(1.5)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi"><span class="sgr32"><span class="sgr1">Test Passed</span></span>
|
27 |
| - Thrown: AllocCheckFailure</code></pre><h2 id="Limitations"><a class="docs-heading-anchor" href="#Limitations">Limitations</a><a id="Limitations-1"></a><a class="docs-heading-anchor-permalink" href="#Limitations" title="Permalink"></a></h2><p>Every call into a <code>@check_allocs</code> function behaves like a dynamic dispatch. This means that it can trigger compilation dynamically (involving lots of allocation), and even when the function has already been compiled, a small amount of allocation is still expected on function entry.</p><p>For most applications, the solution is to use <code>@check_allocs</code> to wrap your top-level entry point or your main application loop, in which case those applications are only incurred once. <code>@check_allocs</code> will guarantee that no dynamic compilation or allocation occurs once your function has started running.</p></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="tutorials/optional_debugging_and_logging/">Optional debugging and logging »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="auto">Automatic (OS)</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.2.1 on <span class="colophon-date" title="Wednesday 20 December 2023 16:13">Wednesday 20 December 2023</span>. Using Julia version 1.10.0-rc3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
| 27 | + Thrown: AllocCheckFailure</code></pre><h2 id="Limitations"><a class="docs-heading-anchor" href="#Limitations">Limitations</a><a id="Limitations-1"></a><a class="docs-heading-anchor-permalink" href="#Limitations" title="Permalink"></a></h2><p>Every call into a <code>@check_allocs</code> function behaves like a dynamic dispatch. This means that it can trigger compilation dynamically (involving lots of allocation), and even when the function has already been compiled, a small amount of allocation is still expected on function entry.</p><p>For most applications, the solution is to use <code>@check_allocs</code> to wrap your top-level entry point or your main application loop, in which case those applications are only incurred once. <code>@check_allocs</code> will guarantee that no dynamic compilation or allocation occurs once your function has started running.</p></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="tutorials/optional_debugging_and_logging/">Optional debugging and logging »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="auto">Automatic (OS)</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.2.1 on <span class="colophon-date" title="Wednesday 31 January 2024 13:55">Wednesday 31 January 2024</span>. Using Julia version 1.10.0.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
0 commit comments