Java Virtual machine Memory analysis

Source: Internet
Author: User

1. In general, Java Virtual machines are divided into: stacks

Stack in the data structure is that advanced out of the stack. Heap... I feel big when I hear that name. After all, we describe a lot of things and nothing most of the time is a bunch of piles of ... (Forgive my divergent thinking, I am sister ...) Does this understand my mind? )

The stack is followed by threads. One thread at a stack. A method of a stack frame (make a professional name, is actually a method of the metadata package, such as the name of the method is recorded, which line, parameters, return: And so on, you just imagine, you are a virtual machine, you have to execute a method of what information you want to write ... )。 The characteristics of the stack is advanced, just as the execution of the method is matched, each execution of the method of the top of the stack, the method encountered in the method into the stack and then execute the stack top method, the execution is finished on the stack ... Match the perfect ... Then a thread just has to read the instruction execution instruction and read the next instruction ... Hey, how do you know where the next instruction is? If it was me, I'd have something to do. Remember where the next command I'm going to execute is. All each thread has a program counter pointing to where the next line of code is. Strictly speaking, the program counter has nothing to do with the stack ... And do not need to advanced after the characteristics of .... So it is neither a heap nor a stack, but also a small amount of memory ... No weight.

The stack also has special things called local method stacks ... What are you doing? The name is so clear, the implementation of the local method stack Bai, what is called local method? Own Baidu to go. I'm just a sister, not Daniel.

There is a big thing, heap ... is a bunch of memory that everyone can use. When will it be used? The place is so big that it must be a lot more memory and less predictable is good. The equivalent of the stack is his home, decoration to be delicate and neat but small area ah. So minutes to build an object out, account for the large amount of memory how to do? The House is too ... Squeezed out. That can only go outside the open space that everyone can use, and then tie the rope at home, convenient to find their own object behind. or register. There are two ways to register, the first: there is an area in the heap specifically registered address. Want to be in a directory of a book. The usage of this push memory is documented regularly. When you need to find an object, you can find it from this directory ... And a variable is in the stack pointing to this directory. This is called a handle ... Oh, that's the pointer. Another is to build an object in the heap inside, in the stack to get a variable pointing to the address of the push inside. is the reference, C called the pointer (I prefer the name ...) Very image ah, a moment to remember. A needle pointing at someone .... What is the difference between these two forms of registration? Well, this is useful when it comes to garbage collection. Garbage collection is to remove the useless objects, can not occupy the manger not to poop ah, right. How to clear it? A lot of ways ... I remember that some of the objects were moved together. And then empty out a blockbuster. This time the problem is coming, you have moved the object ... So I'm going to change the pointer in the stack and point to the new place. If the first kind of handle is not used, because I point to just a directory, your family has changed the matter to me ... You can change the value of your own directory. The second type of reference is: Must have changed. Who said I need you, you go I also follow .... Heap is nothing but this stuff ... Everyone can use the ... Warehouse....

There are several pieces of memory ... The method area runs a constant amount of direct memory ... It's always useful, but I've seen it a few times and it doesn't matter, why? Because I don't feel like I'm using it. Wait till I feel like I'm using it again.

Java Virtual machine Memory analysis

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.