# Tag Info

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 ...
• 80.4k

### 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 ...
• 19.1k

### 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 ...
• 1,331
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. ...
• 3,085

### 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 ...
• 143k

### 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 ...
• 366
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 ...

### 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 ...
• 29.2k

### 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 ...
• 410

### 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 ...
• 141
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 ...
• 29.2k

### 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 ...

### 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.
• 80.4k
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, ...
• 19.1k

### 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 ...
• 17.3k
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 ...

### 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 (...
• 3,246

### 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 ...
• 207

### 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. ...
• 452

### 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 ...
• 2,682

### 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 ...
• 769

### 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 ...
• 17.3k

### 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, ...
• 19.1k

### 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 ...
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 ...
• 143k
Accepted

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 ...
• 1,029

### 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 ...
• 546
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 ...
• 19.1k