Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You may be misreading the valgrind output. Most likely, there is no (obvious) leak here as R is pretty well studied as a system. Yet R is a dynamically typed language which has of course done allocations. "Definitely lost: 120 bytes" is essentially measurement error -- see the valgrind docs.</p> <p>If you want to see a leak, create one, e.g., with a file like this:</p> <pre><code>library(Rcpp) cppFunction('int leak(int N) {double *ptr = (double*) malloc(N*sizeof(double)); \ return 0;}') leak(10000) </code></pre> <p>which reserves memory, even explicitly out of R's reach, and then exits. Here we get:</p> <pre><code>$ R -d "valgrind" -f /tmp/leak.R [...] R&gt; leak(10000) [1] 0 R&gt; ==4479== ==4479== HEAP SUMMARY: ==4479== in use at exit: 35,612,126 bytes in 15,998 blocks ==4479== total heap usage: 47,607 allocs, 31,609 frees, 176,941,927 bytes allocated ==4479== ==4479== LEAK SUMMARY: ==4479== definitely lost: 120 bytes in 2 blocks ==4479== indirectly lost: 480 bytes in 20 blocks ==4479== possibly lost: 0 bytes in 0 blocks ==4479== still reachable: 35,611,526 bytes in 15,976 blocks ==4479== suppressed: 0 bytes in 0 blocks ==4479== Rerun with --leak-check=full to see details of leaked memory ==4479== ==4479== For counts of detected and suppressed errors, rerun with: -v ==4479== Use --track-origins=yes to see where uninitialised values come from ==4479== ERROR SUMMARY: 31 errors from 10 contexts (suppressed: 2 from 2) $ </code></pre> <p>Now there is a bit more of a leak (though it is still not as easily readable as one would hope). If you add the suggested flags, it will eventually point to the <code>malloc()</code> call we made.</p> <p>Also, I have a worked example of actual leak in an earlier version of a CRAN package in one of my 'Intro to HPC with R' slide sets. If and when there is a leak, this helps. When there is none, it is harder to see through the noise.</p> <p>So in short, if you code crashes, it is probably your code's fault. Try a minimal reproducible example is the (good) standard advice.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload