1 minute read

This article is part 1 in a series: Memory management



Memory…

Well, we got so much RAM nowadays, so why even bother caring about memory management in the code.

We can fix all the memory leaks when the product is in alpha/beta/released/patched/next iteration.

Hah, this is C#/Java/JavaScript/any other gc language, we don’t have to care about memory, the GC takes care of it!

Any of those quotes seem familiar?
Well, hopefully you have not said it yourself in that case. Or maybe you don’t even know much about all that stuff anyways.
If you intend to be a good programmer, to know how to write good code which does not leak memory I urge you to learn (or at the least get a speck of understanding of) the parts about memory as early as possible, else you might have huge issues in the future!

To refresh my personal memory, I decided to write a few posts about memory management. Initially I thought I would write one post and give some minor examples and such, but it quickly became a monster…

I decided to split it up in a few different pieces:

  1. Garbage collection, which contains a brief description about the stack and the heap and also the garbage collector and how it works (simplified).
  2. C++ Pointers and References.
  3. C# Value types and Reference types.

The posts are not only for people with interests in the two languages I use for examples, multiple languages uses the same principles as the ones described, and knowing how to work with memory (even though this is just basic information) is very important as a developer.

I hope that anyone who find any errors (minor or major) let me know. Feel free to post a comment if there is anything that you find wrong!

This post have been moved from the old blog.
Original publish date is July 12 2016.