FAQ
Certainly, someone more knowledgeable will comment on these things but in
my experience what you mention is correct though I was working in the area
of millions of objects that contained pointers to tens of millions of
objects. I would suggest writing benchmarks to see if you should even care
though. In my case, I was wanting to recreate these large structures many
times per second and the related calculations were cheap enough that the GC
overhead wasn't really call for. Also, I found it more fitting to provide a
copy of an object since the original data structure that I was working with
could change so this made sense for me as well.

So in all, benchmark, see if you really need to be concerned about this.
Profiling your tests can be really helpful here as well.
On Sunday, October 26, 2014 3:48:07 PM UTC-5, nicolas...@gmail.com wrote:

I must create a lot of objects.
My concern is to ease the work of the garbage collector, to avoid frequent
and long pauses.

What is your opinion about the following sentences ?

- Instead of creating 100'000 objects of type T separately, is it better
to create one big array of 100'000 elements [100000]T ?

- Each of these objects contains 8 pointers *T to other objects. Is it
better to replace these pointers *T by indices (int) into the array of
objects ?

- The frequency of the GC is proportional to the garbage creation rate ?

- The GC duration is proportional to the total number of pointers used in
all live objects (mark phase), and the number of objects to free (sweep
phase) ?

- Each time a pointer is updated by the Go code, is it true that the
garbage collector must do some processing ?

- What is the most important, finally:
- avoid creating garbage ?
- avoid creating too many objects ?
- avoid creating too many pointers ?
- avoid code that update pointers with high frequency ?
--
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.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 13 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 26, '14 at 8:48p
activeOct 27, '14 at 1:27p
posts13
users6
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase