Re: ref?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



What i don't understand is, in c#, it always uses reference by i thought,
or is it only refs on classes?

Memory is allocated on the stack and the heap; this translates to
primitive "value types" and "reference types." An integer or boolean
is stored by value, whereas instances of classes are created with the
new keyword and then managed by reference, where in your code you have
to variables that are both references to the same object in memory, and
when one makes a change, the other will see it.

Counter-intuitively, though, structs are value types. So if you use "x
= y;" in your code you're cloning the values, not using two pointers to
the same location.

.



Relevant Pages

  • Re: to dispose or not ?
    ... always have the system memory roots available. ... collector for the Gen0 and Gen1 heaps and a mark/sweep/compact collector for ... heap or compacts free space out of the heap. ... the reference from the variable to the object in the heap. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: C++ Garbage Collector on VMS?
    ... case of a reference counting system, have a non-zero reference count) as ... to the beginning of the heap, updating the pointers to the objects as it ... (segregating allocation areas by type/size can help a lot there, ... any way with GC-controlled memory). ...
    (comp.os.vms)
  • Re: Memory (Structure vs Class)
    ... does the reference just reside on the heap or is the entire class ... actually a reference to an Interface. ... Dim cls As Class1 ' this declares and defines a block of memory (that ...
    (microsoft.public.vb.general.discussion)
  • Re: Queue cleanup
    ... without ever touching the garbage, and then they release the old heap. ... And suddenly you’ve doubled the memory requirements. ... that‘s not how locality of reference works. ...
    (comp.lang.python)
  • Re: HOW IS Memory Used by a VB App
    ... OK, I think the scene has been said for Virtual Memory, and other posts have ... variables contained an object reference then the body of the object would ... The heap manager takes care of ... if those pages get re-used by the heap manager then ...
    (microsoft.public.vb.general.discussion)