This is a nerd question but I can’t find anything in google. So, in which programming language did the classical memory management system first be implemented?

I mean the division into value types (ordinary Int, Bool, etc.) and reference types, for which we must use alloc / malloc to initialize and free to free up memory in C (as I heard it is called heap). I called it a classic, because I met this approach in many other languages ​​and thought it was almost a standard. But it became interesting to me in which languages ​​this mechanism was implemented for the first time, or maybe it completely depends on the type of OS. I'm not sure that in some integral BASIC, for example, was something like that.

  • 1
    Mind to explain what you considere a 'classic memory management'? A Stack is not neccessarry static, not a Heap dynamic in fact, a dynamic heap is rather uncomon. Which in turn may require you to define the meaning of Heap and Stack as well as Dynamic and Static, as when it comes to early developements, names may have been way different then what we call it nowadays (or assume so).
    – Raffzahn
    Oct 13, 2018 at 9:30
  • 2
    Now your question boils down to: "Which programming language first implemented memory management as C did?" - The answer is maybe a bit too obvious ;) I have some ideas where you might be going, but you may need to put a bit more effort into your question. The way it's put now, the simple answer is "C was the first language to implement C memory management"
    – tofro
    Oct 13, 2018 at 9:40
  • 2
    Not all pointers are heap memory or need to be allocated with malloc. Oct 13, 2018 at 19:05
  • 2
    "This is a nerd question" - I'm pretty certain we're all nerds here :-)
    – user6464
    Oct 14, 2018 at 23:24
  • 2
    In fact, malloc() and free() are not part of the C language at all. They're just library routines. Oct 15, 2018 at 15:57

2 Answers 2



At least for the Stack, as used for subroutine handling (return address as well as parameter passing and local variables) ZMMD might be the first.

Bauer and Samelson, at the University of Munich started building a Compiler using the recent 'invented' stack principle in 1955 for the PERM, a back then tube computer. The stack principle was not only used to manage subroutines, but also as a method to compile the source code. This led in 1956 to a cooperation between the Universities of Zurich, Munich, Mainz and Darmstadt (hence the name). The idea was to create a language that could be used to compile programs for various machines from a single source.

In 1958 this led to an ACM conference in Zurich, where the concept was formalized and agreed as a standard called International Algebraic Language (IAL), later to be known as ALGOL-58.

First implementations where made for

In fact, for the Zuse, Algol became somewhat like BASIC on later home computers, as it stayed true to the idea of not using binary code, but compilation at execution. The Z23 (transistorized version of the Z22) was delivered by default with an Algol compiler as part of the OS memory (Drum). Programs to be executed were loaded from external memory (punch card, punch tape, magnetic tape) and compiled each time they were used.

Algol is often named the first 'modern' language. C is a true descendant of Algol with its change of keywords into symbols and some hardware-specific addons as notable differences.


Memory management like the C heap was also envisioned with Algol, but not implemented, as the very first machines simply hadn't enough memory available to make frivolous use of precious global memory :) But it did allow to allocate dynamic stack memory at runtime (*1).

This changed dramatically during the early 1960s, as computers switched from drums to core - and core in huge sizes, sometimes 64 KiB and more :)

PL/1 might be the first, at least the first major language to implement a heap management. It got introduced in 1966 with IBM's PL/1 for the /360 (*2). Algol added support for dynamic allocation about the same time, officially with it's Algol-68 standard, where also a heap keyword was added to allocate heap memory for a structure (*3).

Fun fact for C: There is next to no C program without an ASCII backslash (\) character, but it was Algol that made ANSI to introduce it to its September 1961 version, so the special Algol operators (AND) and (OR) could be spelled using a digraph of ASCII characters (/\, \/) - not to mention that C, as Algol's grandchild, did support them in addition to &/| -- at least in early versions.

Which in turn shows why Unicode is such a great idea, as it gave back all the great mathematical operators early programming languages used, including Ac and Vel.

*1 - This did not only go well with its creators idea of a nicely nested program and data structure, but also was highly efficient and provided automatic garbage collection. Everything allocated on the stack was automatically cleaned when leaving a procedure, so any need for dynamic memory was satisfied by the stack, due to this nature of only being accessible to code on the same or lower level of nesting, and automatic cleaning when leaving.

After all, the heap is as evil as any other global variable, isn't it?

*2 - An early example how bloaty software developed by committee can be - to fit the compiler into back then well suited 64 KiB machines, it had to be split into almost 100 overlays swapped in during a single compile run.

*3 - Unlike next to all of its offspring, Algol could allocate dynamic runtime memory from the stack as well as from a heap.


allocates an ASTRUCT size chunk on the (local) stack, while


requests a similar one from the (global) heap.

There was only one heap. Allocation from user pools wasn't supported (as always it could be handled as some kind of array of structures by the program itself).

  • The S/360 architecture didn't have a stack in the modern sense of the word (for example there was no stack pointer register) but PL/I did use chained "data frames" for local variables within subroutines. Confusingly by modern conventions, the S/360 assembler POP and PUSH instructions were assembler directives which saved and restored the assembler's controls for things like printed or punched-card output, rather than being part of the code being assembled!
    – alephzero
    Oct 13, 2018 at 11:54
  • "There was only one heap" - at some point in the development of S/360 and S/370, there were effectively two heaps, because virtual memory was split into a base section of 16MB (of which only 7MB was available to user programs, the rest being used by the OS) and the remainder "above the [16 MB} line." Using the memory "above the line" required program directives to allocate and free it, and to associate it with variables in a high level language.
    – alephzero
    Oct 13, 2018 at 12:00
  • @alephzero a) having a software defined stack instead of a missused return stack is something I always prefer (not at least after 30+ years of /370 code). And b) no, this is not about memory allocation due OS functions, but one using language features.
    – Raffzahn
    Oct 13, 2018 at 12:08
  • Footnote 1: I think they call that RAII these days.
    – Davislor
    Oct 13, 2018 at 19:38
  • @Davislor Jup, somewhat similar, except that RAII resources are not located on the stack but within the heap. So there exists additional code when creating and releasing it that calls heap management functions. With Algol it was just the creation of a stack frame relative address referenc for creation, and literally nothing for deletion.
    – Raffzahn
    Oct 13, 2018 at 20:16

This question starts of with a wrong premise. C does no have this distinction between "value types" and "reference types" at all. However, Simula significantly predates C, being developed in 1965, and Simula does have Ref types.

  • 1
    Welcome to Retrocomputing! Because you did address part of the question, I have upvoted your answer. However, the question appears to be about memory management, rather than variable typing. If you could address memory management, it would improve this answer.
    – DrSheldon
    Oct 14, 2018 at 5:47
  • Sorry if I was wrong with terms:( How should I change my question to be correct? I met last time with C in university and never write any production code with it. Maybe I just not understand information on lessons in right way... Oct 14, 2018 at 8:56
  • 1
    @MatveyMalatsion "Stack variables" and "heap variables" are probably the words you're looking for; technically "heap variables" are pointed to by stack variables but everybody will know what you mean.
    – wizzwizz4
    Oct 14, 2018 at 20:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .