86 votes
Accepted

Why don't compilers automatically insert deallocations?

Because it's undecidable whether the program will use the memory again. This means that no algorithm can correctly determine when to call free() in all cases, which ...
user avatar
57 votes

Why don't compilers automatically insert deallocations?

As David Richerby rightly noted, the problem is undecidable in general. Object liveness is a global property of the program, and may in general depend on the inputs to the program. Even precise ...
user avatar
  • 19.1k
30 votes

Why don't compilers automatically insert deallocations?

It's an incompleteness problem, not an undecidability problem While it's true that the optimal placement of deallocation statements is undecidable, that's simply not the issue here. Since it's ...
user avatar
  • 1,331
27 votes
Accepted

If the virtual address space can be larger than the physical address space, how are the address mappings stored in memory?

The trick to making this work is "paging." When bringing data from a hard disk into physical memory, you don't just bring a few bytes. You bring an entire page. 4k bytes is a very common page size. ...
user avatar
  • 3,085
25 votes

Is a computer without RAM, but with a disk, equivalent to one with RAM?

Sure. In principle, given appropriate hardware, you could have just a disk, with everything stored on disk. Any time the CPU did a load or store instruction, there could be some hardware that turns ...
user avatar
  • 143k
24 votes

Why don't compilers automatically insert deallocations?

Currently, none of the posted answers are fully correct. It's not impossible to do this, but adding that feature would restrict mermory allocation patterns. Why don't compilers automatically insert ...
user avatar
16 votes
Accepted

Writing a multitasking operating system for a processor without MMU

It's actually not that hard to design an operating system that doesn't require an MMU. There are a few conveniences you'll have to do without, but nothing insurmountable. Since different tasks will ...
user avatar
16 votes

Is a computer without RAM, but with a disk, equivalent to one with RAM?

In terms of computability, it is known that every modern day computer can be simulated by a Turing Machine whose only storage is a single, linear tape cells that can be written. Assuming you can keep ...
user avatar
  • 29.2k
14 votes

Memory ballooning in the OS

Actually, what you've described confuses ballooning and 'same-page-merging'. I'll try to elaborate on the two to make the distinction apparent. Memory ballooning This is a trick to make sure that ...
user avatar
  • 410
14 votes

Is a computer without RAM, but with a disk, equivalent to one with RAM?

The question is not purely academic. It is a matter of historical record that one of the earliest commercially-produced computers [sorry, I don't recall which offhand] did not have any RAM - all ...
user avatar
  • 141
14 votes
Accepted

What does "map" mean?

So, there are two distinct uses of the word "map", that I'll unpack here. The first is very generic, where map means "to associate," particularly by way of a function. If we say "$f$ maps each $x$ to ...
user avatar
  • 29.2k
13 votes

How do garbage collectors avoid stack overflow?

Note that I am not a garbage collection expert. This answer only gives examples of techniques. I do not claim that it is a representative overview of garbage collection techniques. An unscanned queue ...
user avatar
12 votes

Since programs are swapped from backing store to main memory why don't they get lost when the computer is suddenly turned off?

Because it isn't moved: it's copied.
user avatar
11 votes
Accepted

How do garbage collectors avoid stack overflow?

In a nutshell: Garbage collectors do not use recursion. They just control tracing by keeping track of essentially two sets (that may combine). The order of tracing and cell processing is irrelevant, ...
user avatar
  • 19.1k
10 votes

How does the OS know the physical address of a process' first memory page?

The operating system performs a lot of work before executing the first instruction. The OS must set up at least two data structures, the page table and the region map. The region map is called ...
user avatar
10 votes
Accepted

Why is the object destructor paradigm in garbage collected languages pervasively absent?

The pattern you're talking about, where objects know how to clean their resources up, falls into three relevant categories. Let's not conflate destructors with finalizers - only one is related to ...
10 votes

Why don't compilers automatically insert deallocations?

"Humans do it, so it's not impossible" is a well-known fallacy. We do not necessarily understand (let alone control) the things that we create - money is a common example. We tend to overestimate (...
user avatar
9 votes

Why don't compilers automatically insert deallocations?

The issue is mostly a historic artifact, not an impossibility of implementation. The way most C compilers build code is so that the compiler only sees each source file at a time; it never sees the ...
user avatar
  • 207
9 votes

Why don't compilers automatically insert deallocations?

The lack of automatic memory management is a feature of the language. C is not supposed to be a tool for writing software easily. It is a tool for making the computer do whatever you tell it to do. ...
user avatar
8 votes

How exactly MOV AX will load data from RAM?

I am not sure if this is actually on-topic here, but anyway. The main memory in x86 architectures is addressed byte-wise. If you want to retrieve 16 bits from address 2000h (note that AX is a 16 ...
user avatar
  • 2,682
8 votes

Are there any garbage collectors that take into account paging?

Emery Berger, Matthew Hertz & Yi Feng did some work on this. Garbage collection offers numerous software engineering advantages, but interacts poorly with virtual memory managers. Existing ...
user avatar
8 votes

How can a CPU access more memory locations than 2^wordsize?

The 8080, as @TEMLIB pointed out, had 16 bit registers (the program counter, the stack pointer and BC, DE, and HL), and could access 216 bytes of memory. The 8080 had an 8-bit bus, and for ...
user avatar
8 votes

Is page size always equal to frame size?

A page is a region of virtual address space, and a page frame is a region of physical memory. A page which maps a region of physical memory must have the same size as that piece of physical memory, ...
user avatar
  • 19.1k
8 votes

What does "map" mean?

In the following I am going to be less than accurate in a number of ways, sacrificing technical accuracy to provide a basic understanding. It is obvious that you have read a number of technical ...
user avatar
8 votes
Accepted

How does the TLB identify a particular process?

In the most basic setup, the TLB doesn't determine that. Instead, the TLB only maintains mappings for the pages that are accessible to the current process. If process A is currently running, the TLB ...
user avatar
  • 143k
8 votes
Accepted

difference between "addressable" and "address" in memory?

Address is a label that identifies a memory location. The memory is $4$ byte addressable means that you have labels that refer to memory locations of size $4$ bytes. You don't have names for smaller ...
user avatar
  • 1,029
7 votes

How is heap memory allocated to a process?

Heap allocators typically call a system call to reserve a region of pages and then dole out chunks of that to new, malloc, and ...
user avatar
  • 546
7 votes
Accepted

Why is word-addressable the exception, not the rule?

Byte operations will always be important because a lot of a modern workload involves bytes. Text processing and bytecode interpretation (including emulation of other CPUs) are obvious examples, but ...
user avatar
  • 19.1k
7 votes

Is a computer without RAM, but with a disk, equivalent to one with RAM?

No. Disk drives are not Random Addressable like RAM. Instead they're block storage devices. You can't read or write a byte from them. And your CPU cannot read a whole sector at once, they need that ...
user avatar
  • 809
7 votes

Why do we need the valid-invalid bit in a page table?

As David Richerby says, it’s not clear what you don't understand.  Most of my answer here has already been presented in answers (or comments) to the questions you linked to. I’ll admit, though, that ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible