Spark的JVM相关错误

HeapOutOfMemory

代码:

package spark.jvm;

import java.util.ArrayList;
import java.util.List;

class Person{ }

public class HeapOutOfMemory {
    public static void main(String[] args) {
        System.out.println("HeapOutMemory");
        List<Person> persons= new ArrayList<Person>();
        int count = 0;
        while(true){
            persons.add(new Person());
            System.out.println("Instance: " + (++count));
        }
    }
}

ideaVM相关配置:

-verbose:gc -Xms10M -Xmx10M -XX:MaxDirectMemorySize=5M -Xss128k -XX:+PrintGCDetails

错误:

StackOverFlow

代码:

package spark.jvm;

public class StackOverFlow {
    private int counter;

    public void count(){
        counter++;

        count();
    }

    public static void main(String[] args) {
        System.out.println("StackOverFlow");

        StackOverFlow stackOverFlow = new StackOverFlow();
        try {
            stackOverFlow.count();
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }
}

错误:

ConstantOutOfMemory

代码:

package spark.jvm;

import java.util.ArrayList;
import java.util.List;

public class ConstantOutOfMemory {
    public static void main(String[] args) {
        try {
            List<String> stringList = new ArrayList<String>();

            int item = 0;

            while(true){
                stringList.add(String.valueOf(item++).intern());

            }
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }
}

问题:

DirectMemoryOutOfmemory

代码:

package spark.jvm;

import java.nio.ByteBuffer;

public class DirectMemoryOutOfmemory {
    private static final int ONE_MB = 1024*1024*1024;

    private static int count = 1;

    public static void main(String[] args) {
        try {
            while (true){
                ByteBuffer buffer = ByteBuffer.allocateDirect(ONE_MB);

                count++;
            }
        }catch (Exception e){
            System.out.println("Exception:instance created " +count);

            e.printStackTrace();
        }catch (Error e){
            System.out.println("Error:instance created "+count);

            e.printStackTrace();
        }
    }
}

问题:

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇
Theme Argon
本网站自 2020-12-24 12:00:00 起已运行