java内存数据管理
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                java内存数据管理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                準確的說應該是java8以前的內存管理方式
區別在永久代(方法區)上
public class RamManager {//1.a存儲于永久代public static int a =1;private String str;private int x;private AA aaa;
// method_1方法位于棧中// temp1保存的是引用地址,在棧中public void method_1(String temp1) {// temp1將引用地址賦給this.str,this引用在棧中,this實例在堆中,this.str也在堆中,保存了temp1的值,為字符串"aaa"的地址this.str = temp1;// this.x在堆中this.x = 1;// b在棧中int b = 2;// attr變量在棧中,new int實例在堆中int[] attr = new int[10];attr[0] = 1;// aa變量在棧中,實例AA在堆中AA aa = new AA();// this.aaa在堆中,保存了aa變量的地址this.aaa = aa;}// main方法位于棧中public static void main(String[] args) throws Exception{// ramManager變量在棧中創建,new Manager實例在堆中創建RamManager ramManager = new RamManager();// string變量在棧中,保存的"aaa"的地址,"aaa"在常量池中String string = "aaa";ramManager.method_1(string);}
?
轉載于:https://www.cnblogs.com/liuxinan/p/5213401.html
總結
以上是生活随笔為你收集整理的java内存数据管理的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 请问苏州哪里可以订做旗袍??
- 下一篇: 天燃气是多少钱一度?
