In Java, memory management is divided into: stack (stack), heap, datasegment (data segment), Codesegment (code snippet)
Stack: base data type (Byte,short,int,long,char,float,double,boolean), local variable, object's reference address
Heap: Store object instances, new comes out of the place.
Datasegment (data segment): Static variables and string constants
Codesegment (Code snippet): Store code as the name implies
650) this.width=650; "Width=" 547 "height=" 338 "title=" Memory analysis Diagram "style=" width:468px;height:251px;float:left; "alt=" Wkiol1xul-odqninaalojebpj_4167.jpg "src=" Http://s3.51cto.com/wyfs02/M01/71/95/wKioL1XUL-ODQNiNAALOjEBpj_4167.jpg "/>
Instance:
Here's an example of how a Java variable is stored in memory.
Code Segment:arraylistlist[]=new arraylist[2];
arraylist[0]=2;arraylist[1]=3;arraylist[2]=4;
Because list[] is a variable, this is a declaration we put into the stack.
The variables that are instantiated from each subsequent array are then placed in the heap.
The value of a real variable is constant, so it is placed in a constant pool, which is the datasegment.
Java Memory analysis