From edd @end|ng |rom deb|@n@org  Tue Apr  6 00:53:25 2021
From: edd @end|ng |rom deb|@n@org (Dirk Eddelbuettel)
Date: Mon, 5 Apr 2021 17:53:25 -0500
Subject: [Rd] R extension memory leak detection question
In-Reply-To: <CANjVfJ3gc7+U2-ep4-CeJWDHa7SivkqvBx2sxkD3tA1mdv5DMQ@mail.gmail.com>
References: <CANjVfJ2xXfinnpYgEoH_0dwvG=29FFMinuV+1cOueSrRMNyq9A@mail.gmail.com>
 <b0b80c39-2931-cd4e-ef6f-5cff9e9678c8@gmail.com>
 <CAJf4E3pJiF4U=w89P1UH6jDFbNM6Mwxu=r8EDfGjbtNmeLesuw@mail.gmail.com>
 <CANjVfJ3gc7+U2-ep4-CeJWDHa7SivkqvBx2sxkD3tA1mdv5DMQ@mail.gmail.com>
Message-ID: <24683.38117.444899.558821@rob.eddelbuettel.com>


On 5 April 2021 at 18:27, xiaoyan yu wrote:
| Thank you all for your help.
| We embedded R in our program and found the memory in the process
| accumulated while our expectation is that the memory will go down after
| each R evaluation.
| I started to write a test program with only a few lines of R embedded codes
| and found the memory never went down even after R library is unloaded.
| Please find more details in the readme and test program at
| https://github.com/xiaoyanyuvt/RMemTest

You may find the projects RInside (for easily embedding R inside C++
programs) and littler (also embedding R, but using C only, for use in
lightweight cmdline applications) useful.  Those have existed for, give or
take, 10 and 15 years and have not proven to show memory leaks so I feel the
burden of proof is still on you.

Also I got your program to compile (after making the 'makefile' a bit more
general, and fixing two things upsetting current C++ compilers) but I am not
sure we really see memory consumption:

   edd at rob:~$ ps -fv $(pgrep -x foo)
       PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
   1456192 pts/9    S+     0:00      0     1  5890  1768  0.0 ./foo
   edd at rob:~$ ps -fv $(pgrep -x foo)
       PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
   1456192 pts/9    Sl+    0:00      0     1 1617174 9896  0.0 ./foo
   edd at rob:~$ 

Dirk

-- 
https://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



[Rd] R extension memory leak detection question
Dirk Eddelbuettel