Also, there are many other considerations - like if the objects are const, if not, using smart pointer refs may be the only way in a concurrent system, etc.

There's a lot of factors to consider in value vs. reference - I trust the Googlers investigated which was most appropriate.

-----Original Message-----
From: Robert Engels
Sent: Feb 14, 2020 11:23 AM
To: Alex Besogonov
Cc: ⚛ <0xe2.0x9a.0...@gmail.com>, golang-nuts
Subject: Re: [go-nuts] Go without garbage collector


Yes, and when you store value objects in a vector and it is resized, it is very expensive as you need to make copies of "large objects", vs a "pointer to an object".

Which is better depends on the object lifetimes, size of objects, access patterns, etc.

Clearly the Googlers that wrote the code felt that using pointers rather than value objects was more appropriate. I didn't write that code, nor have I investigated the code enough to have an opinion as to whether that was an appropriate choice - but I assume they did.
-----Original Message-----
From: Alex Besogonov
Sent: Feb 14, 2020 11:01 AM
To: Robert Engels
Cc: ⚛ <0xe2.0x9a.0...@gmail.com>, golang-nuts
Subject: Re: [go-nuts] Go without garbage collector

No, you do not. In C++ you would put object values in the vector, rather than pointers to objects.

On Feb 14, 2020, at 08:57, Robert Engels <reng...@ix.netcom.com> wrote:

If you have a container of objects, you still need to free each object. If it is an "container" of value objects (one reference to a block of memory), you can free once at the block level, but if the block needs to be expanded (dynamic memory), you need to copy all of the data (or use a complex sparse array structure, and then you pay the performance hit during iteration). There is no free lunch.

-----Original Message----- 
From: ⚛ <0xe2.0x9a.0...@gmail.com> 
Sent: Feb 14, 2020 8:52 AM 
To: golang-nuts 
Subject: Re: [go-nuts] Go without garbage collector 

On Friday, February 14, 2020 at 3:43:40 PM UTC+1, Robert Engels wrote:
If each object exists independently - which it does in this case - you must use a free on each object. So you are going to loop - it just may be hidden from you.

I am sorry, I do not understand your style of reasoning in general. 

-- 
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/9f980aed-6fd7-4ac5-ab79-c8415302a31c%40googlegroups.com.




-- 
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/gPoYIPBGy24/unsubscribe.
To unsubscribe from this group and all its topics, 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/1662044109.1005.1581699420223%40wamui-sophie.atl.sa.earthlink.net.





--
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/1282352587.1683.1581701009083%40wamui-fuzz.atl.sa.earthlink.net.



--
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/1996668804.1832.1581701642304%40wamui-fuzz.atl.sa.earthlink.net.

Reply via email to