------ Solution ---------------------------------------- ----
http://blog.csdn.net/wulianghuan/article/details/8602254
carefully read the side of the blog , I think you will understand more thoroughly
------ Solution --------------------- -----------------------
http://blog.csdn.net/yingfeng612/article/details/8750385
closer look .
------ Solution ---------------------------------------- ----
stack : For a machine , the stack space is fixed and is far smaller than the heap space . Advanced after the stack Needless to say , its use is very common , but they are lightweight data store . For example, in a function call, the function parameters will push some protection ; function body pointer , local variables are stored in the stack . You're unlikely to be in a function body using hundreds of thousands of bytes of local variable bar, stack space is enough ;
Heap : heap space and machine configuration. When you use the new , the first will open in a virtual memory space storage space, if virtual memory depletion , then use your memory , that is your hard disk space , so in the current machine configuration , you can freely new and less to worry about not enough memory . However, memory leaks are also caused by the heap memory . Of course, there is no need to worry too much java this problem .
------ Solution ---------------------------------------- ----
stacks : the main store basic data types of variables , for example : int a reference variable Integer in = null, stack memory speed
heap : put new out of the main object instance variables , such as arrays , new out of the object , the heap is dynamically allocated memory space , so the belt speed slower.
------ For reference only -------------------------------------- -
Baidu 's

------ For reference only ---------------------------------------
heap : mainly used to store the new out of the object
stack : mainly used for object references , that simple point is the object address
------ For reference only ----------------- ----------------------

two memory areas .
effect is not the same.
heap : mainly used to store the new object out
stack : mainly used for object references , that simple point is the object address
------ For reference only ----------------- ----------------------
heap reference type
stack value types
mainly based on these two data structures , etc., etc. access speed performance to points .
------ For reference only -------------------------------------- -
are actually memory, but is used in different ways.
------ For reference only -------------------------------------- -
stack is your home cabinet
heap space is your home
------ For reference only ---------------------------- -----------
said simply, is suitable for the storage heap object instance , and class information , in which the data can be shared for multiple threads , which the existence of time depending on the data object classes there is time-dependent . Generally longer , but there 's data recovery needs GC
The stack is a method of execution region , which is stored in local variables and methods of the runtime stack frame , which data is private, not shared , and with the end of a method and destroyed. No GC recycling
------ For reference only ---------------------------------- -----
popular in terms of stack memory is the name of the object and stockpiling is new out of something
give an example to understand class A {
private int i;
private int j;
}
A a = new A ();
stack memory is the name of the object and stockpiling is a new A ();
The new A () thing is included i, j the space allocated .
没有评论:
发表评论