开发者

Java heap size - will this work?

I try this with NetBeans desktop application template - increasing heapsize (to 512 MiB) of executed .jar file. (I believe that NetBeans uses Singleton app by default - SingleFrameView) Will it work?

    public static void main(String[] args) {
        if (args == null) {
            args = new String[1];
            args[0] = "Xmx512m";
        } else {
            String[] tempArgs = new String[args.length+1];
            for (int i=0; i<args.length; i++) {
            tempArgs[i] = args[i];
            }
            tempArgs[tempArgs.length-1] = "Xmx512m";
            args = tempArgs开发者_运维百科;
        }
        launch(MyApp.class, args);
    }
}


Not going to work. The heap space is set from the -Xmx parameter at JVM initialization time. By the time you're running Java code, it's too late.

There could be an exception if the launch() method spawns a new JVM, but nothing I see indicates that that is the case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜