Memory Allocation

Started by
10 comments, last by 21st Century Moose 11 years, 9 months ago

Note that it is idiomatic to use the return value of a function where possible:
...
Once you have learned about memory allocation, you can then go on to use the standard library containers to avoid unnecessary manual memory management:
...
This will prevent the memory leaks NightCreature83 mentioned.

Just as a side note you have to learn memory management and all it's little caveats before you move onto the standard containers as not all shops use the standard containers. Some shops avoid the standard library if they can for various reasons and thus you are off having to know memory managment, also it gives you an insight into how the Standard Containers work in the background.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

Advertisement
One note about memory management is that - depending on the APIs available to you - manual memory management may very well turn out to be more suitable for you. E.g. on Windows, a single HeapDestroy call is all that is needed to free a whole chunk of separate allocations, and without needing to keep track of individual allocations within that chunk.

Of course when learning you should treat this as an "advanced topic" and keep away from it - learn the proper way first. But do be aware that it does exist and can occasionally be a preferable choice - just don't do it yet.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement