Page 1 of 1
Is Efficiant use of Memory still relevant?
Posted: Wed Sep 07, 2011 9:06 pm
by mattheweston
After rereading the discussion between Falco and avansc in my Tile Engine post, a thought occured to me. With the advent of garbage collection in languages such as Java and C#, does one have to concern themselves with efficiency of memory use?
Re: Is Efficiant use of Memory still relevant?
Posted: Wed Sep 07, 2011 9:43 pm
by davidthefat
mattheweston wrote:After rereading the discussion between Falco and avansc in my Tile Engine post, a thought occured to me. With the advent of garbage collection in languages such as Java and C#, does one have to concern themselves with efficiency of memory use?
I believe it has become more important because of the fact that the Morse's law has been slowing down. The fastest CPUs from 5 years ago were about 3.6GHz, it is still around that much, but with more cores. That being said, the actual clock speed of processors are not getting much faster, so we are turning to alternate solutions such as more cores.
Re: Is Efficiant use of Memory still relevant?
Posted: Thu Sep 08, 2011 9:13 am
by dandymcgee
davidthefat wrote:I believe it has become more important because of the fact that the Morse's law has been slowing down.
What you're referring to is Moore's Law. I'm not sure how relevant it is to the question. Even in garbage collected languages programmers should make use of large objects intelligently. In C#, it is wise to place a
using block around large objects which are needed only in the scope of the current function. Other objects should be manually disposed of where necessary.
Re: Is Efficiant use of Memory still relevant?
Posted: Thu Sep 08, 2011 10:30 am
by Falco Girgis
mattheweston wrote:After rereading the discussion between Falco and avansc in my Tile Engine post, a thought occured to me. With the advent of garbage collection in languages such as Java and C#, does one have to concern themselves with efficiency of memory use?
Absolutely not.
Operating systems are allowed to whore out all kinds of resources that they aren't using, because eventually a garbage collection system will clean up after them. Video games are allowed to allocate all kinds of memory and use memory extremely inefficiently, because it's not like they demand any sort of performance or have any sort of bottleneck when sending data back and forth to the GPU. Embedded systems don't need to handle memory management efficiently, because they have limited RAM, so they'll just shit their pants and crash.
How many times do people bitch that their PCs run slowly? How many times do people bitch that framerates suck? Garbage collection is still an extremely slow, expensive process. It helps quite a bit, so that you don't manually have to free memory, but that doesn't mean you can use it shittily and not expect performance drops.
I'm always shocked at how many programmers have a "fuck efficiency" mentality. So where does the performance come from? Are you putting the weight of it all on the electrical engineer's shoulders, because they build the hardware (that we programmers are too ignorant to use effectively)? You're free to use their hardware in as inefficient a manner as you please, but the responsibility for your performance is their duty? So how much more could you get out of hardware if your code
didn't suck?
That argument falls apart even more when you think about the time complexity of algorithms... Making one instruction or set of instructions execute faster isn't going to help when your shitty algorithm is O(N^2) when it should be O(logn) or when you're allocating 20x what you actually need. You have far more power over your own program's efficiency than any hardware engineer or garbage collector...
Re: Is Efficiant use of Memory still relevant?
Posted: Thu Sep 08, 2011 6:10 pm
by EccentricDuck
The thing is, it's more about the allocation and access of that memory than using up the memory. Modern computers have a ton of memory - and just because a new computer isn't using all 8 GB of available memory doesn't mean it won't take a performance hit by using more. If you're running an intensive program that constantly allocates/swaps memory, you're going to spend a great deal of wasted CPU/GPU cycles essentially waiting on memory operations because memory can't keep up with your CPU/GPU. Even accessing memory constantly is slow - which is where caching comes in and it's why efficient use of discrete chunks of data on the stack that are close to where they're being using can speed up computation enormously.
Falco left a really good link not too long ago - in a thread where I'd asked about caching - to a presentation by the creators of God of War where they talk about efficient memory usage and caching. It's a good read.
Re: Is Efficiant use of Memory still relevant?
Posted: Thu Sep 08, 2011 8:13 pm
by short
EccentricDuck wrote:
Falco left a really good link not too long ago - in a thread where I'd asked about caching - to a presentation by the creators of God of War where they talk about efficient memory usage and caching. It's a good read.
http://research.scea.com/research/pdfs/ ... 8Mar03.pdf