On Friday, May 5, 2017 at 12:33:57 AM UTC+8, Axel Wagner wrote:
>
> As so often is the question: Why?
>
> I don't believe this will ever be supported by gc; but if you think it's a 
> good idea, you can of course do it and see whether it actually solves your 
> problems (my prediction would be "there won't be a net change in problems", 
> but am ready to be proven wrong).
>

ARC is not part of GC.

The current official GC algorithm will tolerate the percentage of garbages 
set by GOGC environment variable.
The default value of GOGC is 100. That means most half of the memory 
allocated is garbage before gc starts.
Sometimes I want to make GOGC small. But small GOGC value will run garbage 
collector frequently and consume much CPU.

In fact, to find which memory blocks are garbages, most energy consumed by 
the garbage collector is wasteful.
For an extreme case, there are 9999 alive pointers which all reference very 
small memory blocks,
then a very large short-lived memory block is allocated and becomes unused 
soon. 
If the garbage collector starts now, the collector will waste most time to 
find the only garbage.

If the runtime use ARC to manage pointer to the large short-lived memory 
block,
the memory block will be collected immediately after it becomes unused.
This will largely reduce burden of running garbage collector.

ARC would be a better option for game apps than GC, to keep the fps stable.
 

>
> On Thu, May 4, 2017 at 6:00 PM, T L <tapi...@gmail.com <javascript:>> 
> wrote:
>
>> sometimes, I really want to some memory blocks be collected when they 
>> become unreferenced immediately..
>>
>> -- 
>> 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...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to