Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


janani a p
new
2 Answer(s)      3 years and 5 months ago
Posted in : Java Beginners


hi i am jane pls explain the difference between heap memory and stack memory


Advertisement
View Answers

July 14, 2011 at 1:11 PM


Differences:

1)The OS allocates the stack for each system-level thread when the thread is created. Typically the OS is called by the language runtime to allocate the heap for the application.

2)The stack is attached to a thread, so when the thread exits the stack is reclaimed. The heap is typically allocated at application startup by the runtime, and is reclaimed when the application (technically process) exits.

3)The size of the stack is set when a thread is created. The size of the heap is set on application startup, but can grow as space is needed (the allocator requests more memory from the operating system).

4)The stack is faster because the access pattern makes it trivial to allocate memory from it, while the heap has much more complex bookkeeping involved in an allocation or free. Also, each byte in the stack tends to be reused very frequently which means it tends to be mapped to the processor's cache, making it very fast.



July 14, 2011 at 1:11 PM


Differences:

1)The OS allocates the stack for each system-level thread when the thread is created. Typically the OS is called by the language runtime to allocate the heap for the application.

2)The stack is attached to a thread, so when the thread exits the stack is reclaimed. The heap is typically allocated at application startup by the runtime, and is reclaimed when the application (technically process) exits.

3)The size of the stack is set when a thread is created. The size of the heap is set on application startup, but can grow as space is needed (the allocator requests more memory from the operating system).

4)The stack is faster because the access pattern makes it trivial to allocate memory from it, while the heap has much more complex bookkeeping involved in an allocation or free. Also, each byte in the stack tends to be reused very frequently which means it tends to be mapped to the processor's cache, making it very fast.



Related Tutorials/Questions & Answers:
new
new    hi i am jane pls explain the difference between string greeting = good morning string greeting = new string ("good morning
new
new  hi the difference between string sname = good morning string sname =new("good morning
Advertisements
new
new    hi i am jane pls explain the difference between heap memory and stack memory
new
new   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html
New to struts2.0
New to struts2.0  hi am new to struts2.0 in my application i have declared a list in static how to get the static list values in my result.jsp??? if i remove the static in the list the result is getting displayed.why
New to struts2
New to struts2   Please let me know the link where to start for struts 2 beginners   Struts 2 Tutorials
new 2
new 2  <%@page import="java.util.ArrayList"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <...; arr1=new ArrayList<String>(); ArrayList<String> arr2=new
New to Java - New to java tutorial
. Properties props = new Properties(); // code to fill props with any... a unique session by getInstance() method… Properties props = new Properties... will use subclass javax.mail.internet.MimeMessage. MimeMessage message = new
opening new browser with new JSESSIONID using java
opening new browser with new JSESSIONID using java  I am facing following problem, I am trying to open a new browser using java. First i have opened one IE browser and manually. And i ran my LaunchURL.java file, it is opening new
new java technologies 2012
new java technologies 2012  new java technologies 2012
add new package java
add new package java  How to add new package in Java
The new keyword
The new keyword       The new keyword in java programming language is used to create a new instance... meaning relevant to a compiler. The new keyword allocates new objects
New to programming...
Are you New to Java Programming Language? Learn the how you can Java... development framework. New... fear of pointers... Break the old rhythm. Explore the new
new java technologies 2011
new java technologies 2011  what are the new java technologies in 2011
create a new object in JavaScript
create a new object in JavaScript  How do you create a new object in JavaScript
create a new object in JavaScript
create a new object in JavaScript  How do you create a new object in JavaScript
links open new windows
links open new windows  Why do my links open new windows rather than update an existing frame
New Features in Hibernate 4
New Features in Hibernate 4  What are the new features in hibernate 4... of enterprise web applications.   Here are the list of new features... The ServiceRegistry API is also introduced in the new version of Hibernate Core 4. JDK
how to creat a new program
how to creat a new program  what is use of abs class in realtime projects.. how to creat the program step by step
Latitude and Longitude of New Zealand
Latitude and Longitude of New Zealand  Hi, What is the Latitude and Longitude on New Zealand? Also give me an insight into this beautiful country Thanks   Hi, Latitude of New Zealand is:-41 and Longitude of New
new web page
new web page  I am creating a new web page for an user to sign up....how to give error messages if an user has not entered some fields(it can be one or many)... An example could be your webpage where you have indicated in red
Latitude and Longitude of New Caledonia
Latitude and Longitude of New Caledonia  Hi, What is the Latitude and Longitude on New Caledonia? Thanks   Hi, Latitude of New Caledonia is:-21.5 and Longitude of New Caledonia is: 165.5 A country with two national
New to Java Please help
New to Java Please help  Hi I need help, can some one help me with this. I am currently doing a project. drop me an email to my email address. Thanks!   If you are new in java, then you need to learn core java
Very new to Java
Very new to Java   hi I am pretty new to java and am wanting to create a programe for the rhyme 10 green bottles. 10 green bottles standing on the wall 10 green bottles standing on the wall and if 1 green bottle should
New To JAVA - Java Beginners
New To JAVA  hi iam new to java..,can you please guide me how to learn the java and also tell me how many days it takes to learn java  Hi naresh, All are depend on you. i am sending link, by using this tutorial you
New features in PHP5?
New features in PHP5?   hello,, What are new features added in PHP5?   hii, Following are new features added in PHP5 Access Modifiers are added in PHP5 PHP 5 introduces a number of new "magic" methods. Magic
NEW IN JAVA - Java Beginners
NEW IN JAVA  Suppose you are asked to design a software tool... static void main(String[] args) throws Exception { Scanner scan = new Scanner(System.in); Random random1 = new Random(); Random random2 = new Random(); int
What's New?
What's New? Find latest tutorials and examples at roseindia.net. Our site is publishing free tutorials on many Java and Open source technologies Learn Java technologies step by step: Core Java JSP
New to Java?
New to Java?       If you are new to Java technology and you want to learn Java and make career in the Java technology then this page is for you. Here we have explained how to learn
The new keyword in java
The new keyword in java In this section you will learn about new keyword in java. The new keyword is used to create a instance of a class. The new keyword...; A ob1 = new A(12,56); Shape ob2 = new Shape(ob,32,98); First line creates
Latitude and Longitude of Papua New Guinea
Latitude and Longitude of Papua New Guinea  Hi, What is the Latitude and Longitude on Papua New Guinea? Thanks
 

 

 

DMCA.com