Questions tagged
dynamic-memory-allocation
Dynamic memory allocation, usually in the context of languages without garbage collection or mandatory or automatic reference counting, refers to the process or asking the operating system for a variable sized block of memory.

Dynamic memory allocation, usually in the context c or c++, refers to the process of asking the operating system for a variable sized block of memory.

In those languages, allocation involves the use of a few different techniques:

  • malloc (C), operator new (C++)
  • free (C), operator delete (C++)

Dynamic memory allocation is complicated due to need of a way to make sure that the memory is freed after it's use. Although most operating systems will deallocate memory after program termination, it is unwise to do so (see this question). There are many ways to manage dynamic memory, but in C++, the most common is a smart-pointers.