Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    I would add to your point #2 that if you stored objects on the stack (imagine a dictionary object with hundreds of thousands of entries) then in order to pass it to or return it from a function you'd need to copy the object every time. By using a pointer or reference to an object in the heap, we only pass the (small) reference. Commented Apr 5, 2011 at 12:25
  • 1
    I thought 3 would be 'no' because if the object is being garbage-collected, then there is no reference in the stack pointing to it. Commented Apr 5, 2011 at 13:19
  • @Luciano - I see your point. I read question 3 differently. The "at the same time" or "by that time" is implicit. :: shrug :: Commented Apr 5, 2011 at 16:53