Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak? #79

Open
gaborcsardi opened this issue May 6, 2020 · 8 comments
Open

Possible memory leak? #79

gaborcsardi opened this issue May 6, 2020 · 8 comments

Comments

@gaborcsardi
Copy link
Contributor

Seems like read_pubkey() leaks a bit of memory:

ps::ps_memory_info(ps::ps_handle())
#>        rss        vms    pfaults    pageins
#>   64491520 4481400832      16576        123

for (i in 1:10000) openssl::my_pubkey()
ps::ps_memory_info(ps::ps_handle())
#>        rss        vms    pfaults    pageins
#>   72728576 4482637824      18587        123

for (i in 1:10000) openssl::my_pubkey()
ps::ps_memory_info(ps::ps_handle())
#>        rss        vms    pfaults    pageins
#>   76582912 4482637824      19528        123
@jeroen
Copy link
Owner

jeroen commented May 6, 2020

I think the openssl base64 decoder is leaking a bit, but I can't see what I'm doing wrong.

@jeroen
Copy link
Owner

jeroen commented May 6, 2020

I think at least part of the problem is fixed. I'm getting this now:

> ps::ps_memory_info(ps::ps_handle())
       rss        vms    pfaults    pageins 
 164724736 4729516032      88142          0 
> #>        rss        vms    pfaults    pageins
> #>   64491520 4481400832      16576        123
> 
> for (i in 1:10000) openssl::my_pubkey()
> ps::ps_memory_info(ps::ps_handle())
       rss        vms    pfaults    pageins 
 164872192 4729516032     106147          0 
> #>        rss        vms    pfaults    pageins
> #>   72728576 4482637824      18587        123
> 
> for (i in 1:10000) openssl::my_pubkey()
> ps::ps_memory_info(ps::ps_handle())
       rss        vms    pfaults    pageins 
 164884480 4729516032     107014          0 

@jeroen
Copy link
Owner

jeroen commented May 6, 2020

Actually I cannot reproduce this with the CRAN version. For me the usage stabilizes after a while, maybe the memory from your example is just added to R's memory pool, but not lost.

Does this keep growing infinitely for you?

for(i in 1:500){
  for (i in 1:1000) openssl::my_pubkey()
  rm(list=ls()); gc()
  print(ps::ps_memory_info(ps::ps_handle()))
}

Othewise it may have to do with the version of libssl.

@gaborcsardi
Copy link
Contributor Author

gaborcsardi commented May 6, 2020

Yeah, it is growing, slowly.

EDIT: maybe not indefinitely....

@gaborcsardi
Copy link
Contributor Author

Yeah, I think it is good.

@jeroen
Copy link
Owner

jeroen commented May 6, 2020

This would make a nice tool for spotting memory leaks btw. Where you can feed it a function, and it will repeatedly call it and show how memory usage grows over time.

@gaborcsardi
Copy link
Contributor Author

IDK, it is a lot more low-tech than valgrind. :)

@jeroen
Copy link
Owner

jeroen commented May 6, 2020

Valgrind often has so many false positives that it's hard to make sense of it, and see how serious the problem is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants