<div style="font-family: Tahoma, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Hello,</div><div style="font-family: Tahoma, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Tahoma, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">I'm sorry if this is not the right place to post this, but I ran across this phenomenon and I think some people here might find it of interest. </div><div style="font-family: Tahoma, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Here is a test that runs well (it sends a warning as we're trying to push back to vectors of different sizes in a data frame):<pre>R -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes" \
-e "Rcpp::cppFunction('Rcpp::DataFrame test(SEXP a, SEXP b) { \
Rcpp::DataFrame DF; \
DF.push_back(a); \
DF.push_back(b); \
return DF; }'); \
test(1:4, 11:15)"
<br><span style="font-family: Tahoma, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">And here is a test where valgrind reports that 78 bytes are "definitely lost":</span><br>
R -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes" \
-e "Rcpp::cppFunction('Rcpp::DataFrame test(SEXP a, SEXP b) { \
Rcpp::DataFrame DF; \
DF.push_back(a); \
DF.push_back(b); \
return DF; }'); \
tryCatch( test(1:4, 11:15), warning = function(w) {} )"
<span style="font-family: Tahoma, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">My understanding is that when run in "tryCatch" as above, the test function is aborted and the object DF is not properly freed. <br><br>Yours<br>HP</span></pre></div>