Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the types of memory allocated by java objects

Shulou Source: shulou.com Published: 2022-05-31 17:49:15 10月04日 Update

This article mainly introduces the java object allocation of memory type of what related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this java object allocation type of memory, let's take a look at it.

1. Two types

(1) the pointer collision allocation method is used to allocate objects in a neat accumulation of memory, all the used ones are stored on one side, the unused ones on the other side, and the pointer is placed as an indicator of the boundary point in the middle. When allocating memory as an object, move the pointer to a distance equal to the size of the object that is not used at the same time.

(2) the free list is suitable for allocating memory in irregular memory. In order to know which memory area is available, the virtual machine must maintain the list and select enough space in the list to allocate to each other.

2. Application scenarios

The specific method of use depends on whether the stacked memory is neat, whether the stacked memory is neat, and whether the garbage collector has the function of compression and collation.

3. Examples

Public class TestPerson {public static void main (String [] args) {Person = p1 = Person (); Person = p2 = Person (); p1.age =-30 × p1.shout (); p2.shout ();}} that's all for the article "what are the types of memory allocated by java objects?" Thank you for reading! I believe you all have a certain understanding of the knowledge of "what are the types of memory allocated by java objects". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Memory allocation object type memory storage pointer knowledge content depending on article irregularity value function area at the same time scene garbage size instance Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MySQL macOS Huawei Apple