You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I am trying to use profmem to compute memory usage of a set of functions and I get very different results when I run the same command again (it goes from 273376 to 36648 bytes).
Here is a reproducible example:
rm(list = ls())
r <- profmem({
for (i in 1:5){
for (j in 1:50){
cat(i,j)
}}
})
total(r) #19200
s <- profmem({
for (i in 1:5){
for (j in 1:50){
cat(i,j)
}}
})
total(s) #19760
t <- profmem({
for (i in 1:5){
for (j in 1:50){
cat(i,j)
}}
})
total(t) #19760
In this example memory usage increases while in my case it decreases a lot. Which one would be the "real" memory use, the first one or the following ones? Thank you!!!
Best,
Inés
The text was updated successfully, but these errors were encountered:
Yes, when you start a fresh R session, there are things that will be additional things that will allocated the first time you evaluate some code. Thus, you often have to call it more than ones to get a good better idea about what's going on in your code. I don't fully understand exactly what is going on under the hood in R here, but if one would understand it better, maybe one could create a profmem::burnin() function that one can call once to fix this. Maybe it could even be done automagically by the profmem package, so the user does not have to do anything.
In this example memory usage increases while in my case it decreases a lot. Which one would be the "real" memory use, the first one or the following ones?
So, please note that utils::Rprofmem(), and therefore also profmem::profmem(), does not log memory deallocations, cf. https://github.com/HenrikBengtsson/profmem#what-is-logged. Because of this, you cannot use these data to figure out the amount of memory currently allocated, i.e. total() only reports on the total amount of allocations. FWIW, I've added it to the wishlist to have utils::Rprofmem() record also deallocations, c. HenrikBengtsson/Wishlist-for-R#25.
Hi! I am trying to use profmem to compute memory usage of a set of functions and I get very different results when I run the same command again (it goes from 273376 to 36648 bytes).
Here is a reproducible example:
In this example memory usage increases while in my case it decreases a lot. Which one would be the "real" memory use, the first one or the following ones? Thank you!!!
Best,
Inés
The text was updated successfully, but these errors were encountered: