Qs: Memory
How many bits in 1 byte?
8 bits
Which statements about garbage collection and memory leaks are true?
Garbage collection automatically frees all unused memory.
Memory leaks can still occur even in garbage-collected languages.
Circular references can prevent garbage collectors from reclaiming memory.
Garbage collectors operate in real-time, immediately reclaiming memory when it's no longer referenced.
2 and 3
Which type of memory is generally preferred for storing temporary data in a program, such as local variables within a function?
Stack
Garbage collection and memory leaks
Memory leaks can still occur even in garbage-collected languages.
Circular references can prevent garbage collectors from reclaiming memory.
Garbage collection does NOT:
automatically free memory
operate in real-time by immediately reclaiming memory when no longer referenced
In the memory hierarchy, which type of memory typically has the fastest access time?
Fastest to slowest:
a. SSD
b. CPU Cache (L1, L2, L3)
c. HDD
d. RAM
Solution:
CPU Cache (L1, L2, L3) - the fastest and most expensive memory type.
RAM
SSD
HDD
Steps a CPU follows to interpret code in a CPU Cycle?
Fetch
Decode
Execute
In a computer system using 32-bit addressing, how much total memory can be addressed?
2^32 bytes
Rank from fastest to slowest ?
a. Reading 1MB from SSD
b. Decompressing 1MB with a simple compression algorithm
c. Reading 1MB from RAM
d. Reading 1MB from HDD
e. Downloading 1MB over the network
Solution:
Reading 1MB from RAM
Decompressing 1MB with a simple compression algorithm (e.g., LZ4)
Reading 1MB from SSD
Reading 1MB from HDD
Downloading 1MB over the network
Last updated