Is Efficiant use of Memory still relevant?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
mattheweston
Chaos Rift Junior
Chaos Rift Junior
Posts: 200
Joined: Mon Feb 22, 2010 12:32 am
Current Project: Breakout clone, Unnamed 2D RPG
Favorite Gaming Platforms: PC, XBOX360
Programming Language of Choice: C#
Location: San Antonio,Texas
Contact:

Is Efficiant use of Memory still relevant?

Post 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?
Image
User avatar
davidthefat
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 529
Joined: Mon Nov 10, 2008 3:51 pm
Current Project: Fully Autonomous Robot
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: California
Contact:

Re: Is Efficiant use of Memory still relevant?

Post 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.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Is Efficiant use of Memory still relevant?

Post 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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Is Efficiant use of Memory still relevant?

Post 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...
User avatar
EccentricDuck
Chaos Rift Junior
Chaos Rift Junior
Posts: 305
Joined: Sun Feb 21, 2010 11:18 pm
Current Project: Isometric "2.5D" Airship Game
Favorite Gaming Platforms: PS2, SNES, GBA, PC
Programming Language of Choice: C#, Python, JScript
Location: Edmonton, Alberta

Re: Is Efficiant use of Memory still relevant?

Post 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.
User avatar
short
ES Beta Backer
ES Beta Backer
Posts: 548
Joined: Thu Apr 30, 2009 2:22 am
Current Project: c++, c
Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
Programming Language of Choice: c, c++
Location: Oregon, US

Re: Is Efficiant use of Memory still relevant?

Post 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
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
Post Reply