A
arcticool
I had an interview today and I got destroyed
The question was why have a stack and a heap?
I could answer all the practical stuff like value types live on the
stack, enums are on the stack, as are structs, where classes are on
the heap... when value types go out of scope the memory is re-
allocated, object remain in memory waiting to be cleaned up by the
garbage collector, etc, but he responded 'so why not just put say a
class on the stack? why bother having a heap at all?' I said I
didn't know and he responded 'oh that's just the way of the world
then eh?' like a real smart a**. I felt pretty small. So can someone
please explain this to me so hopefully I never have to feel like
that again.
Thanks,
Jeff
--
The question was why have a stack and a heap?
I could answer all the practical stuff like value types live on the
stack, enums are on the stack, as are structs, where classes are on
the heap... when value types go out of scope the memory is re-
allocated, object remain in memory waiting to be cleaned up by the
garbage collector, etc, but he responded 'so why not just put say a
class on the stack? why bother having a heap at all?' I said I
didn't know and he responded 'oh that's just the way of the world
then eh?' like a real smart a**. I felt pretty small. So can someone
please explain this to me so hopefully I never have to feel like
that again.
Thanks,
Jeff
--