我現在正在學習JVM內存model.I有一個問題:對象引用變量(a中)存儲在哪裏?
package com; public class TestAllocation { private static final int _1MB = 1204*1024; public static void main(String[] args){ testAllocation(); } public static void testAllocation(){ byte[] allocation1,allocation2,allocation3,allocation4; allocation1 = new byte[2 * _1MB]; allocation2 = new byte[2 * _1MB]; allocation3 = new byte[2 * _1MB]; allocation4 = new byte[2 * _1MB]; } }
那麼,哪裏的參考allocation1,allocation2存儲?由於testAllocation()是一個靜態的方法,所以,這個函數裏面的變量存儲在方法區域?但是每次調用一個函數時,都是棧 push/pop操作。於是,allocation1,allocation is存儲在
堆棧幀testAllocation()?
但有一點很清楚,就是數組值,存儲在java堆,對不對?