Re: Stack vs heap
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 02/26/04
- Next message: BBFrost: "Re: How to call an object method named in a string variable ???"
- Previous message: Ignacio Machin \( .NET/ C# MVP \): "Re: Suggestions on sending Files over Network"
- In reply to: Rakesh: "Re: Stack vs heap"
- Next in thread: Rakesh: "Re: Stack vs heap"
- Reply: Rakesh: "Re: Stack vs heap"
- Reply: Rakesh: "Re: Stack vs heap"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 26 Feb 2004 15:43:42 -0000
Rakesh <anonymous@discussions.microsoft.com> wrote:
> I am extremely sorry to have been vague in describing my issue. I am
> not thinking in the OOPS perpective, I am thinking in the internal
> compiler perpective.
>
> Dataset ds = new Dataset();
> static DataSet sds = new Dataset();
> static int x = 0;
>
> From what I understand, the pointer ds is stored in the stack, and
> the object new Dataset() is allocated in the heap.
That depends on where that code is. You've given a snippet without any
context. Given that you've got the "static" modifier, I'll assume that
ds is an instance variable - in which case, no, it's not on the stack,
it's on the heap (as are the other two).
As I said before, see http://www.pobox.com/~skeet/csharp/memory.html
for a more detailed explanation.
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: BBFrost: "Re: How to call an object method named in a string variable ???"
- Previous message: Ignacio Machin \( .NET/ C# MVP \): "Re: Suggestions on sending Files over Network"
- In reply to: Rakesh: "Re: Stack vs heap"
- Next in thread: Rakesh: "Re: Stack vs heap"
- Reply: Rakesh: "Re: Stack vs heap"
- Reply: Rakesh: "Re: Stack vs heap"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|