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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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).
On Thu, May 4, 2017 at 6:00 PM, T L <tapi...@gmail.com> 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.
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...@googlegroups.com.
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).
On Thu, May 4, 2017 at 6:00 PM, T L <tapi...@gmail.com> 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.
To see why the "immediately" solution is not adequate:Step 1: Create a single linked list or a binary tree of a couple billion elements. Make sure there is only a single reference to the head element.Step 2: Release the pointer to the headStep 3: Twiddle your thumbs while your program is blocked since all elements needs to be immediately freed.
type st struct { j int }
type at { i int; s st }
var a at
var s st
dealWithSt(&s)
dealWithSt(&a.s)
So, you have two choices:
- either you have to find base address for pointer on every rc increment/decrement - and it is quite expensive operation (with current GC it is done very rare),
- or you forbid interior pointers (and store a.s in separate location) - and then it is not Go language.
Maybe a 100µs GC would be fast enough for you to be at easy with your game FPS.
If there are ARCs like shared_ptr in C++, I think there must be some kind of raw pointers not managed by gc, this means bringing more "unsafe".
Any memory management strategy costs time. Reference counting is not cheap. Incrementing and decrementing millions of reference counters costs time. Please consider caching issues as well.Go GC, as it currently stands, is very effective, as other people in this forum can confirm to you. Several Gigs of data and the only way to perceive any performance impact is by generating a profile chart!
Reference counting does not come without unforseen stalls - dereference a huge structure with millions of objects!
The 100µs is STW duration. I mean the fps may decrease some during the period of GC running.