to avoid false delete object, we could add some checking code in markDelete 
just like what we do with raceenable. 
one complicate case is internal pointer, we could recursively mark delete 
or mark delete internal pointer by hand ?
On Friday, May 28, 2021 at 10:03:28 AM UTC+8 cheng dong wrote:

> 1. first case
>
> ```go
> func do(x SomeInterface) {...}
> func outer() {
>   var x = new(A)
>   do(x)
>   markDelete(x) // explicit delete x if we know x's lifetime end here
> }
> ```
>
> if we know in advance that x's lifetime will finish when outer end. can we 
> mark delete x. and the compiler can safely alloc x on stack.
>
> 2. second case
>
> ```go
> func loop(ch <-chan *A) {
>   for x := range ch {
>     use(x)
>     markDelete(x)
>   }
> }
> ```
>
> most times, we know which objects could safely be deallocated just like in 
> lang without gc, could we delete them immediately to relief gc pressure ?
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d5459f93-0d61-4972-abbb-16557941e2d0n%40googlegroups.com.

Reply via email to