Package com.carrotsearch.hppc.misc

Source Code of com.carrotsearch.hppc.misc.FastUtilOomPut

package com.carrotsearch.hppc.misc;

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;

import java.lang.reflect.Field;

public class FastUtilOomPut
{
    public static void main(String [] args)
    throws Exception
    {
        Int2IntOpenHashMap map = new Int2IntOpenHashMap(100, 1f);
        Field f = map.getClass().getDeclaredField("key");
        f.setAccessible(true);

        boolean hitOOM = false;
        for (int i = 0;; i++) {
            try {
                if (hitOOM) { System.out.println("put(" + i + ")"); }
                map.put(i,  i);
            } catch (OutOfMemoryError e) {
                hitOOM = true;
                System.out.println("OOM, map: " + map.size() + " " + ((int[])f.get(map)).length);
            }
        }
    }
}
TOP

Related Classes of com.carrotsearch.hppc.misc.FastUtilOomPut

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.