Jump to content
  • Advertisement
Sign in to follow this  
Noods

Resources on memory allocation...

This topic is 3712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a problem that I am working on in my current program. While steping through it, I realized how primitive my implementation of dynamic memory is and I wanted to start learning about how larger programs utilize persistent dynamic memory. Can someone point me to a good book or resource on the topic?

Share this post


Link to post
Share on other sites
Advertisement
C++

Mainly because the only ways I see how to implement what I am trying to do are global vectors or static vectors. I would like to see some other programs in action and read a bit about the do's and dont's.

Share this post


Link to post
Share on other sites
Quote:
...because the only ways I see how to implement what I am trying to do...
What are you trying to do?

Share this post


Link to post
Share on other sites
A good place to start would be to do some study of data structures and design patterns, that'll give you a well rounded view of how objects (and memory) are handled and managed in c++. A good resource for some free-bees are sites like: http://www.freeprogramminresources.com also check out one of the best books out there on design patterns (IMHO) Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley Professional Computing Series).

Share this post


Link to post
Share on other sites
Are you sure this has anything to do with managing dynamic memory? It sounds like you just need some system design advice.

Share this post


Link to post
Share on other sites
Quote:
What are you trying to do?


My previous problem was allocating memory for sprite animations and the subsequent animation frames without knowing the number of animations at the beginning of the program. The solution I used was a vector of animation objects that contained a vector of frames. It worked perfectly for what I was going for actually.

Quote:
Are you sure this has anything to do with managing dynamic memory? It sounds like you just need some system design advice.


While this may be true, I am still fuzzy on how complex programs such as games use memory dynamically. Vectors seem to be a good solution for every problem I come across but I would like to see some other implementations.

Share this post


Link to post
Share on other sites
why not just use arrays and c++ built in dynamic allocation?


Spriteframes* sf = 0

when your app figures out how many you need

sf = new Spriteframes[num];

Share this post


Link to post
Share on other sites
Quote:
Original post by godsenddeath
why not just use arrays and c++ built in dynamic allocation?


Spriteframes* sf = 0

when your app figures out how many you need

sf = new Spriteframes[num];
If you do take this approach, use std::vector (there's little to gain in this particular case from managing the memory manually yourself).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!