java8 metaspace issue

Brian Harris brianfromoregon at gmail.com
Tue May 5 03:17:08 UTC 2015


Hi,

I find that this code crashes in 8u40 after getting up to about 900 when
run with -XX:MaxMetaspaceSize=10m. When run in 7u60 with
-XX:MaxPermSize=10m it does not crash.

Is that expected? It seems similar to
https://bugs.openjdk.java.net/browse/JDK-8025635

Thanks,
Brian

// uses Guava's CacheBuilder
public class Main {

    public static void main(String[] args) throws Exception {
        Cache<Integer, Object> cache = CacheBuilder.newBuilder()
                .softValues()
                .build();

        for (int i = 0; i < 50_000; i++) {
            URL[] dummyUrls = {new URL("file:" + i + ".jar")};
            URLClassLoader cl = new URLClassLoader(dummyUrls,
Thread.currentThread().getContextClassLoader());
            Object proxy = Proxy.newProxyInstance(cl, new
Class[]{Foo.class}, new InvocationHandler() {
                @Override
                public Object invoke(Object proxy, Method method, Object[]
args) throws Throwable {
                    return null;
                }
            });
            cache.put(i, proxy);
            System.out.println(i);
        }
    }

    public interface Foo {
            void x();
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-gc-use/attachments/20150504/6ab35ce2/attachment.html>


More information about the hotspot-gc-use mailing list