When we declare the variables on primitive datatype int,float ,char etc they get allocated in the stack memory and they are called value types they are created when they come in scope of the program and the automatically killed from the memory they go out of the scope in the program.
when we use reference types they get allocated in the heap memory they don't killed why they out of the scope however in the days of C++ it was duty of the programmers to clear the reference types from the heap memory to overcome this problem associated with reference types Java,C# the concept of the Garbage Collector it is nothing but special kind program which keeps on itself rotating itself in the heap memory and the keeps the count of number of objects in stack memory on that class type when count reaches zero the class has gone totally out of the scope in the application garbage collector cleans the reference type from the clear heap memory this will not only in removing unwanted objects from heap memory it also helps us t speed up the application
Comments
Post a Comment