Questions tagged [memory-allocation]
The memory-allocation tag has no usage guidance.
74
questions
2
votes
1
answer
42
views
Buddy system allocator and slab allocator in Linux kernel
In the Silberschatz's book "operating systems" the author talks about the allocation of memory via system buddy and slab.
My first question is: in the book, both memory allocation methods ...
0
votes
1
answer
26
views
Bitvector for Memory Allocation
Lets say a system has 1TB of memory and 4kB blocks. How many MB of memory do we need if we want to store a bitvector to represent the current memory allocation situation with a bitvector?
Bitvector: a ...
0
votes
0
answers
14
views
New Heap after consecutive calls to Realloc and Free
I'm currently spending my time preparing for my exam in Computer Systems. Everything is going smoothly enough, but there is one task I am having problem with understanding. I've been trying to find ...
1
vote
2
answers
65
views
Realistic model of memory allocation/deallocation cost
When doing complexity analysis, they never account for the costs of memory allocation/deallocation on the heap. In particular, this is the case for the announced complexities of the operations on ...
1
vote
2
answers
88
views
How can I write 2^65 on my 64-bit computer?
This is possibly a very trivial question for this site.
If I have a 64-bit laptop that means 2^64 combinations in total are possible.
But I can even get $2^{(x>>>64)}$ on my laptop.
Now, it ...
0
votes
1
answer
29
views
Can Operating system allocate a page of process to any free frame in memory?
Consider I have a user program of 6 pages and 4 byte page size. Now my memory has 300 frames out of which 10 frames are free for allocation. Can the OS allocate page 1 of the given process to any of ...
0
votes
1
answer
82
views
Difference between Caching and Slab Allocator
I've seen the term caching allocator and slab allocator used in discussions about allocation strategies, and would like to understand the difference between them.
I can see some resources on slab ...
2
votes
1
answer
38
views
Words in computer's memory
I don't know much about memory. Here are some lines from CLRS:
The words in a computer memory are typically addressed by integers from 0
to $M - 1$, where $M$ is a suitably large integer. In many ...
1
vote
1
answer
353
views
Memory Address Lines
I am reading a text book by David Tarnoff and there is something I do not understand, the section is on CPU and memory. The book states that the number of address lines going into a memory device ...
0
votes
0
answers
19
views
How do you work out the segmentation table, offset and frame size in segmented memory management?
If I had a process, 1, which has the following segments:
Segment 1 - 50 bytes
Segment 2 - 200 bytes
Segment 3 - 90 bytes
and I know that the total bytes in memory is 1024, how do I work out the offset/...
1
vote
1
answer
68
views
Constant-time adding an element?
Is a computer with infinite memory and infinite word size a Truing machine equivalent (in the sense that polynomial time remains polynomial time and exponential time remains exponential time) if we ...
0
votes
1
answer
224
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
2
answers
283
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
0
answers
49
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
0
answers
16
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
2
answers
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
2
answers
66
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 ...
0
votes
0
answers
46
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
0
answers
67
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
1
answer
521
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
1
answer
213
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
2
answers
98
views
Understanding memory leaks in C/C++ [closed]
I was looking at an example here:
https://blog.parasoft.com/finding-memory-leaks-in-c
...
3
votes
3
answers
3k
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
1
answer
41
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
4
answers
1k
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
2
answers
50
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
1
answer
81
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
2
answers
283
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
1
answer
25
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
0
answers
31
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
1
answer
188
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
1
answer
539
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
1
answer
476
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
1
answer
103
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
2
answers
127
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
0
answers
18
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
2
answers
128
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
0
answers
25
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
3
answers
166
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
1
answer
260
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 ...
4
votes
2
answers
39k
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
1
answer
105
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
0
answers
33
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 ...
6
votes
1
answer
6k
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
2
answers
143
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
1
answer
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
...
55
votes
8
answers
23k
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
1
answer
4k
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
1
answer
890
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
3
answers
12k
views
Row Major Vs Column Major Order: 2D arrays access 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?
...