In Java, which objects are pushed onto the stack and which are on the heap?

For an operator in a Java function:

Xxx xxx = new Xxx() {
    public Abc abc(final Writer out) {
        return new SomeFunction(out) {
            boolean isDone = false;
            public void start(final String name) {
                /* blah blah blah */
            }
        };
    }
};

Which variable, including functions, is pushed onto the heap and which will be pushed onto the stack?

The reason I'm asking is a segmentation error in the JVM:

kernel: java[14209]: segfault at 00002aab04685ff8 rip 00002aaab308e4d0 rsp 00002aab04685ff0 error 6

00002aab04685ff8and 00002aab04685ff0are nearby, it seems that the stack is growing too fast. I am trying to examine this part of the code and doubt that this is causing the problem when calling this function many times. Is it possible that the stack is not cleared if some variables in the heap reference it?

+3
source share
2 answers

The question of whether a particular object goes to the heap is a bit related.

, Java , -. , , .

HotSpot JIT -, Escape Analysis. , "" , . , .

Escape Analysis Java, .


: . . , .

, (, C) , , , Java. , Sun (Oracle) , .

, , . , "" , ( ) .

+5

name, isDone, out, ABC "" someFunction ; .

0

All Articles