Health, home? [Analysis of Java Memory]

Source: Internet
Author: User

Health, home? [Analysis of Java Memory]

Abstract: Original creation Place: http://www.cnblogs.com/Alandre/sediment brick slurry Carpenter hope reprint, keep abstract, thank you!

optimism, how can and other kno u,u R yourself! I must is strong and carry on. -Mud and brick pulp carpenter A. Chat under

201407 months remember when the body collapsed, hehe. To say, to their own, is also responsible for the people. The chest was sore and then almost exhausted, and I persisted for a week, and that week was really a blur. Can't look at the code at all, look at the code is faint. Always want to sleep. The chest will hurt a bit indirectly. Until 29th, after supper, my chest was stuffy. Go to the side attached to a three-a hospital check, did a terrible electrocardiogram. The hospital is also good for people, but the latter happens completely unreasonable. Then the mood is like the following figure, when heard an emergency is not responsible Aunt General practitioner said, "ECG has a wave slightly high, hurriedly 24 hours of guardianship, immediately contact parents" (She did not know, my father was also the period of coronary heart disease, he did not know that I did not seriously upset by her so toss. What's my mood going to be? Why doesn't a doctor behave like that? Although I am studying at Medical University. )

Now slowly recovery, in fact, no major illness, stay up too much, the body collapsed. I still have a blood pill. Stay with me a lot. I remember, I will be grateful. The biggest is home and loved ones.

Tell us:

    1. Health first, the capital of revolution. It's easy to say, it's hard to do. (try to be regular, whether you stay up late)

    2. And keep optimistic, it's good for your body.

    3. Moderate amount of exercise

    4. Some details to note and try: Bubble foot ....

Two. Text

I want to combine my own story and say it's really sad. But I'm not careful, I just want to pass on the story, I think you'll like it. Thank you here first. Like every person out there, every wandering out to study or work. Home is like a computer inside the hard disk, want to memory, have your home, home address.

People crossing the city, sometimes stop to look at themselves ah.

Like Java, he's a good friend of mine. Java also has a home, but also a destination. In Java, Java programs, Java virtual machines, operating systems. It is where it belongs. It interacts with one another.

The following passage comes from Java Bible "Think in Java":

 in Java, there are six different places where you can store data:1.  Register (register). This is the fastest storage area because it is located in a different location from the other store-the inside of the processor. However, the number of registers is extremely limited, so the registers are allocated by the compiler on demand. You cannot directly control or feel any sign of register presence in the program. The 2.  stack (stacks). is located in Universal RAM, but it can be supported from the processor with its "stack pointer". If the stack pointer moves down, the new memory is allocated, and if you move up, the memory is freed. This is a fast and efficient method of allocating storage, second only to registers. When you create a program, the Java compiler must know the exact size and lifecycle of all the data stored in the stack, because it must generate the appropriate code to move the stack pointer up and down. This constraint limits the flexibility of the program, so while some Java data is stored on the stack-especially object references-the Java object does not store it. Neptune's Entertainment http://bct5453.com/3.  heap (heap). A universal memory pool (also available in RAM) for storing so Java objects. The benefit of a heap that differs from the stack is that the compiler does not need to know how many storage areas to allocate from the heap, or how long the stored data survives in the heap. Therefore, there is great flexibility in allocating storage in the heap. When you need to create an object, you only need new to write a simple line of code, and when you execute this line of code, it will be automatically stored in the heap allocation. Of course, for this flexibility you have to pay the code accordingly. Storage allocation with heaps takes more time than storage storage with the stack. 4.  static Storage (static storage). "Static" here means "in a fixed position". The data stored in the static store that persists while the program is running. You can use the keyword static to identify a particular element of an object that is static, but the Java object itself never resides in a static storage space. 5.  constant Storage (constant storage). Constant values are usually stored directly inside the program code, and it is safe to do so because they are never changed. Sometimes, in an embedded system, the constants themselves are separated from the rest, so in this case, you can choose to place them in ROM 6.  non-RAM storage. If the data is completely outside of the program, it can be free from any control of the program and can exist when the program is not running. 

In my opinion, the piece I want to analyze is summarized as follows:

In Java, memory analysis can be divided into stack-stack, heap-heap (inside the method area of bread) and so on. Stack flexibility is not good, automatic continuous allocation of memory, LIFO. Dynamic allocation of heaps, flexible. So there are places in Java's home.

Home is an umbrella, help us shelter the wind and rain, home is an oasis of the soul, bring us happiness, to relieve our troubles, home is a lamp, help us illuminate the road ahead.

A hole or anything is better than a home kennel. Good at calling home, life is so short.

Three. Shallow analysis of Java memory

Say it from a small code. From small to large, slowly let oneself understand.

The entrance to the MainClass program, like the road of life.

Public class mainclass{    public static void main (String[]  args)     {        people dad = new  people ();        dad.name =  "Jeff Father";                 people mum  = new people ();        mum.name =  "Jeff  mum ";                 Home home = new home ();         home.address =   "Place of freedom";                 home.dad = dad;        home.mum  = mum;  &nbsP;             home.mum.givelove ();     }}

Below are the corresponding two classes of Home people

public class home{String address;        People dad; People mum;}    public class people{String name;        int age;    public void Givelove () {System.out.println ("Give Love but Say nothing!"); }}

Home family wrote to this class I thought of. At that time, 24-hour guardianship made me worried. Afraid to tell their parents, because dad was still sick. I called the sister in the field, then really smiled at ING. But keep telling yourself, "Everything's going to be over." ”

I like to see the animal world, where love is full of moments. I like photography, too.

After running everyone can see: (This is the love of parents)

"Give Love but Say nothing!"

The first thing to say in front of three classes are Class Loaders, class code information is put into the method area. For example, the properties of the code, no parameters or methods with parameters ... As shown in the following:

And then, according to the code, we put the memory to the management. In front of four words, that is the family of lovely parents, hope they healthy Kang. When I was young, mom and dad were younger and you were full of energy. I think of the song "Tears In Heaven":

People dad = new people ();
Dad.name = "Jeff Father";

People mum = new people ();
Mum.name = "Jeff Mum";

In the first sentence, the new people () is in the heap of the non-method area, creating a block belonging to this new people, whose method givelove points to the specific method within the people class of information. Then there is a reference to this new block in the stack.

In the second sentence, the first "Jeff Father" is inside the constant pool inside the MainClass class information. The above new block inside name is a reference to its constant.

The same is true of home. The address of the home is the most clear address of this life from small to large.

Home Home = new Home ();

home.address = "Place of Freedom";

The above code is consistent with the previous. Everybody slowly realize, will give a picture will understand a lot later.

Home.dad = dad;

home.mum = mum;

inside the home there is a people attribute that references the ID of the dad block. In this way, the home with dad has a mum is home. Home has what good nostalgia. It's a house, not a family member. the figure is summarized as follows:

Today's own, drinking Chinese medicine every day. Gradually entered the ranks of health, fitness. Until you are near death, you will feel the value of life, and you will not go to those useless places.

Small feeding, big food. Selflessness is the duty of their angels.

Here's a small exercise: if you add the following code to the MainClass main function above:

The answer is not to say. Ha ha

Note: = = indicates that the data reference is the same as return true.

If you do not know the words, according to my diagram, and my summary of the following experience.

Life is about making something. I started to remember the memo and began to enjoy life. To start everything new. Sometimes it's right to tell the Zen master, put down some, to practice feeling. The school will be put down after the injury. Come on, everybody. Come on, I'm on my own. Recently I like C + + Java, has its own goals and ideals. I feel very steadfast in my life. Sister's engagement day is coming, congratulations. I have to learn to smile.

Four. Thanks to the source of knowledge and summary

A heap is a run-time data area from which the object of a class allocates space. These objects are created through new, and they do not require program code to be explicitly released. objects and arrays in Java are stored in the heap. Heap is responsible for garbage collection, the advantage of the heap is the ability to dynamically allocate memory size, the lifetime does not have to tell the compiler beforehand, because it is at runtime to allocate memory dynamically, Java garbage collector will automatically take away these no longer use data.

The method area is also a heap, which holds the code information of the class, the static variable, the constant pool

The stack mainly contains some basic types of variables (, int, short, long, byte, float, double, Boolean, char) and object references.

Resources:

Google and its own experience.

If the above articles or links are helpful to you, don't forget to click the "Like a" button on the article button or in the bottom right corner of the page. You can also click on the right side of the page "share" hover button oh, let more people read this article.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.