>>>>> Tim Taylor 
>>>>>     on Tue, 17 Jan 2023 13:39:01 +0000 writes:

    > On 17/01/2023 13:06, Duncan Murdoch wrote:
    >> I don't have a valgrind-capable version of R, but I'd be interested to 
    >> see whether this is a one-time loss, or repeated.  That is, do you get a 
    >> much bigger loss from running the lossy code in a loop like this?
    >> 
    >>  for (i in 1:100) { png(filename='p.png'); plot(1:10); dev.off() }
    >> 
    >> Duncan Murdoch

    > Duncan - Not that I'm seeing

> Duncan - Not that I'm seeing
> 
> Rdevel -d valgrind --vanilla -e " for (i in 1:1) {png(filename='p.png'); 
> plot(1:10); dev.off()}"
> 
> ==63291== LEAK SUMMARY:
> ==63291==    definitely lost: 2,560 bytes in 4 blocks
> ==63291==    indirectly lost: 17,710 bytes in 762 blocks
> ==63291==      possibly lost: 1,820 bytes in 8 blocks
> ==63291==    still reachable: 52,177,408 bytes in 21,282 blocks
> ==63291==                       of which reachable via heuristic:
> ==63291==                         newarray           : 4,264 bytes in 1 
> blocks
> ==63291==         suppressed: 0 bytes in 0 blocks
> 
> Rdevel -d valgrind --vanilla -e " for (i in 1:100) 
> {png(filename='p.png'); plot(1:10); dev.off()}"
> 
> ==63464== LEAK SUMMARY:
> ==63464==    definitely lost: 2,560 bytes in 4 blocks
> ==63464==    indirectly lost: 17,710 bytes in 762 blocks
> ==63464==      possibly lost: 1,820 bytes in 8 blocks
> ==63464==    still reachable: 56,072,939 bytes in 19,283 blocks
> ==63464==                       of which reachable via heuristic:
> ==63464==                         newarray           : 4,264 bytes in 1 
> blocks
> ==63464==         suppressed: 0 bytes in 0 blocks
> 
> Tim


Thank you very much, Duncan and Tim.
Indeed someone else mentioned to me privately that they thought
these were "once in an R session"-losses, and hence not at all
problematic:

There are several places in the R sources (written in C),
where *static* (fixed size) buffers originally are not allocated
and once they are used are allocated and then used for the rest
of the R session.

It's comparable to not having all base packages loaded in
your R session when you start up: Then they do *not* use any
memory (and startup time) resources, and if you really need
them, load the namespaces and possibly even attach the package
to search().

That is perfectly valid smart use of resources from within R,
and indeed a feature and not a bug.

Martin

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to