Long-lived objects holding references to short-lived objects may cause memory leaks (the old generation refers to the new generation)

 

Specific categories
1, static collections cause memory leaks

public class Test01 {
    static Vector v = new Vector(10);
    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            Object obj = new Object();
            v.add(obj);
            obj = null;
        }
    }

 

Guess you like

Origin blog.csdn.net/GoSaint/article/details/115377212