This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Heap & Pool

 
Noorulain Khan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between heap and pool.
and use of intern() method
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The heap is just the area of RAM that is allotted to the JVM by the operating system for runtime activity. As such it is the place that objects get created during a JVM session.
From the Java Virtual Machine Specification

3.5.5 Runtime Constant Pool
A runtime constant pool is a per-class or per-interface runtime representation of the constant_pool table in a class file (�4.4). It contains several kinds of constants, ranging from numeric literals known at compile time to method and field references that must be resolved at run time. The runtime constant pool serves a function similar to that of a symbol table for a conventional programming language, although it contains a wider range of data than a typical symbol table.
Each runtime constant pool is allocated from the Java virtual machine's method area (�3.5.4). The runtime constant pool for a class or interface is constructed when the class or interface is created (�5.3) by the Java virtual machine.
The following exceptional condition is associated with the construction of the runtime constant pool for a class or interface:
When creating a class or interface, if the construction of the runtime constant pool requires more memory than can be made available in the method area of the
Java virtual machine, the Java virtual machine throws an OutOfMemoryError.
See Chapter 5 for information about the construction of the runtime constant pool.
 
Sadaf Zaidi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one define pool in its own words please!
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sadaf,
The 'pool' is just a special area of memory that Java sets up to store all String literals. Imagine a box with a partition wall; on one side is the 'pool' on the other side the 'heap'. Everytime you use a string literal, it gets stored on the pool side, regular objects get stored on the heap side.
Hope that helps.
 
Michael Bruesch
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cindy Glass rocks! I've never learned so much quality information until I came across the posts of Cindy. They always answer the question and even go a step further. On behalf of everyone else here I'm sure, I thank you Cindy.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome < Cindy bashfully shuffling feet >
 
Argm Mastoi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes thanx alot cindy, it is crystal clear now. how we can give smilies.
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the link on the left to "Smilies Legend" when you post something.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic