Re: Garbage collectable pinned arrays!



On Feb 11, 11:51 pm, "Atmapuri" <janez.makov...@xxxxxxx> wrote:
Hi!

It would be great, if the pinned arrays would be garbage
collectable. This would greatly reduce the amount of copy
back and forth the managed and unmanaged memory.
I cant think of a single reason, why the GC should not allow
this.

It would be also great, if the memory could already be allocated
as pinned:

double[] array= new pinned uninitialized double [500];

where uninitialized would mean that it is not set to zero, thus
saving processing power where GC pressure is high.

As I understand it, pinning is an attribute of the *reference*, not
the object itself. The object is pinned when there's a pinning
reference to it anywhere on the call stack.

Thus, it doesn't make sense for a pinned object to be garbage
collectible. The object can't be considered garbage anyway while
you're still holding a reference to it, and once you let go of the
last reference, it's no longer pinned.

I don't see why you'd even want it to be collectible, actually. The
point of pinning is to let unmanaged code access the object without
worrying that the GC will move it. But collecting the object and
letting its memory be used for something else is just as dangerous as
moving it!

Jesse
.



Relevant Pages

  • Re: async sockets and threading
    ... a reference to the Socket instance as long as the asynchronous operation hasn't completed. ... The "_socket" static variable _ought_ to be sufficient here, but if there's a bug that causes it not to be, there's no reason to think that bug won't also affect the "_stream" variable. ... If the JIT compiler is deciding that these static variables are unreachable for some reason, then once the "_stream" variable has been assigned, that's the last use in the method, and the bug might lead to the GC collecting the objects. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Interview with Alan Kay
    ... Well, Generational GCs are not garbage collectors, they are actually ... They collect live data, and leave the garbage. ... and thus collecting the live data is going ... pointers regardless of what page they were on. ...
    (comp.lang.lisp)
  • Re: Scotts catalog/inventory software
    ... As far as reference material, you may find the Scott catalogs in your ... If you are collecting topicals take a look at ... > I have no nearby Stamp Shoppe. ...
    (rec.collecting.stamps.discuss)
  • Re: Form not being garbage collected
    ... >From the code snippet you pasted, we could say there is no memory leak ... collecting to occur. ... you found that the main form of your app always not get garbage ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Is garbage collection here yet?
    ... clean up afterwards i.e. collecting the garbage. ... If you clean up afterwards, it's not leaking, right? ... Ok, to rephrase it, you let garbage accumulate. ... before the next line of tcl code gets excuted. ...
    (comp.lang.tcl)

Loading