Do you actually use dynamic memory?

Member
Posts: 749
Joined: 2003.01
Post: #1
Looks to me it's quite difficult and not really important in most games...

Do you use it?

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
What kind of question is this?

I'm assuming you mean new/malloc/+alloc? In which case, what answers did you expect other that "yes, always"?
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #3
Yeah I mean new and delete.

Couldnt you just make arrays "big enough"? I mean, rarely games have memory problems, much more often performance problems.

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
There's no reason dynamic memory need be any more performance-problematic than making lots of global arrays "big enough"...

There's no way to use inheritance in C++, or any Objective C without using dynamic memory, so that alone will swing most people.

Making lots of global arrays "big enough" has its own problems. Karl Berg's .obj loader took that approach, and it liked to make about 50MB per object. Then when you made a global array of "enough" objects (say, 20) then all of a sudden you're using more than a GB of RAM....
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #5
hmmm... ok...

looks like my games are way too simple for me to appreciate this stuff.

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #6
I'm voting "often" since I use arrays and stack objects when it's advantuous to do so (like I know that I'm going to need only 3 values for a vector, or I have an object that I won't be moving around), but I use heap memory otherwise.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #7
OneSadCookie Wrote:There's no way to use inheritance in C++, or any Objective C without using dynamic memory, so that alone will swing most people.
I have C++ objects that use inheritance and virtual functions that are created on the stack rather than the heap. You use Type object(parameters) to create such object, and they work fine. Objective C, however, doesn't let you create such objects.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
oh, inheritance will "work", you just can't use dynamic polymorphism without at least taking the address of the object, and taking the address of objects on the stack is asking for pain Wink
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #9
Najdorf Wrote:Looks to me it's quite difficult and not really important in most games...

Do you use it?

Uh, actually, I use it a lot in whatever project I'm working on, be it a simple game, a tool, or a commercial level game.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #10
OneSadCookie Wrote:oh, inheritance will "work", you just can't use dynamic polymorphism without at least taking the address of the object, and taking the address of objects on the stack is asking for pain Wink
As in you store a bunch of subclasses as superclasses (for a container or what-not)? For that, pointers are definitely best. I usually only use stack/data objects for temporary objects or instance variables that are initialized only on the initialization of the class they are in.
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #11
I only use behemoth switch statements in my programming. Maybe one unsigned long long to track the state, and that's it.

-Jon
Quote this message in a reply
Apprentice
Posts: 8
Joined: 2005.07
Post: #12
That must have been One Clever Switch , and One Very Well Packed Int Smile

-> http://otee.dk/forum/viewtopic.php?t=510

How many man-hours did actually go into it?

d.
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #13
aarku Wrote:I only use behemoth switch statements in my programming. Maybe one unsigned long long to track the state, and that's it.

-Jon
Yeah, that's how REAL programmers do it.
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #14
davidhelgason Wrote:That must have been One Clever Switch , and One Very Well Packed Int Smile

-> http://otee.dk/forum/viewtopic.php?t=510

How many man-hours did actually go into it?

d.

I'd estimate 100.

-Jon
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #15
GIgantic switch statements have their place, but I try to avoid them unless I think it's necessary (such as with data streams)
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Troubles With Dynamic Memory Nick 1 2,431 Sep 7, 2005 08:56 PM
Last Post: Nick