• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

What is MethodArea? Is it stack itself?

 
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is MethodArea? Is it stack itself???
 
Sheriff
Posts: 22656
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did you find this term? Because if I use Google to search for it I find only 131 results, including this thread.
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've seen "method area" used to refer to that part of memory to which code is loaded. It's part of the heap -- in particular, in Sun's JVMs it's an area of the heap known as the "permanent generation", or "PermGen space".
 
Vishal Hegde
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ernest Friedman-Hill wrote:I've seen "method area" used to refer to that part of memory to which code is loaded. It's part of the heap -- in particular, in Sun's JVMs it's an area of the heap known as the "permanent generation", or "PermGen space".



But When we split the terminology method area ..it means area for methods and methods are stored in stack, right?
 
Vishal Hegde
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Where did you find this term? Because if I use Google to search for it I find only 131 results, including this thread.



I heard it from one of my seniors
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vishal Hegde wrote:
But When we split the terminology method area ..it means area for methods and methods are stored in stack, right?



The stack is for stack frames -- local variables and return addresses. The stack is a temporary scratch area, and nothing is "stored" there.

I'm entirely unclear on why you're arguing with me, anyway; you asked what this term means, and I told you.

 
Ranch Hand
Posts: 492
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So methods are stored in the heap?

I though that methods were local to a class' activation record on the runtime stack. is this wrong?

Hunter
 
Sheriff
Posts: 27235
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Methods are permanent, unchanging, and they are the same for all instances of a class. So the simple and logical thing would be to keep one copy of each method of a class in a permanent place. And, unsurprisingly, that's how it is done.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By "methods are stored in the heap", I mean that the data structures representing a method to the JVM, including its bytecode, are stored in the heap when they are loaded from the class files. We have several people now saying that they believe "methods are stored on the stack", and that's simply not true, by this definition of "methods".

What is stored on the stack(s) is the information about which method called which other method in a given thread, and the values of the local variables in each executing method. This is information about the execution of methods, rather than methods themselves. Note that each thread has its own stack, a fact that seems to often be overlooked in these discussions.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's important to understand what the stack is exactly, instead of just remembering "this is on the heap, and that is on the stack" without understanding why or how it works.

To understand exactly what the stack is, read this Wikipedia article: Call stack. It explains exactly what the stack is for and how it works.

Note that most microprocessors, including all microprocessors used in PCs, have built-in instructions that support a call stack. For example, the processor has a jump-to-subroutine (JSR) instruction which saves the state of many of the processor's registers and the location in memory of the instruction after the JSR instruction on the stack, and then jumps to the address of the subroutine. At the end of the subroutine is a return instruction (RET) which pulls this information off the stack to restore the registers to the state they were in before the subroutine was called, and which jumps to the saved address. So the mechanism of the call stack is a very low-level thing, which is implemented in the hardware of the microprocessor itself. Java uses this mechanism of the processor when methods are called (the JSR and RET instructions).

The call stack is not a general storage area just like the heap, where data or code is stored.
 
Marshal
Posts: 75844
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hardly think this is a "beginning" question, so I shall move it.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic