Package com.carrotsearch.hppc.misc

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

package com.carrotsearch.hppc.misc;

import java.lang.reflect.Field;

import com.carrotsearch.hppc.IntIntOpenHashMap;

public class HppcOomPut
{
    public static void main(String [] args)
    throws Exception
    {
        IntIntOpenHashMap map = new IntIntOpenHashMap(100, 1f);
        Field f = map.getClass().getDeclaredField("keys");
        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.HppcOomPut

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.