Jump to content
  • Advertisement
Sign in to follow this  
Pooya65

memory managment

This topic is 2949 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

Advertisement
What do you want it to do? Take an already written program and make it's memory allocations/deallocations faster?

Share this post


Link to post
Share on other sites
Quote:
What do you want it to do? Take an already written program and make it's memory allocations/deallocations faster?


thanks for your interesting
yes


i read some things about Memory Pools (in below articles) but i said this schema is not fast in real game

http://seganx.com/?p=326#comments
http://www.codeproject.com/KB/cpp/MemoryPool.aspx

Share this post


Link to post
Share on other sites
In general, memory pools are quite fast and very commonly used in games. Perhaps you were simply looking at an inefficient implementation.

You're going to have to provide more information about your requirements to get any real help, in any case.

Share this post


Link to post
Share on other sites
Quote:
http://www.codeproject.com/KB/cpp/MemoryPool.aspx

Ugh, this one uses linked list with pointers. That's just horrible.

Memory pools should be used for identical data types only. Anything else is generic allocator.

template < class T, size_t N >
struct Pool {
Pool() : offset(0) {}
T * acquire() {
return (offset < N) ? &storage[offset++] : NULL;
}
void reset() {
offset = 0;
}
private:
T storage[N];
size_t offset;
};

That is as good as it gets. Constructors and destructors aren't called, so classes on which it's used should be PODs and/or initialized after acquired.

It doesn't support releasing individual pieces, so algorithm should be structured in such a way to discard everything after done.

Or, keep two pool, when memory needs to be reclaimed, copy valid objects by obtaining them from second pool, then reset the first one.

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!