Memory and Optimization [tutorial? pls?]

Does anyone have any good tutorials for C++ on optimization and or memory? Those are my interests so I want to learn more about the two topics. :)

What could I learn to improve my knowledge on these two topics?
Does anyone recommend any books on these two topics?
Last edited on
Anyone? Q.Q
No, but love the Q.Q, it's been so long since I've seen someone use that emoticon, I've only seen it twice (including yours) outside of an FPS called Soldier Front, heh, not a friendly community to say the least.
http://www.agner.org/optimize/

What do you mean, "tutorial on memory"? On the definition of "memory"? On how to use memory? On how to eat memory chips in ham sandwiches?
helios, The Stack and the Heap, I guess. Thanks. :)
Zephilinox, It means what I think it means, right?
Last edited on
There are two meanings, the first is the same as T_T or :'[ (I.e I'm sad and crying) the second one is the one I'm used to, 'Cry More Noob'
Oh, I was using it like I was crying. I never knew it was also an insult. O.O

Anyone else have anything? :)
Why don't you start coding something related to memory, do you know pointers inside-out? the c++ standard for bit/byte sizes of all built in data types? can you make a dynamic memory factory? or construct your own double linked list (because C++ uses a single linked list, so it's nicer if you don't re-implement something that's already available in the stl)
Zephilinox wrote:
because C++ uses a single linked list

std::list is a double linked list.
what? I could of sworn they were single linked lists ._. but checked again and you're right, they are, odd, I don't know why I thought they were single...
^^ A hint is the bi-directional iterator.
This is a very very vague question.
First of all I should say that optimization on language level is secondary. Algorithmic optimization always comes first. I mean no matter how optimized is your implementation of bubble sort is it will never (except tiny arrays) be faster than heap sort or quick sort. An excellent book on this topic is this one: http://www.amazon.com/Introduction-Algorithms-Thomas-H-Cormen/dp/0262033844
and you should probably start with this if you think of optimizing anything.

But of course there's much more than that - understanding the CPU pipeline (instruction counts for memory access, branch prediction, several levels of cache), optimizing code for multi-core architectures (including GPU's with CUDA/DirectCompute/OpenCL) and much much more. There is no single book (AFAIK) that will allow you to always write optimal code.

And there's even more than that - are you sure you need optimization in a particular place (finding a bottleneck is important), is it worth to trade programming effort for gaining 0.1% faster and 0.3% less memory consuming code? What about that code being cross-platform? Are you willing to support several versions for different platforms? What about code maintenance? Do you wish to write part of code in assembly just to win several cpu cycles?

Sometimes the answer to these questions is "yes", but it is very very application dependent and no book would be able to give you a general advice on that.
closed account (o3hC5Di1)
Hi there,

I hate to say it, but google really has a lot of links turning up in this aspect:
http://www.google.com/search?q=c%2B%2B%20memory%20optimization

All the best,
NwN
Topic archived. No new replies allowed.