maximal number of DLLs reached

551 views
Skip to first unread message

Jose Jimenez

unread,
Dec 14, 2016, 11:24:31 AM12/14/16
to nimble-users
Hi All,

I'm trying to make a simulation in nimble with 100 iterations of the same code using a loop, but after 40-45 iterations R crash, and I get "maximal number of DLLs reached". Can DLLs be unloaded programatically, without restarting R?

Thank you,
Jose

Chris Paciorek

unread,
Dec 15, 2016, 3:57:05 PM12/15/16
to Jose Jimenez, nimble-users
hi Jose, the following should work on Mac or Linux, but may have some
problems Windows (it might work but then trigger an error when you
close R in Windows).

Suppose that you have an uncompiled model or nimbleFunction, called
'obj', and a compiled version of that called 'Cobj'.

Simply do:
nimble:::clearCompiled(obj)

That should remove the DLLs associated with the project associated
with 'obj' and 'Cobj'.

Chris
> --
> You received this message because you are subscribed to the Google Groups
> "nimble-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nimble-users...@googlegroups.com.
> To post to this group, send email to nimble...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nimble-users/287fcea6-42c8-4b8c-935d-4899cfb1070c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

JOSE JIMENEZ GARCIA-HERRERA

unread,
Dec 15, 2016, 4:20:00 PM12/15/16
to Chris Paciorek, nimble-users
Thank you Chris. It is working fine on Mac

Best regards,
Jose

Perry de Valpine

unread,
Dec 15, 2016, 4:39:43 PM12/15/16
to JOSE JIMENEZ GARCIA-HERRERA, Chris Paciorek, nimble-users
Ah, Chris’ email made me realize that when I responded to Jose I neglected to cc nimble-users!  In case others are interested, here was my answer.  Jose did report to me that clearCompiled() crashed Windows but not OS X.  -Perry

This has been a headache for us.  If you are running in Linux or OS X, you can use what is still an internal/development feature:

nimble:::clearCompiled(Rmodel)

where Rmodel is any part (model or nimbleFunction) of a nimble project (stuff that was compiled together, perhaps via the project argument to compileNimble).   This is not fully documented for users for a few reasons.  One is that it is new.  Another is that it doesn’t work safely on Windows.  And a third is that one still has to be careful: we’ve tried to make it completely safe but it is not fully tested.  In particular it is possible that if you have multiple R objects of the same nimble object, and you accidentally try to use one of them later, the system could crash.  It shouldn’t happen, but as mentioned it is not highly tested.  But for your purposes if you are writing a loop in which you compile and then want to clear at the end, go ahead and try it and it is likely to work.  Unfortunately Windows manages compiled and loaded stuff differently.  On Windows, in some cases what might happen is that the compiled objects will unload but the non-safeness will mean that R crashes upon exiting.  If you can live with that you can use it.  In any case it won’t cause harm to try it as long as you know it might be unstable and don’t have unsaved work in the R session.


frederic....@gmail.com

unread,
May 19, 2023, 8:01:07 AM5/19/23
to nimble-users
Dear all,

I reopen the issue of this  nimble:::clearCompiled function since I had to use it - outside Windows - for the reasons stated above, in a project of R Package. Yet, when submitting to CRAN, it seems I get stuck with the following NOTE:

> * checking dependencies in R code ... NOTE Unexported object imported

> by a ‘:::’ call: ‘nimble:::clearCompiled’

>    See the note in ?`:::` about the use of this operator.


and the following comment by the CRAN team member:

Can the nimble people be convinced to export that function if they propose to use it?


I therefore forward you this question, hoping that I will be able/allowed to publish my package before this functions is exported. 


Sincerely,

Frédéric Gosselin


Chris Paciorek

unread,
May 22, 2023, 10:51:43 AM5/22/23
to frederic....@gmail.com, nimble-users
Hi Frédéric,

Thanks for asking about this. `clearCompiled` will be exported in our next version, version 1.0.0, which should be released very soon.

-chris



frederic....@gmail.com

unread,
May 24, 2023, 1:37:32 AM5/24/23
to nimble-users
I thank you very much Chris. This will help me very much.

All the best,

Frédéric

Reply all
Reply to author
Forward
0 new messages