p1 <- profmem({
x <- 1:1000
p2 <- profmem({
y <- as.double(x)
})
z <- x * y
})
Where p1 should hold all memory allocations including those done during p2.
Issue
Rprofmem() itself can only handle a single file; from ?Rprofmem:
Enabling profiling automatically disables any existing profiling to another or the same file.
which is also confirmed when inspecting the internal code.
In develop, profmem_begin/end() now protects against the stack from being greater than one level, in order to avoid overwriting existing profiling logs by mistake.
Solution
It should not be impossible to have the profmem package to orchestrate a stack of files. One idea is to have profmem_begin() parse existing profile buffer and stack it before starting over producing a fresh one. Calls to profmem_end() will consume the current buffer and append it any previous one existing at the same level. If not at the top level, then it'll resume profiling to a fresh profile file.
Wish
To be able to do:
Where
p1
should hold all memory allocations including those done duringp2
.Issue
Rprofmem()
itself can only handle a single file; from?Rprofmem
:which is also confirmed when inspecting the internal code.
In develop,
profmem_begin/end()
now protects against the stack from being greater than one level, in order to avoid overwriting existing profiling logs by mistake.Solution
It should not be impossible to have the profmem package to orchestrate a stack of files. One idea is to have
profmem_begin()
parse existing profile buffer and stack it before starting over producing a fresh one. Calls toprofmem_end()
will consume the current buffer and append it any previous one existing at the same level. If not at the top level, then it'll resume profiling to a fresh profile file.