Skip to content

Commit

Permalink
Add backup physical memory detection on macOS when _SC_PHYS_PAGES is not
Browse files Browse the repository at this point in the history
defined on macOS (PR#18713).


git-svn-id: https://svn.r-project.org/R/trunk@86527 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed May 7, 2024
1 parent 3866042 commit 9711c6f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/startup.c
Expand Up @@ -34,6 +34,11 @@
#include <unistd.h>
#endif

#ifdef __APPLE__
# include <sys/types.h>
# include <sys/sysctl.h>
#endif

/* These are used in ../gnuwin32/system.c, ../unix/sys-std.c */
SA_TYPE SaveAction = SA_SAVEASK;
SA_TYPE RestoreAction = SA_RESTORE;
Expand Down Expand Up @@ -251,6 +256,17 @@ void R_SizeFromEnv(Rstart Rp)
R_size_t MinMaxVSize = 17179869184; /* 16 Gb */
Rp->max_vsize = sysmem > MinMaxVSize ? sysmem : MinMaxVSize;
}
#elif defined(__APPLE__) && (SIZEOF_SIZE_T > 4)
else {
R_size_t sysmem = 0;
R_size_t len = sizeof(sysmem);
if (!sysctlbyname("hw.memsize", &sysmem, &len, NULL, 0)
&& len == sizeof(sysmem)) {

R_size_t MinMaxVSize = 17179869184; /* 16 Gb */
Rp->max_vsize = sysmem > MinMaxVSize ? sysmem : MinMaxVSize;
}
}
#endif
if((p = getenv("R_VSIZE"))) {
value = R_Decode2Long(p, &ierr);
Expand Down

0 comments on commit 9711c6f

Please sign in to comment.