1.1 --- a/src/os/linux/vm/os_linux.cpp Fri Mar 09 13:34:45 2012 -0800 1.2 +++ b/src/os/linux/vm/os_linux.cpp Mon Mar 12 13:12:07 2012 -0700 1.3 @@ -2547,7 +2547,14 @@ 1.4 } 1.5 1.6 void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) { 1.7 - commit_memory(addr, bytes, alignment_hint, false); 1.8 + // This method works by doing an mmap over an existing mmaping and effectively discarding 1.9 + // the existing pages. However it won't work for SHM-based large pages that cannot be 1.10 + // uncommitted at all. We don't do anything in this case to avoid creating a segment with 1.11 + // small pages on top of the SHM segment. This method always works for small pages, so we 1.12 + // allow that in any case. 1.13 + if (alignment_hint <= (size_t)os::vm_page_size() || !UseSHM) { 1.14 + commit_memory(addr, bytes, alignment_hint, false); 1.15 + } 1.16 } 1.17 1.18 void os::numa_make_global(char *addr, size_t bytes) {