Changeset bfb4560


Ignore:
Timestamp:
Mar 20, 2011 6:14:30 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
3ba9f872
Parents:
fa8f229
Message:

maxMemory() fixes for silly GNU returning Long.MAX_VALUE

Files:
17 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/crypto/DHSessionKeyBuilder.java

    rfa8f229 rbfb4560  
    8383        // add to the defaults for every 128MB of RAM, up to 512MB
    8484        long maxMemory = Runtime.getRuntime().maxMemory();
    85         int factor = Math.min(4, (int) (1 + (maxMemory / (128*1024*1024l))));
     85        if (maxMemory == Long.MAX_VALUE)
     86            maxMemory = 127*1024*1024l;
     87        int factor = (int) Math.max(1l, Math.min(4l, 1 + (maxMemory / (128*1024*1024l))));
    8688        int defaultMin = DEFAULT_DH_PRECALC_MIN * factor;
    8789        int defaultMax = DEFAULT_DH_PRECALC_MAX * factor;
  • core/java/src/net/i2p/crypto/YKGenerator.java

    rfa8f229 rbfb4560  
    6161        // add to the defaults for every 128MB of RAM, up to 1GB
    6262        long maxMemory = Runtime.getRuntime().maxMemory();
    63         int factor = Math.min(8, (int) (1 + (maxMemory / (128*1024*1024l))));
     63        if (maxMemory == Long.MAX_VALUE)
     64            maxMemory = 127*1024*1024l;
     65        int factor = (int) Math.max(1l, Math.min(8l, 1 + (maxMemory / (128*1024*1024l))));
    6466        int defaultMin = DEFAULT_YK_PRECALC_MIN * factor;
    6567        int defaultMax = DEFAULT_YK_PRECALC_MAX * factor;
  • core/java/src/net/i2p/data/DataHelper.java

    rfa8f229 rbfb4560  
    11961196            case 3: return str + "G";
    11971197            case 4: return str + "T";
     1198            case 5: return str + "P";
     1199            case 6: return str + "E";
     1200            case 7: return str + "Z";
     1201            case 8: return str + "Y";
    11981202            default: return bytes + "";
    11991203        }
     
    12221226            case 3: return str + "&nbsp;G";
    12231227            case 4: return str + "&nbsp;T";
     1228            case 5: return str + "&nbsp;P";
     1229            case 6: return str + "&nbsp;E";
     1230            case 7: return str + "&nbsp;Z";
     1231            case 8: return str + "&nbsp;Y";
    12241232            default: return bytes + "&nbsp;";
    12251233        }
     
    12281236    /**
    12291237     * Strip out any HTML (simply removing any less than / greater than symbols)
     1238     * @param orig may be null, returns empty string if null
    12301239     */
    12311240    public static String stripHTML(String orig) {
  • core/java/src/net/i2p/data/RouterInfo.java

    rfa8f229 rbfb4560  
    5353    private boolean _shouldCache;
    5454    /** maybe we should check if we are floodfill? */
    55     private static final boolean CACHE_ALL = Runtime.getRuntime().maxMemory() > 128*1024*1024l;
     55    private static final boolean CACHE_ALL = Runtime.getRuntime().maxMemory() > 128*1024*1024l &&
     56                                             Runtime.getRuntime().maxMemory() < Long.MAX_VALUE;
    5657
    5758    public static final String PROP_NETWORK_ID = "netId";
  • core/java/src/net/i2p/data/SDSCache.java

    rfa8f229 rbfb4560  
    5151    static {
    5252        long maxMemory = Runtime.getRuntime().maxMemory();
     53        if (maxMemory == Long.MAX_VALUE)
     54            maxMemory = 96*1024*1024l;
    5355        FACTOR = Math.max(MIN_FACTOR, Math.min(MAX_FACTOR, maxMemory / (128*1024*1024d)));
    5456    }
  • core/java/src/net/i2p/util/ByteCache.java

    rfa8f229 rbfb4560  
    7070    static {
    7171        long maxMemory = Runtime.getRuntime().maxMemory();
     72        if (maxMemory == Long.MAX_VALUE)
     73            maxMemory = 96*1024*1024l;
    7274        MAX_CACHE = (int) Math.min(4*1024*1024l, Math.max(128*1024l, maxMemory / 128));
    7375    }
  • core/java/src/net/i2p/util/SimpleScheduler.java

    rfa8f229 rbfb4560  
    4444        _name = name;
    4545        long maxMemory = Runtime.getRuntime().maxMemory();
     46        if (maxMemory == Long.MAX_VALUE)
     47            maxMemory = 96*1024*1024l;
    4648        _threads = (int) Math.max(MIN_THREADS, Math.min(MAX_THREADS, 1 + (maxMemory / (32*1024*1024))));
    4749        _executor = new ScheduledThreadPoolExecutor(_threads, new CustomThreadFactory());
  • core/java/src/net/i2p/util/SimpleTimer.java

    rfa8f229 rbfb4560  
    4545        runner.start();
    4646        long maxMemory = Runtime.getRuntime().maxMemory();
     47        if (maxMemory == Long.MAX_VALUE)
     48            maxMemory = 128*1024*1024l;
    4749        int threads = (int) Math.max(MIN_THREADS, Math.min(MAX_THREADS, 1 + (maxMemory / (32*1024*1024))));
    4850        for (int i = 1; i <= threads ; i++) {
  • core/java/src/net/i2p/util/SimpleTimer2.java

    rfa8f229 rbfb4560  
    4444        _count = 0;
    4545        long maxMemory = Runtime.getRuntime().maxMemory();
     46        if (maxMemory == Long.MAX_VALUE)
     47            maxMemory = 96*1024*1024l;
    4648        _threads = (int) Math.max(MIN_THREADS, Math.min(MAX_THREADS, 1 + (maxMemory / (32*1024*1024))));
    4749        _executor = new CustomScheduledThreadPoolExecutor(_threads, new CustomThreadFactory());
  • router/java/src/net/i2p/router/JobQueue.java

    rfa8f229 rbfb4560  
    6262    static {
    6363        long maxMemory = Runtime.getRuntime().maxMemory();
     64        if (maxMemory == Long.MAX_VALUE)
     65            maxMemory = 128*1024*1024l;
    6466        if (maxMemory < 64*1024*1024)
    6567            RUNNERS = 3;
  • router/java/src/net/i2p/router/Router.java

    rfa8f229 rbfb4560  
    14331433        ctx.statManager().createRateStat("router.fastPeers", "How many fast peers we know", "Throttle", new long[] { 5*60*1000, 60*60*1000 });
    14341434        _maxMemory = Runtime.getRuntime().maxMemory();
    1435         ctx.statManager().createRateStat("router.memoryUsed", "(Bytes) Max is " + (_maxMemory / (1024*1024)) + "MB", "Router", new long[] { 60*1000 });
     1435        String legend = "(Bytes)";
     1436        if (_maxMemory < Long.MAX_VALUE)
     1437            legend += " Max is " + DataHelper.formatSize(_maxMemory) + 'B';
     1438        ctx.statManager().createRateStat("router.memoryUsed", legend, "Router", new long[] { 60*1000 });
    14361439    }
    14371440    private RouterContext getContext() { return _ctx; }
  • router/java/src/net/i2p/router/RouterContext.java

    rfa8f229 rbfb4560  
    9494            // to fill than to drain - so we don't need too many
    9595            long maxMemory = Runtime.getRuntime().maxMemory();
     96            if (maxMemory == Long.MAX_VALUE)
     97                maxMemory = 96*1024*1024l;
    9698            long buffs = Math.min(16, Math.max(2, maxMemory / (14 * 1024 * 1024)));
    9799            envProps.setProperty("prng.buffers", "" + buffs);
  • router/java/src/net/i2p/router/transport/ntcp/NTCPSendFinisher.java

    rfa8f229 rbfb4560  
    3535    static {
    3636        long maxMemory = Runtime.getRuntime().maxMemory();
     37        if (maxMemory == Long.MAX_VALUE)
     38            maxMemory = 96*1024*1024l;
    3739        THREADS = (int) Math.max(MIN_THREADS, Math.min(MAX_THREADS, 1 + (maxMemory / (32*1024*1024))));
    3840    }
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    rfa8f229 rbfb4560  
    492492
    493493        long maxMemory = Runtime.getRuntime().maxMemory();
     494        if (maxMemory == Long.MAX_VALUE)
     495            maxMemory = 128*1024*1024l;
    494496        int nr, nw;
    495497        if (maxMemory < 32*1024*1024) {
  • router/java/src/net/i2p/router/transport/udp/MessageReceiver.java

    rfa8f229 rbfb4560  
    4040
    4141        long maxMemory = Runtime.getRuntime().maxMemory();
     42        if (maxMemory == Long.MAX_VALUE)
     43            maxMemory = 96*1024*1024l;
    4244        if (maxMemory < 32*1024*1024)
    4345            _threadCount = 1;
  • router/java/src/net/i2p/router/transport/udp/PacketHandler.java

    rfa8f229 rbfb4560  
    4949
    5050        long maxMemory = Runtime.getRuntime().maxMemory();
     51        if (maxMemory == Long.MAX_VALUE)
     52            maxMemory = 96*1024*1024l;
    5153        int num_handlers;
    5254        if (maxMemory < 32*1024*1024)
  • router/java/src/net/i2p/router/tunnel/TunnelGatewayPumper.java

    rfa8f229 rbfb4560  
    2727        _stop = false;
    2828        long maxMemory = Runtime.getRuntime().maxMemory();
     29        if (maxMemory == Long.MAX_VALUE)
     30            maxMemory = 96*1024*1024l;
    2931        _pumpers = (int) Math.max(MIN_PUMPERS, Math.min(MAX_PUMPERS, 1 + (maxMemory / (32*1024*1024))));
    3032        for (int i = 0; i < _pumpers; i++)
Note: See TracChangeset for help on using the changeset viewer.