VirtualBox

Ignore:
Timestamp:
Mar 25, 2009 4:29:07 PM (16 years ago)
Author:
vboxsync
Message:

VM Settings: Made the max RAM limits higher for big memory configs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsGeneral.cpp

    r18094 r18264  
    359359bool VBoxVMSettingsGeneral::revalidate (QString &aWarning, QString & /* aTitle */)
    360360{
     361    /* Come up with some nice round percent boundraries relative to
     362       the system memory. A max of 75% on a 256GB config is ridiculous,
     363       even on an 8GB rig reserving 2GB for the OS is way to conservative.
     364       The max numbers can be estimated using the following program:
     365
     366            double calcMaxPct(uint64_t cbRam)
     367            {
     368                double cbRamOverhead = cbRam * 0.0390625; // 160 bytes per page.
     369                double cbRamForTheOS = RT_MAX(RT_MIN(_512M, cbRam * 0.25), _64M);
     370                double OSPct  = (cbRamOverhead + cbRamForTheOS) * 100.0 / cbRam;
     371                double MaxPct = 100 - OSPct;
     372                return MaxPct;
     373            }
     374
     375            int main()
     376            {
     377                uint64_t cbRam = _1G;
     378                for (; !(cbRam >> 33); cbRam += _1G)
     379                    printf("%8lluGB %.1f%% %8lluKB\n", cbRam >> 30, calcMaxPct(cbRam),
     380                           (uint64_t)(cbRam * calcMaxPct(cbRam) / 100.0) >> 20);
     381                for (; !(cbRam >> 51); cbRam <<= 1)
     382                    printf("%8lluGB %.1f%% %8lluKB\n", cbRam >> 30, calcMaxPct(cbRam),
     383                           (uint64_t)(cbRam * calcMaxPct(cbRam) / 100.0) >> 20);
     384                return 0;
     385            }
     386
     387       Note. We might wanna put these calculations somewhere global later. */
     388    ulong fullSize = vboxGlobal().virtualBox().GetHost().GetMemorySize();
     389    double maxPct  = 0.75;
     390    double warnPct = 0.50;
     391    if (fullSize < 3072)
     392        /* done */;
     393    else if (fullSize < 4096)   /* 3GB */
     394        maxPct  = 0.80;
     395    else if (fullSize < 6144)   /* 4-5GB */
     396    {
     397        maxPct  = 0.84;
     398        warnPct = 0.60;
     399    }
     400    else if (fullSize < 8192)   /* 6-7GB */
     401    {
     402        maxPct  = 0.88;
     403        warnPct = 0.65;
     404    }
     405    else if (fullSize < 16384)  /* 8-15GB */
     406    {
     407        maxPct  = 0.90;
     408        warnPct = 0.70;
     409    }
     410    else if (fullSize < 32768)  /* 16-31GB */
     411    {
     412        maxPct  = 0.93;
     413        warnPct = 0.75;
     414    }
     415    else if (fullSize < 65536)  /* 32-63GB */
     416    {
     417        maxPct  = 0.94;
     418        warnPct = 0.80;
     419    }
     420    else if (fullSize < 131072) /* 64-127GB */
     421    {
     422        maxPct  = 0.95;
     423        warnPct = 0.85;
     424    }
     425    else                        /* 128GB- */
     426    {
     427        maxPct  = 0.96;
     428        warnPct = 0.90;
     429    }
     430
    361431    /* System RAM & Video RAM sliders correlation test */
    362     ulong fullSize = vboxGlobal().virtualBox().GetHost().GetMemorySize();
    363432    quint64 needBytes = VBoxGlobal::requiredVideoMemory (&mMachine);
    364     if (mSlRam->value() + mSlVideo->value() > 0.75 * fullSize)
     433    if (mSlRam->value() + mSlVideo->value() > maxPct * fullSize)
    365434    {
    366435        aWarning = tr (
    367             "you have assigned more than <b>75%</b> of your computer's memory "
    368             "(<b>%1</b>) to the virtual machine. Not enough memory is left "
     436            "you have assigned more than <b>%1%</b> of your computer's memory "
     437            "(<b>%2</b>) to the virtual machine. Not enough memory is left "
    369438            "for your host operating system. Please select a smaller amount.")
     439            .arg ((unsigned)(maxPct * 100))
    370440            .arg (vboxGlobal().formatSize (fullSize * _1M));
    371441        return false;
    372     } else
    373     if (mSlRam->value() + mSlVideo->value() > 0.5 * fullSize)
     442    }
     443    if (mSlRam->value() + mSlVideo->value() > warnPct * fullSize)
    374444    {
    375445        aWarning = tr (
    376             "you have assigned more than <b>50%</b> of your computer's memory "
    377             "(<b>%1</b>) to the virtual machine. Not enough memory might be "
     446            "you have assigned more than <b>%1%</b> of your computer's memory "
     447            "(<b>%2</b>) to the virtual machine. Not enough memory might be "
    378448            "left for your host operating system. Continue at your own risk.")
     449            .arg ((unsigned)(warnPct * 100))
    379450            .arg (vboxGlobal().formatSize (fullSize * _1M));
    380451        return true;
    381     } else
     452    }
    382453    if ((quint64) mSlVideo->value() * _1M < needBytes)
    383454    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette