Changeset 228 for trunk


Ignore:
Timestamp:
Jan 8, 2011, 2:29:55 PM (15 years ago)
Author:
dmik
Message:

hotspot: Fixed the detection of the default maximum Java heap size value on OS/2 so that it fits into the maximum available memory block for the current process (which depends on the VIRTUALADDRESSLIMIT value). See #34 for details.

Location:
trunk/openjdk/hotspot/src/os
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/openjdk/hotspot/src/os/os2/vm/os_os2.cpp

    r116 r228  
    2727#define INCL_DOSMODULEMGR
    2828#define INCL_DOSPROFILE
     29#define INCL_DOSMISC
     30#define INCL_DOSERRORS
    2931#include <os2wrap2.h>
    3032
    3133// do not include precompiled header file
    3234# include "incls/_os_windows.cpp.incl"
     35
     36#define MIN2(x, y) (((x) < (y))? (x) : (y))
    3337
    3438bool os::dll_address_to_library_name(address addr, char* buf,
     
    3842    os2_APIRET arc = DosQueryModFromEIP(&hmod, &obj, buflen, buf, &offs,
    3943                                        (ULONG)addr);
    40     if (arc == NO_ERROR) {
     44    if (arc == os2_NO_ERROR) {
    4145    // buf already contains path name
    4246    if (offset) {
     
    6670        arc = DosQueryModFromEIP(&jvmHmod, &obj, sizeof(buf), buf, &offs,
    6771                                 (ULONG)&os::address_is_in_vm);
    68         if (arc != NO_ERROR) {
     72        if (arc != os2_NO_ERROR) {
    6973            assert(false, "Can't find jvm module.");
    7074            return false;
     
    7377
    7478    arc = DosQueryModFromEIP(&hmod, &obj, sizeof(buf), buf, &offs, (ULONG)addr);
    75     if (arc != NO_ERROR)
     79    if (arc != os2_NO_ERROR)
    7680        return false;
    7781    return hmod == jvmHmod;
     
    121125    os2_APIRET arc = DosQuerySysState(os2_QS_PROCESS | os2_QS_MTE, os2_QS_MTE,
    122126                                      pid, 0, buf, 64 * 1024);
    123     if (arc != NO_ERROR) {
     127    if (arc != os2_NO_ERROR) {
    124128        assert(false, "DosQuerySysState() failed.");
    125129        return;
     
    141145}
    142146
     147julong os::allocatable_physical_memory(julong size) {
     148    // The primary role of this method on OS/2 is to limit the default maximum
     149    // Java heap size as the calculations done by Java when defining this limit
     150    // use fractions of the physical memory but in fact the OS/2 process can
     151    // allocate much less than the physical memory size of the modern PCs so
     152    // the allocation will fail very often in -server mode (-client mode limits
     153    // the physical RAM size to 1G for calculations so it's not a big problem
     154    // for it; -server mode limits it to 4G which is very problematic taking
     155    // into account that the default fraction for the heap size is 1/4 -- see
     156    // below about the maximum private memory block size). Since this method is
     157    // called after Java has performed its calculations, we correct the limit
     158    // here.
     159    //
     160    // Some details about the process' maximum private memory block size on
     161    // OS/2:
     162    //
     163    // 1. For systems that don't suport high memory (prior to WSeB AFAIR)
     164    //    the theoretical maximum memory block size is approx. 512M / 2.
     165    // 2. For systems with high memory support, the theoretical maximum spans
     166    //    from VIRTUALADDRESSLIMIT / 2 to VIRTUALADDRESSLIMIT / 1.5 or so.
     167    //    VIRTUALADDRESSLIMIT is 1024M unless it is explicitly specified in
     168    //    CONFIG.SYS.
     169    // 3. The real maximum memory block available to Java is somewhat smaller
     170    //    than the theoretical maximum and it gets decreased each time the
     171    //    process allocates memory with DosAllocMem().
     172    //
     173    // A typical situation when Java fails in -server mode is when the
     174    // theoretical maximum is 1024M (or lower) and the amount of physical RAM
     175    // is 2G and more. Java will want >=512M in this case for the heap, but the
     176    // process will have less than 512M available because because some space
     177    // will be occupied by the system DLLs.
     178    //
     179    // We solve this problem by limiting the requested size to the real maximum
     180    // memory block size (minus some threshold, see below).
     181
     182    static os2_ULONG maxMemBlock = 0;
     183    if (maxMemBlock == 0) {
     184        os2_ULONG pageSize;
     185        os2_ULONG flags = os2_OBJ_ANY;
     186        os2_APIRET arc;
     187        arc = DosQuerySysInfo(os2_QSV_PAGE_SIZE, os2_QSV_PAGE_SIZE,
     188                              (os2_PVOID)&pageSize, sizeof(os2_ULONG));
     189        if (arc != os2_NO_ERROR)
     190            return size;
     191        // get maximum high memory block size
     192        arc = DosQuerySysInfo(os2_QSV_MAXHPRMEM, os2_QSV_MAXHPRMEM,
     193                              (os2_PVOID)&maxMemBlock, sizeof(os2_ULONG));
     194        if (arc == os2_ERROR_INVALID_PARAMETER) {
     195            // high memory is not supported, get maximum low memory block size
     196            flags &= ~os2_OBJ_ANY;
     197            arc = DosQuerySysInfo(os2_QSV_MAXPRMEM, os2_QSV_MAXPRMEM,
     198                                  (os2_PVOID)&maxMemBlock, sizeof(os2_ULONG));
     199        }
     200        if (arc != os2_NO_ERROR)
     201            return size;
     202        // maxMemBlock is the maximum memory block available right now. It will
     203        // decrease by the time when the actual heap allocation takes place. We
     204        // assume that Java will allocate for non-heap needs (this includes
     205        // other DLLs it may drag in) no more than 3/10 of the current size.
     206        // Note that this is quite an arbitrary choice based on some experiments
     207        // with various VIRTUALADDRESSLIMIT settings. Our mission here is to
     208        // make java with no explicit -Xmx specification not fail at startup
     209        // due to "Could not reserve enough space for object heap" error. But
     210        // even if it fails in some specific configuration, it's always possible
     211        // to specify the upper limit manually with -Xmx.
     212        os2_ULONG threshold = maxMemBlock * 3 / 10;
     213        threshold = ((threshold + pageSize - 1) / pageSize) * pageSize;
     214        maxMemBlock -= threshold;
     215    }
     216
     217    return MIN2(size, maxMemBlock);
     218}
  • trunk/openjdk/hotspot/src/os/windows/vm/os_windows.cpp

    r145 r228  
    673673}
    674674
     675#ifndef __WIN32OS2__
    675676julong os::allocatable_physical_memory(julong size) {
    676677#ifdef _LP64
     
    681682#endif
    682683}
     684#endif
    683685
    684686// VC6 lacks DWORD_PTR
Note: See TracChangeset for help on using the changeset viewer.