|
![](/i/fill.gif) |
Darren New <dne### [at] san rr com> wrote:
> Interestingly enough, when writing C# video games for the XBox, one
> suggestion is to avoid allocating memory each frame. The GC engine on the
> xbox apparently sucks, so if you're getting more than a handful of GCs per
> minute, players are going to notice. So instead, you use things like points
> and vectors and matricies and arrays of vertex structures and such, all of
> which allocate on the stack without heap or pointers. That's something that
> would be very difficult to do in Java, if it were possible at all.
If you are an expert and competent C++ programmer (especially a games
programmer), you have usually developed a natural way of thinking and
designing programs (especially ones requiring maximum efficiency) which
minimizes the amount of individual memory allocations, because 'news' and
'deletes' are heavy operations and you don't want a lot of those happening
each frame. In some situations this might result in slightly awkward
designs (where simplicity is somewhat being traded for memory usage
efficiency), but in many situations it is possible to write simple and
clean code which is at the same time efficient in this sense.
A Java programmer doesn't have to bother thinking about how many 'news'
he is writing, both because he can't really avoid them and because they
don't really matter all that much from an efficiency point of view (with
the possible exception of them causing somewhat more memory being allocated
than an equivalent well-designed C++ program would), and hence the mentality
regarding dynamic allocation is completely different.
I suppose, thus, that it's usually much easier for a competent C++
programmer to start writing efficient C# programs for the XBox than
for a competent Java programmer.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |