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

Large memory overhead for duplicating the stackedsdm object in the "simulate.res.S" function #19

Open
ch16S opened this issue Jun 19, 2022 · 1 comment

Comments

@ch16S
Copy link

ch16S commented Jun 19, 2022

Hey guys

I noted a very large memory overhead in the simulate.res.S helper function.

The function calls:
many.obj = list(obj)[rep(1, n.res)]
This create many lists of the same stackedsdm object.
Unfortunately the LM and GLM models have quite a large memory foot print - and so if you working with 1000's of samples and 1000's of species then memory requirements become enormous in this step you in effect multiple the memory usage by the number of simulations.
I propose you run the following instead:
res = lapply(1:n.res,function(x) residuals(obj))
This achieves the desired outcome to produce the residuals but without the unnecessary memory usage.

Cheers,
Chris

@gordy2x
Copy link
Owner

gordy2x commented Oct 26, 2022

Yes the code is very inefficient, thanks for the suggestion, I'll try to find some time to test and implement.

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