|
边看书,边看此贴
写一些偶的笔记
Where storage lives
There are six different places to store data:
1.Registers.This is the fastest storage because it exists in a place different
from that of other storage:inside the processor.You don`t have direct control,nor do
you see any evidence in your programs that registers even exist.
2.The stack.This lives int the general random-access memory(RAM) area,but has
direct support from the processor via its stack pointer.The exact size and lifetime of
all the data is stored on the stack.
3.The heap.This is general-purpose pool of memory(also in the RAM area)where
all Java objects live.Whenever you need to create an object,you simply write the code
to create it by using new,and the storage is allocated on the heap when that
code is executed.
4.Static storage.Static storage(also in RAM) contains data that is available
for the entire time a program is running.You can use the static keyword to
specify that a particular element of an object is static,but Java objects themselves
are never placed int static storage.
5.Constant storage.Constant valuse are often placed directly in the program
code,which is safe since they can never change.Sometimes constant are cordoned off by
themselves so that they can be optionally placed int read-only memory (ROM),in
embedded system.
6.Non-RAM storage.If data lives completely outside a program,it can exist while
the program is not running,outside the control of the program. |
|