Microsoft working on new systems language
Jerry
jlquinn at optonline.net
Fri Jan 3 15:04:53 PST 2014
"Chris Cain" <clcain at uncg.edu> writes:
> On Monday, 30 December 2013 at 11:23:22 UTC, JN wrote:
>> The best you can do in those
>> languages usually is to just not allocate stuff during the game.
>
> Yeah. The techniques to accomplish this in GC-only languages surprisingly
> mirror some of the techniques where malloc is available, though. For instance,
> the object pool pattern has the object already allocated and what you do is
> just ask for an object from the pool and set it up for your needs. When you're
> done, you just give it back to the pool to be recycled. It's very similar to
> what you'd do in any other language, but a little more restricted (other
> languages, like D, might just treat the memory as untyped bytes and the
> "object pool" would be more flexible and could support any number of types of
> objects).
I find even in C++ that I need to create object pools for speeding up
our code. Generally this is due to objects that have allocated memory
in them, such as vectors. For example
(C++)
class blah {
vector<int> a, b, c, d;
};
I end up making the object declare a reset function so that it can be
recycled without paying for the vector reallocations.
This is definitely a useful pattern to not have to rewrite.
Jerry
More information about the Digitalmars-d
mailing list