Re: C# Struct vs Class



Doesn't that mean that this is rounded to one paragraph in memory plus some
pointer? 16 + 4 = 20. Correct or not?

"Hafiz" <hafizur.rahman@xxxxxxxxx> wrote in message
news:1164776062.898230.167800@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Actually when I only declare struct it keep this on stack. but when I
add this struct to any arraylist then it keeps those in Heap. Then it
already takes memory for reference.

So my assumption is if we use struct but keep reference for further use
then struct and class is same?

Any idea ?

Thanks to all for replying this.



Kevien Lee wrote:
//to reduce the memory size I have redeclared this in struct

The struct is alloc in stack,but the class was on the heap.still there
is same size,but you should consider the value type and ref type
boxing/unboxing operate,it is the most cost



.



Relevant Pages

  • Re: C# Struct vs Class
    ... round all variables allocated in memory to one byte, word, etc. ... So my assumption is if we use struct but keep reference for further use ... is same size,but you should consider the value type and ref type ...
    (microsoft.public.dotnet.framework.performance)
  • Re: C# Struct vs Class
    ... Actually when I only declare struct it keep this on stack. ... add this struct to any arraylist then it keeps those in Heap. ... So my assumption is if we use struct but keep reference for further use ... is same size,but you should consider the value type and ref type ...
    (microsoft.public.dotnet.framework.performance)
  • [PATCH 07/24] io-controller: Common hierarchical fair queuing code in elevaotor layer
    ... Requests keep a reference on ioq and ioq keeps keep a reference ... So the queue can be freed. ... Cgroup deletion path holds iocg->lock and removes iog entry ... +static struct io_group * ...
    (Linux-Kernel)
  • [PATCH 07/23] io-controller: Common hierarchical fair queuing code in elevaotor layer
    ... Requests keep a reference on ioq and ioq keeps keep a reference ... So the queue can be freed. ... Cgroup deletion path holds iocg->lock and removes iog entry ... +static struct io_group * ...
    (Linux-Kernel)
  • [PATCH 08/28] io-controller: Common hierarchical fair queuing code in elevaotor layer
    ... Requests keep a reference on ioq and ioq keeps keep a reference ... So the queue can be freed. ... Cgroup deletion path holds iocg->lock and removes iog entry ... +static struct io_group * ...
    (Linux-Kernel)

Loading