forked from lix-project/lix
fix integer overflow on i686 with high phys memory
sizeof(long) is 4 bytes on i686 GCC.
With ~32 GiB of memory and a page size of 4096, there are 7988420 pages.
(7988420 * 4096) is bigger than INT32_MAX folks.
Change-Id: I50bb9ea072aac11b449d79e5d55525887a6e5a99
This commit is contained in:
parent
6b08138929
commit
b9dc444c94
|
@ -316,13 +316,14 @@ void initGC()
|
|||
(resident) memory to be allocated. This might be a problem on
|
||||
systems that don't overcommit. */
|
||||
if (!getEnv("GC_INITIAL_HEAP_SIZE")) {
|
||||
size_t size = 32 * 1024 * 1024;
|
||||
int64_t size = 32 * 1024 * 1024;
|
||||
#if HAVE_SYSCONF && defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
|
||||
size_t maxSize = 384 * 1024 * 1024;
|
||||
long pageSize = sysconf(_SC_PAGESIZE);
|
||||
long pages = sysconf(_SC_PHYS_PAGES);
|
||||
if (pageSize != -1)
|
||||
int64_t maxSize = 384 * 1024 * 1024;
|
||||
int64_t pageSize = sysconf(_SC_PAGESIZE);
|
||||
int64_t pages = sysconf(_SC_PHYS_PAGES);
|
||||
if (pageSize != -1) {
|
||||
size = (pageSize * pages) / 4; // 25% of RAM
|
||||
}
|
||||
if (size > maxSize) size = maxSize;
|
||||
#endif
|
||||
debug("setting initial heap size to %1% bytes", size);
|
||||
|
|
Loading…
Reference in a new issue