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
Copy file name to clipboardExpand all lines: memory-profiling.html
+10-15
Original file line number
Diff line number
Diff line change
@@ -22,13 +22,11 @@ <h1 align="center">Memory profiling in R</h1>
22
22
the interval. <code>summaryRprof</code> now has options to summarize this information.
23
23
This is available only on Unix at the moment.
24
24
25
-
<li> If R is compiled with <code>R_MEMORY_PROFILING</code> defined, the function <code>tracemem</code> marks an object so that <code>Rf_duplicate</code> will print a stack trace when the object is duplicated. This is intended for tracking accidental copying of large objects. <code>untracemem</code> will untrace an object (though not all copies of it) and <code>tracingState</code> controls whether tracing information is printed. In the example below we see that <code>lm</code> does not duplicate its <code>data</code> argument, but that <code>glm</code> does, and that <code>lm</code> does copy the response vector three times.
25
+
<li> If R is compiled with <code>--enable-memory-profiling</code>, the function <code>tracemem</code> marks an object so that a stack trace will be printed when the object is duplicated, or when it is copied by coercion or arithmetic functions. This is intended for tracking accidental copying of large objects. <code>untracemem</code> will untrace an object (though not all copies of it) and <code>tracingState</code> controls whether tracing information is printed. In the example below we see that <code>lm</code> does not duplicate its <code>data</code> argument, but that <code>glm</code> does, and that <code>lm</code> does copy the response vector.
lm(formula = Volume ~ Height + Girth, data = trees)
63
59
64
60
Coefficients:
65
61
(Intercept) Height Girth
66
62
-57.9877 0.3393 4.7082
67
-
68
63
</pre>
69
64
<code>tracemem</code> cannot be used on functions, since it uses the same trace bit that <code>trace</code> uses, and will not work on objects such as environments that are passed by reference and not duplicated. The output for this could be made prettier and sent to a file: the main thing to decide is how to handle files when multiple objects may be being traced.
70
65
@@ -76,6 +71,6 @@ <h1 align="center">Memory profiling in R</h1>
76
71
Valgrind can also help with memory profiling at the C level, using <code>--tool=massif</code>
0 commit comments