I was reading on memory Allocation concepts. where I found a statement saying Object Types needs Dynamic Memory and Primitive types needs Static memory they justify it saying If the requirement is of dynamic memory, it’s allocated on the heap or else it goes on a stack.
i am not getting the concept why this is so?
Every help is appreciated.
This answer is not 100% complete, but some of this is relevant, and I don't have the rep to simply comment...
The heap sticks around for the life of the program and is much larger (in general), so it may be a design decision that objects (in memory managed languages like C# and Java) are allocated to the heap to not overload stack memory. Also, stack memory is associated with variable scope (when it can be used) by nature of a stack, and if the memory manager will handle the objects it is more efficient to do it at certain times, versus every time the variable pops off the stack. Heaps also do not have variable size restrictions, which more realistically accommodates objects, which can be very large depending on what is defined in their class.
Here is a very good explanation of the differences of the two (stack, heap):
Also very good, but more geared toward C:
Though neither of those links specifically address WHY for C#. I'm probably going to get docked for this answer :)