Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #86627

Re: manual memory management, vs an automatic gc...

From "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups comp.lang.c++
Subject Re: manual memory management, vs an automatic gc...
Date 2022-09-26 17:09 -0700
Organization A noiseless patient Spider
Message-ID <tgtf0f$3rq4e$1@dont-email.me> (permalink)
References <tgl32i$2l0h0$1@dont-email.me> <tgrnsa$bj0$1@gioia.aioe.org>

Show all headers | View raw


On 9/26/2022 1:29 AM, Juha Nieminen wrote:
> Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>> I have conducted a lot of experiments in the past with garbage collected
>> languages, and have come to a conclusion. Manual memory management
>> techniques can be a good thing, even in a GC environment. Iirc, I wrote
>> about it here before, many years ago.
>>
>> Being able to create objects all over the place willy-nilly, and never
>> even have to think about destroying them... Is a "convenience" that a GC
>> can help one out with...
> 
> I think that as data-oriented design (as opposed to object-oriented design)
> is gaining popularity, especially in certain fields of programming that
> require extreme efficiency (such as game engines), the need for automatic
> garbage collection is diminishing, at least in those fields.
> 
> The problem with automatic GC is that it's mostly needed when you
> allocate dynamically individual objects (which is the case with most
> GC'd languages). However, using individually allocated objects is a
> performance killer. (In fact, using "objects" at all, ie. class
> instances, is a performance killer.)

Quick note. Will get back to you.

Instead of allocating one "object" at a time, allocate a chunk of 
contiguous (wrt memory representation) objects instead. Iterating 
through the chunk will be good for the cache.



> 
> DOD doesn't require individually allocated objects, as everything is
> put into arrays. (And not as in arrays of objects. Arrays of individual
> values, which would normally be class member variables.)
> 
> Since optimally all the dynamically allocated data is in arrays, and
> no "object" refers to any other "object", the need for automatic GC
> is significantly lessened.
> 
> In contrast, low-level control of what the compiler produces is
> significantly more important.

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

manual memory management, vs an automatic gc... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-09-23 12:57 -0700
  Re: manual memory management, vs an automatic gc... Juha Nieminen <nospam@thanks.invalid> - 2022-09-26 08:29 +0000
    Re: manual memory management, vs an automatic gc... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-09-26 17:09 -0700
      Re: manual memory management, vs an automatic gc... Juha Nieminen <nospam@thanks.invalid> - 2022-09-27 06:45 +0000

csiph-web