iDevGames Forums
Do you actually use dynamic memory? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Do you actually use dynamic memory? (/thread-5120.html)

Pages: 1 2 3


Do you actually use dynamic memory? - Najdorf - Aug 27, 2005 06:21 PM

Looks to me it's quite difficult and not really important in most games...

Do you use it?


Do you actually use dynamic memory? - OneSadCookie - Aug 27, 2005 06:24 PM

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"?


Do you actually use dynamic memory? - Najdorf - Aug 27, 2005 06:30 PM

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.


Do you actually use dynamic memory? - OneSadCookie - Aug 27, 2005 07:06 PM

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....


Do you actually use dynamic memory? - Najdorf - Aug 27, 2005 08:48 PM

hmmm... ok...

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


Do you actually use dynamic memory? - akb825 - Aug 27, 2005 10:19 PM

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.


Do you actually use dynamic memory? - akb825 - Aug 27, 2005 10:26 PM

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.


Do you actually use dynamic memory? - OneSadCookie - Aug 28, 2005 01:49 AM

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


Do you actually use dynamic memory? - Malarkey - Aug 28, 2005 04:08 PM

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.


Do you actually use dynamic memory? - akb825 - Aug 28, 2005 07:24 PM

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.


Do you actually use dynamic memory? - aarku - Aug 28, 2005 07:37 PM

I only use behemoth switch statements in my programming. Maybe one unsigned long long to track the state, and that's it.

-Jon


Do you actually use dynamic memory? - davidhelgason - Aug 28, 2005 07:51 PM

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.


Do you actually use dynamic memory? - Josh - Aug 28, 2005 09:21 PM

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.


Do you actually use dynamic memory? - aarku - Aug 29, 2005 12:24 PM

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


Do you actually use dynamic memory? - akb825 - Aug 29, 2005 01:06 PM

GIgantic switch statements have their place, but I try to avoid them unless I think it's necessary (such as with data streams)