From x|@oy@n@yu @end|ng |rom gm@||@com  Tue Apr  6 02:28:17 2021
From: x|@oy@n@yu @end|ng |rom gm@||@com (xiaoyan yu)
Date: Mon, 5 Apr 2021 20:28:17 -0400
Subject: [Rd] R extension memory leak detection question
In-Reply-To: <24683.38117.444899.558821@rob.eddelbuettel.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>
 <24683.38117.444899.558821@rob.eddelbuettel.com>
Message-ID: <CANjVfJ3UpC9NdMR3M0SMV9WU2u8GiEXqyz5fQ=tHpKa-7-LZAw@mail.gmail.com>

Thanks for your quick response. It is also surprising for us to notice the
memory accumulation when running our program since it has been years since
we developed our program.
Here is the memory status I observed from 15384k to 234208k to 242024k
without decreasing when running the test program.
[Before the first ENTER]$ps -aux | grep foo
xy 16985  0.0  0.0  *15384*  1312 pts/0    S+   00:09   0:00 ./foo
[After the first ENTER ]$ps -aux | grep foo
xy 16985  0.4  0.2 *234208* 42104 pts/0    S+   00:09   0:00 ./foo
[After the second ENTER and also before the program exit]$ps -aux | grep foo
xy    16985  0.1  0.2 *242024* 42244 pts/0    S+   00:09   0:00 ./foo

The test program is just a small simplified portion of our program. We
observed even more memory in use when running our program. We would like to
try to understand more of the memory life cycle of the embedded R.

Thanks,
Xiaoyan


On Mon, Apr 5, 2021 at 6:53 PM Dirk Eddelbuettel <edd at debian.org> wrote:

>
> 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
>

	[[alternative HTML version deleted]]



[Rd] R extension memory leak detection question
xiaoyan yu