This question is not about difference between Stack and Heap in Java. In C++, both Stack and Heap are in RAM. How is it in Java? Answer Yes. Stack is used for static memory allocation and Heap for dynamic memory allocation, both stored in the computer’s RAM This is to ensure faster processing of java programs.
Tag: stack-memory
What does push into stack means? move or duplicate method?
When an object calls a function, the function would be pushed from the method area into the stack. My question is: Q: What does that “push” mean in this context? Does that simply mean move(from the method area) or copy of the function(a copy of the method pushed onto the stack)? Answer The method itself is not pushed onto the
Instance created inside of a Method
I have not been able to find any reliable literature on this but i’m curious as to where an object is stored if its created inside of a method ? on the stack or on the heap in java 8? I know that normally only local primitives, reference variables and function calls are stored on the stack and that objects
Does JVM Stack have no direct references to objects but reference to constant pool?
I am investigating JVM architecture and its working behind the scenes. I have heard a lot of times that stack stores method return types, operands, local variables and references to objects. But while reading the Oracle specification I have found the picture where drawn that stack frame has no references to objects directly but the reference to the constant pool.
Clarification on run-time/compile-time and heap/stack [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago. Improve this question (Please excuse me if i got the title incorrect, I believe it is binding but if anything let me know
How are strings passed into methods in java (In terms of memory)
When we call methods, if you are passing in a primitive type, that value is put on the stack frame when calling the method. If you are passing in a reference type, if it’s not null, you would have already created it on the heap some where and what gets put on the stack is a reference to it. But
Need an explanation for apparent heap size reduction
From the GC logs, it appears that the heap size is being reduced across young and old generations after sometime. Below are three entries from the logs. {Heap before gc invocations=5: PSYoungGen total 44800K, used 44180K [0x18220000, 0x1b420000, 0x24a20000) eden space 38400K, 100% used [0x18220000,0x1a7a0000,0x1a7a0000) from space 6400K, 90% used [0x1ade0000,0x1b3853c8,0x1b420000) to space 6400K, 0% used [0x1a7a0000,0x1a7a0000,0x1ade0000) PSOldGen total 51200K,
where is array saved in memory in java?
If I have a function that in that function I declare: Where are arr and the whole array stored? heap? stack? Does it matter if the declaration is in some function or in main()? and let’s say I also have these command lines: where are arr[0] and arr[1] stored? Answer Memory diagram: Boxes are memory locations (where binary numbers can
Java’s enum… Where are they created?
Since enum in C# are on the stack, I was wondering where enum, in Java, where created. On the stack? On the heap? In some mysterious other place? Enumeration in C# are more primitive than those in Java, this might explain why they are created on the stack… Where are they? I can’t find them! Thanks Answer Enums in Java
Java Object Method Stack Frame Parameters
So in java, say you have a non-static method ‘bar()’ in an class ‘Foo’. Say then that you call this method like so: Now the stack frame for the call includes the integer parameter, as well as a ‘this’ parameter to be used as an internal reference to the object. What other interesting parameters are copied to the new stack