Re: C# Struct vs Class



Btw, not sure how it works now in .NET, but many years ago we were able to
round all variables allocated in memory to one byte, word, etc. Code was
rounding to one paragraph, etc. I don't think that something was
dramatically changed after that.

"Just D" <no@xxxxxxxxxxx> wrote in message
news:mnobh.5$sx2.0@xxxxxxxxxxxxxxx
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: [RFC v11][PATCH 05/13] Dump memory address space
    ... External checkpoint of a task other than ourself) ... each page is mapped to kernel memory and then ... * returns the page if it was modified (and grabs a reference to it), ... +static struct page * ...
    (Linux-Kernel)
  • System.Collections Memory and Speed
    ... Is there a formula to calculate the memory usage and estimate the speed? ... reference or any better suggestion) ... width, height and extension ... Value = Width, Height and Extension (Could be stored as a struct, string, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# Struct vs Class
    ... round all variables allocated in memory to one byte, word, etc. ... add this struct to any arraylist then it keeps those in Heap. ... is same size,but you should consider the value type and ref type ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Reference counting of MMC host driver modules
    ... calls blk_cleanup_queueon the underlying struct request_queue. ... The MD driver still has the block device open and, actually, ... things work fine unless the memory of the struct request_queue isn't ... the request_queue's reference count goes to zero even ...
    (Linux-Kernel)
  • Re: Reference counting of MMC host driver modules
    ... calls blk_cleanup_queueon the underlying struct request_queue. ... The MD driver still has the block device open and, actually, ... things work fine unless the memory of the struct request_queue isn't ... the request_queue's reference count goes to zero even ...
    (Linux-Kernel)

Loading