Questions tagged [memory-allocation]
The memory-allocation tag has no usage guidance.
64
questions
0
votes
1answer
24 views
Number of hardware page tables and page directories kept in the MMU
How many hardware page tables (physical) and page directories are kept in the memory management unit?
If a cpu has a 32 bit virtual address, the upper 10 bits are used for the page directory, the ...
2
votes
2answers
56 views
How are programs split up into pages in Memory Paging?
I am a bit confused about how the logical addresses are generated in a paging memory architecture and where and when a program is split up into pages.
I understand how logical addresses are translated ...
0
votes
0answers
39 views
memory management - interview question
I was asked the following question in an interview and I don't understand what is the best solution for it -
Assume you have an application that needs memory. It asks for a program for this memory, 20 ...
0
votes
0answers
11 views
Can I have 2 free adjacent nodes in the fit algorithm for data management
so I know we can have 2 busy adjacent nodes for the fit algo since there'll always be free memory available, but what about when it comes to 2 free adjacent nodes? Is it possible to have 2 adjacent ...
5
votes
2answers
1k views
What course in CS deals with the study of RAM, CPU, Storage?
I watched the Crash Course playlist of Computer Science. It was teaching about RAM, CPU, Storage etc but I felt it was way too fast and only people who have studied the course first hand understood it ...
0
votes
2answers
44 views
Storage in registers
Whenever CPU needs the data, it gives the address of that word to the RAM via bus, then the RAM generated the copy of that word and sends to the registers via bus. Why can't the RAM send the original ...
1
vote
3answers
151 views
How is a program stored before compiling?
When we write code, after compilation the code will be converted to machine language and then stored in the hard disk. But before compiling the code, it is still in the high-level language. How and ...
0
votes
0answers
38 views
Concurrent Garbage-Collectiong/Compacting Memory Allocator
I'm developing an algorithm for concurrent heap garbage collection/compaction. It will be used in low latency systems that need to scale well to a lot of clients, e.g. web servers.
I thought about an ...
0
votes
0answers
30 views
Unbanked access, banked access and common memory access
What are they and what are their differences?
Unbanked access
Banked access
Common memory access
[EDIT]
This question is originated from my reading of MPLAB XC8 PIC Assembler User's Guide where the ...
0
votes
1answer
64 views
How much space an ascii character really takes on a 64 bit word addressable memory?
I know that an ASCII character needs 1 byte of memory for storage, but if a computer uses a 64-bit word addressable memory does it mean that the character actually takes 8 bytes even when only 1 byte ...
1
vote
1answer
51 views
How does computer memory store the file name?
I have this doubt for long time. When i save a notepad file, it takes the memory for the information in the file. let's say, I type 'ABC' in notepad and saved the filename as stack, it shows that the ...
0
votes
2answers
56 views
Understanding memory leaks in C/C++ [closed]
I was looking at an example here:
https://blog.parasoft.com/finding-memory-leaks-in-c
...
1
vote
2answers
123 views
Determine page number and offsets for address references
I'm working on learning operating systems and I've come across a strange question that I don't know how to answer.
The question is:
Assuming a 1-KB page size, what are the page numbers and offsets ...
0
votes
1answer
30 views
Memory Addressing - Alignment Clarification
I'm reading "Computer Architecture A Quantitative Approach" (5th edition) and I'm having a hard time understing this table:
I understand how Misalignment happens, i.e., some byte, half-word, word, or ...
1
vote
3answers
353 views
The maximum decimal integer that can be stored in memory of 8-bit word processor computer?
Actually i am preparing for an exam and in the last year exam this que. was been asked. i.e
The maximum decimal integer number that can be stored in memory of 8-bit word processor computer ?
a)...
2
votes
2answers
46 views
Can the same machine word sometimes be data and sometimes be code?
I have a question about machine words. We have data and a code segment in the memory which is addressed. If we take a word from it and let's say it is a code (instruction), and another one is some ...
2
votes
1answer
70 views
How big is the capacity of a standard memory cell that the pointer is linking to?
Often programming language lectures and references have an illustration of computer memory as an array composed of individual cells. Each cell has an address, which is effectively the pointer and can ...
1
vote
2answers
130 views
Is call stack compile time or runtime detail?
I'm sorry if the question is quite naive, but I don't understand if a call stack is a language implementation detail or it depends on OS?
What I'm trying to understand is what decides how to store ...
0
votes
1answer
23 views
Recursive Call Inside Argument List (C++) [closed]
So, my professor asked me to implement recursion in different ways to compute $a^n$ (a and n being integers) and rank them according to their space efficiency. Now, here is one of the methods I came ...
3
votes
0answers
27 views
Rearrange items in order reduce fragmentation and reduce wasted space
I have a segment with some offsets at irregular intervals
There are items of various length inside. Items cannot be placed randomly. Instead, their left side must match some offset.
Items are free ...
0
votes
1answer
102 views
Distinction between paging and segmentation?
In my operating systems textbook, there is a paragraph which states:
As for the contents of each PTE, we have a number of different bits
in there worth understanding at some level. A valid bit is ...
0
votes
1answer
231 views
Converting physical address to logical
In 8-bit address space there are 16 pages and the page table stores:
68792EA51BD3CF04 (hex)
The physical address is 39h, what is the corresponding logical address?
I have literally no idea what to ...
2
votes
1answer
314 views
Is it theoretically possible to dynamically grow array size in stack memory?
I was wondering, given the usual stack memory functioning, whether it is possible for an array like primitive type allowed to grow in size to exist.
The functioning of such primitive type is as ...
1
vote
1answer
89 views
How does dynamic memory-allocation exactly work?
I have wondered about ordinary code. Assume we are running this code on any modern System like Unix/Linux/Mac/Windows. This code is C, but it should work with every language which is close to the ...
0
votes
2answers
77 views
How does the memory of a 64bit and 32bit processor work
In this article, the author states that a 64bit processor can theoretically reference 2^64 bytes of memory. What does he mean by this statement, or rather the word, reference?
Also, I visualize the ...
0
votes
0answers
17 views
Memory interfacing problem [duplicate]
I've learnt that the memory interfacing problem is used when we need to connect a memory that has lesser number of locations to a processor that has more address lines.
For eg. Connecting memory chips ...
1
vote
2answers
83 views
Random access memory and data
What kind of data is stored in the RAM when it is fresh out of manufacture?
Apart from certain basic instructions (if yes, what are they), are there numbers stored as well or are most of the memory ...
1
vote
0answers
22 views
Addresses with no memory allocated
I've read that a program can crash if it tries to access addresses with no memory allocated. But, how is it possible that an address has no memory allocated? When does it happen?
0
votes
3answers
93 views
How does a computer remember the address of a data variable in a program, in the main memory?
Suppose I write a program as below:
int main()
{
int a = 3;
int b = 4;
return 0;
}
Suppose the computer stores the address of 'a' as 0x00104. How does it ...
2
votes
1answer
124 views
Binary trees and preallocated nodes
I want to design a binary tree with preallocated nodes, in order to avoid calling malloc/free every time I want to insert/delete a node. The problem is I don't know ahead of time how many nodes the ...
3
votes
2answers
32k views
How is the formula for calculation in row/column major obtained?
In my book, this formula is given for calculation of address of row major order's element $[I,J]$:
Address of $[I,J]$th element in row major order $= B + W[n(I-L_r)+ [J-L_c]]$
where B denotes base ...
1
vote
1answer
83 views
Allocating memory via Buddy Allocation
I'm trying to learn buddy allocation and whilst I think I understand the basics of it, there is one problem exercise with which I'm struggling with.
So I have an 8K block and I'm using buddy ...
2
votes
0answers
25 views
Sweeping integrated into memory allocation: Why only fixed size objects?
In our language design book, it is mentioned that GC sweep can be integrated into allocation, such that when you call malloc for example, you sweep until you find a ...
4
votes
1answer
3k views
What is the time complexity of memory allocation assumed to be?
It is well-known that dynamic arrays have an amortized $O(1)$ time complexity for adding one item, but a worst-case $O(n)$ complexity. This is because for particular values of $n$, there is no more ...
1
vote
2answers
57 views
If you increase the address space for an OS, does the Phys Mem used by the program increase?
I am learning about the OS.
I know: that Address Space Size = # of pages x page size
So if I increase Address Space Size, then the number of pages increases:(not the page size). However, isn't the ...
1
vote
1answer
2k views
Why do we use dynamic memory allocation in general and why did we use it in this particular example? [closed]
Dynamic Programming C/C++ implementation of LIS(Longest Increasing Subsequence) problem
...
51
votes
8answers
21k views
How are variables stored in and retrieved from the program stack?
Apologies in advance for the naivety of this question. I am a 50 year old artist trying to properly understand computers really for the first time. So here goes.
I have been trying to understand how ...
1
vote
1answer
3k views
How does malloc(sizeof(char)) work [closed]
AFAIK, malloc(sizeof(char)) is intended to allocate a 1-byte block of VM and strcpy requires that
the destination string dest must be large enough to receive the copy
That means theorically that ...
2
votes
1answer
741 views
Do modern operating systems use memory control blocks?
I was taught in my operating systems class that sections of memory in the heap are marked as free/occupied through the use of memory control blocks (MCB). The generalized definition of an MCB that was ...
4
votes
2answers
7k views
Row Major vs Column Major order access 2D arrays in programming languages
Programmers prefer accessing a 2D array in Row-Major Order rather than Column-Major Order, Why?
Are there some advantages/benefits of accessing a 2D array in row-major as compare to column-major?
...
0
votes
1answer
198 views
Less used data (1 byte) in memory address holding 4 bytes [closed]
I need to store two distinct variables of 1 byte size in memory.
My memory system stores 4 bytes at one address; therefore, you cannot address byte 3 directly, and you have to logically access it ...
0
votes
0answers
180 views
Direct Mapped Cache, textbook excerpt clarification, identifying block field
I have an excerpt from my textbook concerning direct mapped cache that I would like further clarification on, the text reads.....
"Consider the following example: Assume memory consists of 2^14 ...
-1
votes
3answers
14k views
How to compute total internal and external fragmentation
I want to find the total external and internal fragmentation. What I understand is that external fragmentation occurs when processes are loaded and removed from memory, causing memory to be broken ...
1
vote
3answers
1k views
Does word addressable memory have more bytes than byte addressable memory?
Well, my question - if word addressable memory has more bytes than byte addressable memory - is derived from the fact that in word addressable memory each address addresses a word and in byte ...
2
votes
1answer
61 views
Why not space out memory allocations?
In ext4 file system, the files are spaced out as far apart as reasonably possible to allow for efficient reallocation. Why do we not do this in memory?
Why not allocate one memory as page 20, and the ...
3
votes
1answer
696 views
Combining adjacent memory blocks
This is a conceptual issue that I am having in designing an algorithm for a memory allocator that works in conjunction with memory pooling. Free blocks are put on one of several free lists within the ...
2
votes
2answers
2k views
Why is data fragmentation not possible on main memory (RAM)?
I am wondering why data fragmentation is a problem on main memory.
On a software level, virtual addresses are used anyway. So why can one address space not be split up into multiple segments, like a ...
0
votes
1answer
142 views
Memory address of variable after reassignment
When a local variable is reassigned a different value/object, does its position/address change in the stack?
6
votes
1answer
670 views
How do arrays work “under the hood”?
In some languages (such as C), arrays seem very simple to me. When allocating memory for these, all you need to do is pick a starting point in memory and then allocate the next ...
12
votes
2answers
10k views
Can someone explain this diagram about Slab Allocation?
I'm trying to understand how Slab Allocation works and why it is different or better than ordinary paging.
I found this diagram which I believe would be helpful if it had more explanation.
Some ...