Extreme C
上QQ阅读APP看书,第一时间看更新

Summary

As part of this chapter, we mainly covered the Stack and Heap segments and the way they should be used. After that, we briefly discussed memory-constrained environments and we saw how techniques like caching and memory pools can increase the performance.

In this chapter:

  • We discussed the tools and techniques used for probing both Stack and Heap segments.
  • We introduced debuggers and we used gdb as our main debugger to troubleshoot memory-related issues.
  • We discussed memory profilers and we used valgrind to find memory issues such as leakages or dangling pointers happening at runtime.
  • We compared the lifetime of a Stack variable and a Heap block and we explained how we should judge the lifetime of such memory blocks.
  • We saw that memory management is automatic regarding Stack variables, but it is fully manual with Heap blocks.
  • We went through the common mistakes that happen when dealing with Stack variables.
  • We discussed the constrained environments and we saw how memory tuning can be done in these environments.
  • We discussed the performant environments and what techniques can be used to gain some performance.

The next four chapters together cover object orientation in C. This might at first glance seem to be unrelated to C, but in fact, this is the correct way to write object-oriented code in C. As part of these chapters, you will be introduced to the proper way of designing and solving a problem in an object-oriented fashion, and you will get guidance through writing readable and correct C code.

The next chapter covers encapsulation and the basics of object-oriented programming by providing the required theoretical discussion and examples to explore the topics discussed.