dotnet / dotnet/dotnet-api-docs
The GCHandle.Free page needs to say more
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 950
- Fork
- 1.7k
- Merge medio
- 2g 19h
- PR unite (30g)
- 52
Descrizione
I came here from the GCHandle.Free F# page.
The page should say more:
- Even after
GCHandle.Free()is called, the object itself can still be used by any code that possesses a reference to it. - A pinned handle is no longer pinned after
GCHandle.Free(). (Or is it?)
All behavior wrt pinning should be explained somewhere (the GCHandleType page?) and referred to everywhere it is relevant. Contrasting the behavior of a pinned object vs system memory should also fully explained in the same place.
Other thoughts
If a GCHandle is still pinned after GCHandle.Free() then it seems reasonable that one should immediately free a pinned handle after pinning it. Also, it might be reasonable to do so in most other circumstances, and this should be discussed.
A GCHandle.IsPinned property would be good.
One is led to believe that the object will be pinned wherever it is at the moment, which could cause a fragmentation problem. Perhaps there should be another argument to Alloc that can be used to ask the collector to pack the object into the long-lived generation or to move it to system memory. This last would be especially good for an object that will never be freed. Moving to system memory would probably warrant additions for GCHandleType.SystemMemory and GCHandle.IsSystemMemory.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla pagina F# collegata su GCHandle.Free e dalla pagina GCHandleType menzionata nell’issue. Verifica il comportamento documentato della liberazione di un handle sottoposto a pinning e dell’utilizzo dell’oggetto referenziato, quindi chiarisci le indicazioni relative al ciclo di vita e al pinning nelle pagine pertinenti con riferimenti incrociati. Tratta le modifiche proposte a IsPinned, SystemMemory e all’allocazione come un ambito separato che richiede indicazioni da parte dei maintainer.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp, fsharp
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100