Applied Epi Community

R studio error/ R crashes while trying to run a command

SOS Please help!

I have been using R for quite some time and it was running very well until today.

Today I updated the R version to 4.1.3 , then when I reopened my Rmarkdown file and run it, RStudio encounters Fatal error:Unexpected exception:bad allocation , followed by R Session Aborted pop-up asked to start NEW Session.

I have tried many times to try to solve the error including turn on/off RStudio as well as the compute, I have also uninstalled and reinstalled the R and RStudio, but no help.
Has anyone experienced this?

Bad allocation will refer to allocation of memory. So either your data (all R objects) is too large for the amount of memory in your computer, or your code is doing something to massively expand the amount of memory used for the transformations you are doing! Best to include your code and highlight at which point in the code your error would appear

1 Like

Thank you,Florence


This is the screen shot.

Hi @ishaatu,

Could you provide more information on the code you’re trying to run, perhaps encapsulating it in a reprex? To me, it’s unclear if it’s that or if it’s an issue with RStudio pointing to a bad copy of R. Best to eliminate the former and then troubleshoot from there.

All the best,

Tim

Agree with @isaacflorence … it is likely a memory allocation issue on your device. Try deleting cached files, clearing all objects that are not essential, and freeing up as much memory as possible. If freeing up and allocating more memory doesn’t fix the problem, I suggest sharing a reprex as @machupovirus suggested, to help troubleshoot as the error might be linked to the code looping through your Rmarkdown file. Let us know how it goes. Regards

1 Like

Thank you very much @BryanTegomoh @machupovirus and @isaacflorence

I am actually in the same city as Aishat (she attended our Applied Epi R course here) and will meet her tonight to try to troubleshoot based on your suggestions

She is just importing a dataset with 90000 records and 20 columns, and then running head()

2 Likes

Now that’s what I call a world-class service…

1 Like

Hi @ishaatu
Kindly check the code ( you can break it down to see where the problem is occurring). I faced the same issue a few days ago and I ended up realizing that one of the functions I was using was running some infinite loops.
Regards,