Sign in to follow this  
Silly_con

Memory allocation

Recommended Posts

Silly_con    136
For a medium complexity game, is best to use new/delete (or malloc/free) function every time you need alloc or release memory, or is best to allocate much memory at start, and use a class to manage this allocated memory ? thnx

Share this post


Link to post
Share on other sites
Ra    1062
In most cases it'll be better to allocate memory at the start rather than on-demand because memory allocations are generally slow. You'll probably want to allocate a decent amount of memory at the start of your program to avoid having to allocate memory in time-critical sections of your code.

Share this post


Link to post
Share on other sites
SiCrane    11839
Of course, new/delete can be overloaded (globally or on a per-class basis) to use a more specialized memory allocation routine, including one that pre-allocates the memory up-front. That way you don't have to change how you program if you determine that you need to do memory pooling later on.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this