POV-Ray : Newsgroups : povray.off-topic : C# vs Java in memory management : Re: C# vs Java in memory management Server Time
3 Sep 2024 21:18:27 EDT (-0400)
  Re: C# vs Java in memory management  
From: Warp
Date: 24 Jul 2010 14:14:11
Message: <4c4b2d73@news.povray.org>
Darren New <dne### [at] sanrrcom> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.