Questions tagged [memory-allocation]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
2answers
41 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 ...
0
votes
1answer
52 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
63 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
0answers
16 views

External fragmentation of memory

Im trying to calculate the external fragmentation of a memory with the content UFFFUUFFUU where U is used, and F is free. Im confused as to how to do this, when i dont know the number that Used is ...
0
votes
0answers
16 views

How does increase in main memory affects cache performance?

I know advantages of increase in main memory like more pages , better Spatial locality of reference , more number of processes in main memory and increase in CPU performance. What can be disadvantages ...
0
votes
1answer
19 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 ...
0
votes
0answers
12 views

What happen if the L1 cache has the address entry with write_back attribute. Will that address be available in L2 cache?

I have the TLB entry for a particular address. This address has write-back attributes in both L1 cache and L2 cache. My queries are: 1> if L1 cache entry has write-back, can it be write-back in L2? 2> ...
3
votes
0answers
26 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
48 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
0answers
18 views

How to optimally select free-list in a custom allocator?

I have a program where I cannot afford to use standard memory allocators because they use MAP_PRIVATE and not MAP_SHARED for the ...
0
votes
1answer
66 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
132 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
84 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
53 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
16 views

Memory addressing

What does the following sentence mean? "The 8085 micropressor has the capability of addressing 64KB of RAM?" In general, what is the meaning of a CPU's ability to address a given amount of memory? ...
0
votes
0answers
11 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
70 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
70 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 ...
1
vote
1answer
60 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 ...
2
votes
2answers
21k 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
67 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
24 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 ...
2
votes
1answer
1k 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
42 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
1k 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 ...
50
votes
8answers
17k 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
2k 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
559 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 ...
2
votes
2answers
5k 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
141 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
175 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
2answers
8k 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
56 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
545 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 ...
1
vote
2answers
1k 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
89 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
575 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 ...
10
votes
2answers
9k 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 ...
1
vote
1answer
7k views

Would it be possible to use the cloud for RAM?

I'm not sure if this is the right place to ask but I had this idea. Since the cloud can be used for storing memory, would it be possible to use it for RAM too?
5
votes
0answers
358 views

When there's no memory, should malloc or read/write fail?

To my surprise, I recently found out that Windows would fail a large memory allocation even if little of said memory is to actually be used, e.g. even if you don't want the swap, you better not ...
2
votes
2answers
737 views

where is all deleted data will go from memory system/internet? [closed]

where is all deleted data will go from a memory system ? if it is not deleting actually where it storing ? i am always wonder about this when we are sending something to a memory system it takes ...
7
votes
3answers
15k views

How are hash table's values stored physically in memory?

Question: How are hash table's values stored in memory such that space if efficiently used and values don't have to be relocated often? My current understanding (could be wrong): Let's say I have 3 ...
0
votes
1answer
81 views

In Ada95 how many bytes does integer occupied in memory? [closed]

Also asking for float, character, ect.
0
votes
1answer
53 views

Name for almost random memory distribution on the heap

If I had a heap like the following: with blue blocks being occupied memory and white blocks being free memory What is the general name given to the situation illustrated, where the free and occupied ...
3
votes
3answers
4k views

How is heap memory allocated to a process?

I want to better understand how OS provides heap memory to a process. Here by heap memory I mean the memory allocated dynamically, say by call to malloc. When a ...
-1
votes
1answer
127 views

In case of program overlays; is it necessary to have error handling routine in memory, regardless of error?

I came accross the question regarding program overlays, ...
0
votes
1answer
5k views

Dynamic loading vs. dynamic linking?

What is the difference between dynamic loading and dynamic linking? Both systems seem to allow shared libraries, but I am struggling to differentiate between them.
0
votes
1answer
114 views

How Does Dynamic Heap Storage Have Something to Do with Heap?

There are three typical ways to allocate memory for programs: static, stack and dynamic heap. However, when I look at the implementation of dynamic heap memory allocation from wikipedia , what I found ...