Java FAQ _07JVM Architecture (003) _ Memory allocation what are the policies

Source: Internet
Author: User

Click to enter _ more _java thousand ask

1. What are the strategies for memory allocation?

We start with the principle of compiling, different development environment, development language will have different strategies. In general, the program runs with three memory allocation policies: Static, stacked, heap-

  • Static storage
    is the ability to determine the storage space requirements at runtime for each data target at compile time, so that they can be allocated fixed memory space at compile time.
    This allocation policy requires that the presence of mutable data structures is not allowed in the program code, and that nested or recursive structures are not allowed because they cause the compiler to be unable to calculate the exact storage space.

  • Stack-up storage
    A stack storage allocation is a dynamic storage allocation that is implemented by a stack-like run stack, as opposed to the allocation of static storage.
    In the stack storage scheme, the requirement of the program to the data area is completely unknown at compile time, only when it is run, but it is necessary to know the size of the data area required by the program module in order to allocate its memory when it enters a program module in operation. Like the stacks we know in data structures, stack storage allocations are distributed according to the principles of advanced post-out.

  • Heap-Storage
    Heap storage allocations are specifically responsible for the memory allocation of data structures that are not determined by the storage requirements at compile time or at runtime.
    For example, variable-length strings and object instances, the heap consists of large chunks of available or free blocks, and the memory in the heap can be allocated and freed in any order.

2. Java Memory allocation policy

Java's memory allocation is mainly stack-based, as follows:

Learn about the Java memory model look here: What is the Java memory model
See the JVM instance structure here: what is the structure of the JVM instance?
Learn how the JVM manages memory look here: [How the JVM manages memory][4]
[4]:

Java FAQ _07JVM Architecture (003) _ Memory allocation what are the policies

Related 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.